Skip to content

[types] Make MethodType generic#15993

Open
srittau wants to merge 1 commit into
python:mainfrom
srittau:generic-method-type
Open

[types] Make MethodType generic#15993
srittau wants to merge 1 commit into
python:mainfrom
srittau:generic-method-type

Conversation

@srittau

@srittau srittau commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@srittau

srittau commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator Author

Will be useful for #15977.

@github-actions

Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

pydantic (https://github.com/pydantic/pydantic)
- pydantic/experimental/arguments_schema.py:41: error: Argument 1 to "_arguments_schema" of "GenerateSchema" has incompatible type "Callable[..., Any]"; expected "FunctionType | MethodType | partial[Any]"  [arg-type]
+ pydantic/experimental/arguments_schema.py:41: error: Argument 1 to "_arguments_schema" of "GenerateSchema" has incompatible type "Callable[..., Any]"; expected "FunctionType | MethodType[[VarArg(Any), KwArg(Any)], Any] | partial[Any]"  [arg-type]
- pydantic/experimental/arguments_schema.py:43: error: Argument 1 to "_arguments_v3_schema" of "GenerateSchema" has incompatible type "Callable[..., Any]"; expected "FunctionType | MethodType | partial[Any]"  [arg-type]
+ pydantic/experimental/arguments_schema.py:43: error: Argument 1 to "_arguments_v3_schema" of "GenerateSchema" has incompatible type "Callable[..., Any]"; expected "FunctionType | MethodType[[VarArg(Any), KwArg(Any)], Any] | partial[Any]"  [arg-type]

dd-trace-py (https://github.com/DataDog/dd-trace-py)
- ddtrace/internal/wrapping/context.py:642: error: Argument 1 to "is_wrapped" of "_UniversalWrappingContext" has incompatible type "MethodType"; expected "FunctionType"  [arg-type]
+ ddtrace/internal/wrapping/context.py:642: error: Argument 1 to "is_wrapped" of "_UniversalWrappingContext" has incompatible type "MethodType[[VarArg(Any), KwArg(Any)], Any]"; expected "FunctionType"  [arg-type]
- ddtrace/internal/wrapping/context.py:645: error: Argument 1 to "get_function_code" has incompatible type "MethodType"; expected "FunctionType"  [arg-type]
+ ddtrace/internal/wrapping/context.py:645: error: Argument 1 to "get_function_code" has incompatible type "MethodType[[VarArg(Any), KwArg(Any)], Any]"; expected "FunctionType"  [arg-type]
- ddtrace/internal/wrapping/context.py:710: error: Argument 1 to "get_or_create" of "_ContextRecord" has incompatible type "MethodType"; expected "FunctionType"  [arg-type]
+ ddtrace/internal/wrapping/context.py:710: error: Argument 1 to "get_or_create" of "_ContextRecord" has incompatible type "MethodType[[VarArg(Any), KwArg(Any)], Any]"; expected "FunctionType"  [arg-type]
- ddtrace/internal/wrapping/context.py:711: error: Argument 2 to "link_function_to_code" has incompatible type "MethodType"; expected "FunctionType"  [arg-type]
+ ddtrace/internal/wrapping/context.py:711: error: Argument 2 to "link_function_to_code" has incompatible type "MethodType[[VarArg(Any), KwArg(Any)], Any]"; expected "FunctionType"  [arg-type]
- ddtrace/internal/wrapping/context.py:712: error: Argument 1 to "set_function_code" has incompatible type "MethodType"; expected "FunctionType"  [arg-type]
+ ddtrace/internal/wrapping/context.py:712: error: Argument 1 to "set_function_code" has incompatible type "MethodType[[VarArg(Any), KwArg(Any)], Any]"; expected "FunctionType"  [arg-type]
- ddtrace/internal/wrapping/context.py:718: error: Argument 1 to "is_wrapped" of "_UniversalWrappingContext" has incompatible type "MethodType"; expected "FunctionType"  [arg-type]
+ ddtrace/internal/wrapping/context.py:718: error: Argument 1 to "is_wrapped" of "_UniversalWrappingContext" has incompatible type "MethodType[[VarArg(Any), KwArg(Any)], Any]"; expected "FunctionType"  [arg-type]
- ddtrace/internal/wrapping/context.py:721: error: Invalid index type "MethodType" for "WeakKeyDictionary[FunctionType, _ContextRecord]"; expected type "FunctionType"  [index]
+ ddtrace/internal/wrapping/context.py:721: error: Invalid index type "MethodType[[VarArg(Any), KwArg(Any)], Any]" for "WeakKeyDictionary[FunctionType, _ContextRecord]"; expected type "FunctionType"  [index]
- ddtrace/internal/wrapping/context.py:723: error: Argument 1 to "get_function_code" has incompatible type "MethodType"; expected "FunctionType"  [arg-type]
+ ddtrace/internal/wrapping/context.py:723: error: Argument 1 to "get_function_code" has incompatible type "MethodType[[VarArg(Any), KwArg(Any)], Any]"; expected "FunctionType"  [arg-type]
- ddtrace/internal/wrapping/context.py:782: error: Argument 1 to "set_function_code" has incompatible type "MethodType"; expected "FunctionType"  [arg-type]
+ ddtrace/internal/wrapping/context.py:782: error: Argument 1 to "set_function_code" has incompatible type "MethodType[[VarArg(Any), KwArg(Any)], Any]"; expected "FunctionType"  [arg-type]
- ddtrace/internal/wrapping/context.py:785: error: No overload variant of "get" of "WeakKeyDictionary" matches argument type "MethodType"  [call-overload]
+ ddtrace/internal/wrapping/context.py:785: error: No overload variant of "get" of "WeakKeyDictionary" matches argument type "MethodType[[VarArg(Any), KwArg(Any)], Any]"  [call-overload]
- ddtrace/internal/wrapping/context.py:789: error: No overload variant of "pop" of "WeakKeyDictionary" matches argument types "MethodType", "None"  [call-overload]
+ ddtrace/internal/wrapping/context.py:789: error: No overload variant of "pop" of "WeakKeyDictionary" matches argument types "MethodType[[VarArg(Any), KwArg(Any)], Any]", "None"  [call-overload]

@srittau srittau marked this pull request as ready for review July 10, 2026 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant