Skip to content

Conversation

@hereisasound
Copy link

No description provided.

@github-actions

This comment has been minimized.

@AlexWaygood
Copy link
Member

Hi, thanks for the PR! It looks like this would cause mypy to start emitting a bunch of new errors on several open-source projects -- mind explaining what problem you're trying to solve here? :)

@srittau
Copy link
Collaborator

srittau commented Jun 19, 2024

Please note that there is quite a lengthy discussion around this behavior in #6670 when it was last changed.

@hereisasound
Copy link
Author

hereisasound commented Jun 20, 2024

Hello :)
For example here

import functools
from typing import reveal_type


class Flamingo:
    def __init__(self, name: str, age: int):
        pass

class Flock:
    def __init__(self):
        self.flamingos = []

    @functools.wraps(Flamingo.__init__)
    def add_flamingo(self, *args, **kwargs):
        flamingo = Flamingo(*args, **kwargs)
        self.flamingos.append(flamingo)

flock = Flock()
reveal_type(flock.add_flamingo)
flock.add_flamingo('Fiona', 3)

print(help(flock.add_flamingo))

Here is an output:

Help on method __init__ in module __main__:

__init__(name: str, age: int) method of __main__.Flock instance
    Initialize self.  See help(type(self)) for accurate signature.

None

Mypy says:

mypy fiona.py
fiona.py:19: note: Revealed type is "functools._Wrapped[[self: fiona.Flamingo, name: builtins.str, age: builtins.int], None, [self: fiona.Flock, *args: Any, **kwargs: Any], Any]"
fiona.py:20: error: Argument 1 to "__call__" of "_Wrapped" has incompatible type "str"; expected "Flock"  [arg-type]
fiona.py:22: error: "help" does not return a value (it only ever returns None)  [func-returns-value]
Found 2 errors in 1 file (checked 1 source file)

But yes, it seems really not very easy here with conflicts :(

@srittau
Copy link
Collaborator

srittau commented Jun 20, 2024

The problem here is not the used type var, it's the fact that the whole signature is copied – including the first argument. Usually this makes sense, although not in the case of wrapping a method, as the example show. In this case, the first argument should be ignored.

So we would need an overload for cases where a method is passed to wraps, but I'm not sure the current type system can handle that.

@AlexWaygood
Copy link
Member

Is this the same issue that has been reported in #10653?

@srittau
Copy link
Collaborator

srittau commented Jun 20, 2024

Is this the same issue that has been reported in #10653?

Looks like it, although that issue is a bit convoluted.

@srittau
Copy link
Collaborator

srittau commented Jun 20, 2024

See also python/typing#1410.

@hereisasound
Copy link
Author

Hmm, maybe something like this:

def wraps(
        wrapped: Callable[Concatenate[Self, _PWrapped], _RWrapped],
        assigned: Sequence[str] = (
        "__module__", "__name__", "__qualname__", "__doc__", "__annotations__", "__type_params__"),
        updated: Sequence[str] = ("__dict__",),
) -> _MethodWrapper[_PWrapped, _RWrapped]: ...

@srittau
Copy link
Collaborator

srittau commented Jun 20, 2024

I'm not sure that would work, but it's worth a try as an additional overload.

@github-actions
Copy link
Contributor

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

pip (https://github.com/pypa/pip)
+ src/pip/_internal/index/collector.py:220: error: Incompatible return value type (got "_WrappedMethod[Never, Never, [IndexContent], list[Link]]", expected "ParseLinks")  [return-value]
+ src/pip/_internal/index/collector.py:220: note: Following member(s) of "_WrappedMethod[Never, Never, [IndexContent], list[Link]]" have conflicts:
+ src/pip/_internal/index/collector.py:220: note:     Expected:
+ src/pip/_internal/index/collector.py:220: note:         def __call__(self, page: IndexContent) -> Iterable[Link]
+ src/pip/_internal/index/collector.py:220: note:     Got:
+ src/pip/_internal/index/collector.py:220: note:         def __call__(self, *args: Never, **kwargs: Never) -> Never

pydantic (https://github.com/samuelcolvin/pydantic)
+ pydantic/v1/class_validators.py:275: error: Incompatible return value type (got "_WrappedMethod[Never, Never, [type[BaseModel] | type[Dataclass] | None, Any, dict[str, Any], ModelField, type[BaseConfig]], Any]", expected "Callable[[type[BaseModel] | type[Dataclass] | None, Any, dict[str, Any], ModelField, type[BaseConfig]], Any]")  [return-value]
+ pydantic/v1/class_validators.py:275: note: "_WrappedMethod[Never, Never, [type[BaseModel] | type[Dataclass] | None, Any, dict[str, Any], ModelField, type[BaseConfig]], Any].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ pydantic/v1/class_validators.py:278: error: Incompatible return value type (got "_WrappedMethod[Never, Never, [type[BaseModel] | type[Dataclass] | None, Any, dict[str, Any], ModelField, type[BaseConfig]], Any]", expected "Callable[[type[BaseModel] | type[Dataclass] | None, Any, dict[str, Any], ModelField, type[BaseConfig]], Any]")  [return-value]
+ pydantic/v1/class_validators.py:278: note: "_WrappedMethod[Never, Never, [type[BaseModel] | type[Dataclass] | None, Any, dict[str, Any], ModelField, type[BaseConfig]], Any].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ pydantic/v1/dataclasses.py:329: error: Argument 1 to "__call__" of "_WrappedMethod" has incompatible type "Dataclass"; expected Never  [arg-type]
+ pydantic/plugin/_schema_validator.py:124: error: Incompatible return value type (got "_WrappedMethod[Never, Never, P, R]", expected "Callable[P, R]")  [return-value]
+ pydantic/plugin/_schema_validator.py:124: note: "_WrappedMethod[Never, Never, P, R].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ pydantic/type_adapter.py:144: error: Incompatible return value type (got "_WrappedMethod[Never, Never, [TypeAdapterT, **P], R]", expected "Callable[[TypeAdapterT, **P], R]")  [return-value]
+ pydantic/type_adapter.py:144: note: "_WrappedMethod[Never, Never, [TypeAdapterT, **P], R].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"

Expression (https://github.com/cognitedata/Expression)
+ expression/core/fn.py:50: error: Incompatible return value type (got "_WrappedMethod[Never, Never, _P, _TResult]", expected "Callable[_P, _TResult]")  [return-value]
+ expression/core/fn.py:50: note: "_WrappedMethod[Never, Never, _P, _TResult].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ expression/core/fn.py:69: error: Incompatible return value type (got "_WrappedMethod[Never, Never, _P, Coroutine[Any, Any, _TResult]]", expected "Callable[_P, Awaitable[_TResult]]")  [return-value]
+ expression/core/fn.py:69: note: "_WrappedMethod[Never, Never, _P, Coroutine[Any, Any, _TResult]].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ expression/core/builder.py:131: error: Incompatible return value type (got "_WrappedMethod[Never, Never, _P, _TOuter]", expected "Callable[_P, _TOuter]")  [return-value]
+ expression/core/builder.py:131: note: "_WrappedMethod[Never, Never, _P, _TOuter].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"

pandas (https://github.com/pandas-dev/pandas)
+ pandas/core/computation/align.py:86: error: Incompatible return value type (got "_WrappedMethod[Never, Never, [Any], Any]", expected "Callable[[F], F]")  [return-value]
+ pandas/core/computation/align.py:86: note: "_WrappedMethod[Never, Never, [Any], Any].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"

pwndbg (https://github.com/pwndbg/pwndbg)
+ pwndbg/decorators.py: note: In function "only_after_first_prompt":
+ pwndbg/decorators.py:32: error: Incompatible return value type (got "_WrappedMethod[Never, Never, P, T]", expected "Callable[P, T | None]")  [return-value]
+ pwndbg/decorators.py:32: note: "_WrappedMethod[Never, Never, P, T].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ pwndbg/lib/cache.py: note: In function "cache_until":
+ pwndbg/lib/cache.py:166: error: Incompatible return value type (got "_WrappedMethod[Never, Never, P, T]", expected "Callable[P, T]")  [return-value]
+ pwndbg/lib/cache.py:166: note: "_WrappedMethod[Never, Never, P, T].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ pwndbg/gdblib/proc.py: note: In member "OnlyWhenRunning" of class "module":
+ pwndbg/gdblib/proc.py:175: error: Incompatible return value type (got "_WrappedMethod[Never, Never, P, T]", expected "Callable[P, T | None]")  [return-value]
+ pwndbg/gdblib/proc.py:175: note: "_WrappedMethod[Never, Never, P, T].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ pwndbg/gdblib/proc.py: note: In member "OnlyWhenQemuKernel" of class "module":
+ pwndbg/gdblib/proc.py:184: error: Incompatible return value type (got "_WrappedMethod[Never, Never, P, T]", expected "Callable[P, T | None]")  [return-value]
+ pwndbg/gdblib/proc.py:184: note: "_WrappedMethod[Never, Never, P, T].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ pwndbg/gdblib/proc.py: note: In function "OnlyWithArch":
+ pwndbg/gdblib/proc.py:204: error: Incompatible return value type (got "_WrappedMethod[Never, Never, P, T]", expected "Callable[P, T | None]")  [return-value]
+ pwndbg/gdblib/proc.py:204: note: "_WrappedMethod[Never, Never, P, T].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ pwndbg/gdblib/abi.py: note: In function "LinuxOnly":
+ pwndbg/gdblib/abi.py:69: error: Incompatible return value type (got "_WrappedMethod[Never, Never, P, T | D]", expected "Callable[P, T | D | None]")  [return-value]
+ pwndbg/gdblib/abi.py:69: note: "_WrappedMethod[Never, Never, P, T | D].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ pwndbg/ida.py: note: In function "withIDA":
+ pwndbg/ida.py:143: error: Incompatible return value type (got "_WrappedMethod[Never, Never, P, T]", expected "Callable[P, T | None]")  [return-value]
+ pwndbg/ida.py:143: note: "_WrappedMethod[Never, Never, P, T].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ pwndbg/ida.py: note: In function "withHexrays":
+ pwndbg/ida.py:154: error: Incompatible return value type (got "Callable[[VarArg(Never), KwArg(Never)], Never]", expected "Callable[P, T | None]")  [return-value]
+ pwndbg/ida.py: note: In function "takes_address":
+ pwndbg/ida.py:162: error: Incompatible return value type (got "_WrappedMethod[Never, Never, [int, **P], T]", expected "Callable[[int, **P], T]")  [return-value]
+ pwndbg/ida.py:162: note: "_WrappedMethod[Never, Never, [int, **P], T].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ pwndbg/ida.py: note: In function "returns_address":
+ pwndbg/ida.py:170: error: Incompatible return value type (got "_WrappedMethod[Never, Never, P, int]", expected "Callable[P, int]")  [return-value]
+ pwndbg/ida.py:170: note: "_WrappedMethod[Never, Never, P, int].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ pwndbg/gdblib/kernel/__init__.py: note: In function "requires_kconfig":
+ pwndbg/gdblib/kernel/__init__.py:61: error: Incompatible return value type (got "_WrappedMethod[Never, Never, P, T | D]", expected "Callable[P, T | D]")  [return-value]
+ pwndbg/gdblib/kernel/__init__.py:61: note: "_WrappedMethod[Never, Never, P, T | D].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ pwndbg/gdblib/kernel/__init__.py: note: In function "requires_debug_syms":
+ pwndbg/gdblib/kernel/__init__.py:80: error: Incompatible return value type (got "_WrappedMethod[Never, Never, P, T | D]", expected "Callable[P, T | D]")  [return-value]
+ pwndbg/gdblib/kernel/__init__.py:80: note: "_WrappedMethod[Never, Never, P, T | D].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ pwndbg/glibc.py: note: In function "OnlyWhenGlibcLoaded":
+ pwndbg/glibc.py:175: error: Incompatible return value type (got "_WrappedMethod[Never, Never, P, T]", expected "Callable[P, T | None]")  [return-value]
+ pwndbg/glibc.py:175: note: "_WrappedMethod[Never, Never, P, T].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ pwndbg/commands/__init__.py: note: In function "OnlyWithFile":
+ pwndbg/commands/__init__.py:274: error: Incompatible return value type (got "_WrappedMethod[Never, Never, P, T]", expected "Callable[P, T | None]")  [return-value]
+ pwndbg/commands/__init__.py:274: note: "_WrappedMethod[Never, Never, P, T].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ pwndbg/commands/__init__.py: note: In function "OnlyWhenQemuKernel":
+ pwndbg/commands/__init__.py:288: error: Incompatible return value type (got "_WrappedMethod[Never, Never, P, T]", expected "Callable[P, T | None]")  [return-value]
+ pwndbg/commands/__init__.py:288: note: "_WrappedMethod[Never, Never, P, T].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ pwndbg/commands/__init__.py: note: In function "OnlyWhenUserspace":
+ pwndbg/commands/__init__.py:302: error: Incompatible return value type (got "_WrappedMethod[Never, Never, P, T]", expected "Callable[P, T | None]")  [return-value]
+ pwndbg/commands/__init__.py:302: note: "_WrappedMethod[Never, Never, P, T].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ pwndbg/commands/__init__.py: note: In function "OnlyWithArch":
+ pwndbg/commands/__init__.py:326: error: Incompatible return value type (got "_WrappedMethod[Never, Never, P, T]", expected "Callable[P, T | None]")  [return-value]
+ pwndbg/commands/__init__.py:326: note: "_WrappedMethod[Never, Never, P, T].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ pwndbg/commands/__init__.py: note: In function "OnlyWithKernelDebugSyms":
+ pwndbg/commands/__init__.py:342: error: Incompatible return value type (got "_WrappedMethod[Never, Never, P, T]", expected "Callable[P, T | None]")  [return-value]
+ pwndbg/commands/__init__.py:342: note: "_WrappedMethod[Never, Never, P, T].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ pwndbg/commands/__init__.py: note: In function "OnlyWhenPagingEnabled":
+ pwndbg/commands/__init__.py:354: error: Incompatible return value type (got "_WrappedMethod[Never, Never, P, T]", expected "Callable[P, T | None]")  [return-value]
+ pwndbg/commands/__init__.py:354: note: "_WrappedMethod[Never, Never, P, T].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ pwndbg/commands/__init__.py: note: In function "OnlyWhenRunning":
+ pwndbg/commands/__init__.py:366: error: Incompatible return value type (got "_WrappedMethod[Never, Never, P, T]", expected "Callable[P, T | None]")  [return-value]
+ pwndbg/commands/__init__.py:366: note: "_WrappedMethod[Never, Never, P, T].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ pwndbg/commands/__init__.py: note: In function "OnlyWithTcache":
+ pwndbg/commands/__init__.py:381: error: Incompatible return value type (got "_WrappedMethod[Never, Never, P, T]", expected "Callable[P, T | None]")  [return-value]
+ pwndbg/commands/__init__.py:381: note: "_WrappedMethod[Never, Never, P, T].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ pwndbg/commands/__init__.py: note: In function "OnlyWhenHeapIsInitialized":
+ pwndbg/commands/__init__.py:393: error: Incompatible return value type (got "_WrappedMethod[Never, Never, P, T]", expected "Callable[P, T | None]")  [return-value]
+ pwndbg/commands/__init__.py:393: note: "_WrappedMethod[Never, Never, P, T].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ pwndbg/commands/__init__.py: note: In function "OnlyWithResolvedHeapSyms":
+ pwndbg/commands/__init__.py:515: error: Incompatible return value type (got "_WrappedMethod[Never, Never, P, T]", expected "Callable[P, T | None]")  [return-value]
+ pwndbg/commands/__init__.py:515: note: "_WrappedMethod[Never, Never, P, T].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ pwndbg/wrappers/__init__.py: note: In member "__call__" of class "OnlyWithCommand":
+ pwndbg/wrappers/__init__.py:39: error: Incompatible return value type (got "Callable[[VarArg(Never), KwArg(Never)], Never]", expected "Callable[P, T | None]")  [return-value]
+ pwndbg/commands/cymbol.py: note: In function "OnlyWhenStructFileExists":
+ pwndbg/commands/cymbol.py:83: error: Incompatible return value type (got "_WrappedMethod[Never, Never, [str, str], Never]", expected "_OnlyWhenStructFileExists")  [return-value]
+ pwndbg/commands/cymbol.py:83: note: Following member(s) of "_WrappedMethod[Never, Never, [str, str], Never]" have conflicts:
+ pwndbg/commands/cymbol.py:83: note:     Expected:
+ pwndbg/commands/cymbol.py:83: note:         def [T] __call__(self, custom_structure_name: str, custom_structure_path: str = ...) -> T | None
+ pwndbg/commands/cymbol.py:83: note:     Got:
+ pwndbg/commands/cymbol.py:83: note:         def __call__(self, *args: Never, **kwargs: Never) -> Never

hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
+ src/hydra_zen/wrapper/_implementations.py:522: error: Need type annotation for "target"  [var-annotated]
- src/hydra_zen/wrapper/_implementations.py:524: error: Incompatible types in assignment (expression has type "Zen[P, R]", variable has type "_Wrapped[P, R, [Any], Any]")  [assignment]
+ src/hydra_zen/wrapper/_implementations.py:524: error: Incompatible types in assignment (expression has type "Zen[P, R]", variable has type "_WrappedMethod[Any, Any, [Any], Any]")  [assignment]

optuna (https://github.com/optuna/optuna)
+ optuna/_experimental.py:84: error: Incompatible return value type (got "_WrappedMethod[Never, Never, [VarArg(Any), KwArg(Any)], FT]", expected "Callable[FP, FT]")  [return-value]
+ optuna/_experimental.py:84: note: "_WrappedMethod[Never, Never, [VarArg(Any), KwArg(Any)], FT].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ optuna/_deprecated.py:115: error: Incompatible return value type (got "_WrappedMethod[Never, Never, [VarArg(Any), KwArg(Any)], FT]", expected "Callable[FP, FT]")  [return-value]
+ optuna/_deprecated.py:115: note: "_WrappedMethod[Never, Never, [VarArg(Any), KwArg(Any)], FT].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ optuna/_convert_positional_args.py:85: error: Incompatible return value type (got "_WrappedMethod[Never, Never, [VarArg(Any), KwArg(Any)], _T]", expected "Callable[_P, _T]")  [return-value]
+ optuna/_convert_positional_args.py:85: note: "_WrappedMethod[Never, Never, [VarArg(Any), KwArg(Any)], _T].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"

trio (https://github.com/python-trio/trio)
+ src/trio/_deprecate.py:120: error: Incompatible return value type (got "_WrappedMethod[Never, Never, ArgsT, RetT]", expected "Callable[ArgsT, RetT]")  [return-value]
+ src/trio/_deprecate.py:120: note: "_WrappedMethod[Never, Never, ArgsT, RetT].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ src/trio/_deprecate.py:140: error: Incompatible return value type (got "Callable[[VarArg(Never), KwArg(Never)], Never]", expected "Callable[ArgsT, RetT]")  [return-value]
+ src/trio/_core/_ki.py:143: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_core/_ki.py:149: error: Incompatible return value type (got "_WrappedMethod[Never, Never, ArgsT, RetT]", expected "Callable[ArgsT, RetT]")  [return-value]
+ src/trio/_core/_ki.py:149: note: "_WrappedMethod[Never, Never, ArgsT, RetT].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ src/trio/_core/_ki.py:153: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_core/_ki.py:166: error: Incompatible return value type (got "_WrappedMethod[Never, Never, ArgsT, RetT]", expected "Callable[ArgsT, RetT]")  [return-value]
+ src/trio/_core/_ki.py:166: note: "_WrappedMethod[Never, Never, ArgsT, RetT].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ src/trio/_core/_ki.py:169: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_core/_ki.py:170: error: Unused "type: ignore" comment  [unused-ignore]
+ src/trio/_core/_ki.py:176: error: Incompatible return value type (got "_WrappedMethod[Never, Never, ArgsT, RetT]", expected "Callable[ArgsT, RetT]")  [return-value]
+ src/trio/_core/_ki.py:176: note: "_WrappedMethod[Never, Never, ArgsT, RetT].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ src/trio/_core/_ki.py:184: error: Incompatible return value type (got "_WrappedMethod[Never, Never, ArgsT, RetT]", expected "Callable[ArgsT, RetT]")  [return-value]
+ src/trio/_core/_ki.py:184: note: "_WrappedMethod[Never, Never, ArgsT, RetT].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ src/trio/testing/_trio_test.py:48: error: Incompatible return value type (got "_WrappedMethod[Never, Never, ArgsT, RetT]", expected "Callable[ArgsT, RetT]")  [return-value]
+ src/trio/testing/_trio_test.py:48: note: "_WrappedMethod[Never, Never, ArgsT, RetT].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"

antidote (https://github.com/Finistere/antidote)
+ tests/core/test_thread_safety.py:71: error: Incompatible return value type (got "_WrappedMethod[Never, Never, P, T]", expected "Callable[P, T]")  [return-value]
+ tests/core/test_thread_safety.py:71: note: "_WrappedMethod[Never, Never, P, T].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"

tornado (https://github.com/tornadoweb/tornado)
- tornado/gen.py:261: error: Unused "type: ignore" comment  [unused-ignore]
+ tornado/testing.py:596: error: Need type annotation for "coro"  [var-annotated]

werkzeug (https://github.com/pallets/werkzeug)
+ src/werkzeug/wsgi.py:28: error: Incompatible return value type (got "_Wrapped[[VarArg(Any), KwArg(Any)], Callable[[dict[str, Any], StartResponse], Iterable[bytes]], [VarArg(Any)], Iterable[bytes]]", expected "Callable[[dict[str, Any], StartResponse], Iterable[bytes]]")  [return-value]
+ src/werkzeug/wsgi.py:28: note: "_Wrapped[[VarArg(Any), KwArg(Any)], Callable[[dict[str, Any], StartResponse], Iterable[bytes]], [VarArg(Any)], Iterable[bytes]].__call__" has type "Callable[[VarArg(Any)], Callable[[dict[str, Any], StartResponse], Iterable[bytes]]]"

starlette (https://github.com/encode/starlette)
+ starlette/authentication.py:66: error: Incompatible return value type (got "_WrappedMethod[Never, Never, _P, Coroutine[Any, Any, None]]", expected "Callable[_P, Any]")  [return-value]
+ starlette/authentication.py:66: note: "_WrappedMethod[Never, Never, _P, Coroutine[Any, Any, None]].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ starlette/authentication.py:83: error: Incompatible return value type (got "_WrappedMethod[Never, Never, _P, Coroutine[Any, Any, Any]]", expected "Callable[_P, Any]")  [return-value]
+ starlette/authentication.py:83: note: "_WrappedMethod[Never, Never, _P, Coroutine[Any, Any, Any]].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ starlette/authentication.py:100: error: Incompatible return value type (got "_WrappedMethod[Never, Never, _P, Any]", expected "Callable[_P, Any]")  [return-value]
+ starlette/authentication.py:100: note: "_WrappedMethod[Never, Never, _P, Any].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"

Tanjun (https://github.com/FasterSpeeding/Tanjun)
+ tanjun/_internal/__init__.py:283: error: Incompatible return value type (got "_WrappedMethod[Never, Never, _P, Coroutine[Any, Any, _T]]", expected "Callable[_P, Coroutine[Any, Any, _T]]")  [return-value]
+ tanjun/_internal/__init__.py:283: note: "_WrappedMethod[Never, Never, _P, Coroutine[Any, Any, _T]].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"

mkosi (https://github.com/systemd/mkosi)
+ mkosi/util.py:37:12: error: Incompatible return value type (got "_Wrapped[[VarArg(Any), KwArg(Any)], Iterator[tuple[T, V]], [VarArg(Any), KwArg(Any)], dict[T, V]]", expected "Callable[..., dict[T, V]]")  [return-value]
+ mkosi/util.py:37:12: note: "_Wrapped[[VarArg(Any), KwArg(Any)], Iterator[tuple[T, V]], [VarArg(Any), KwArg(Any)], dict[T, V]].__call__" has type "Callable[[VarArg(Any), KwArg(Any)], Iterator[tuple[T, V]]]"
+ mkosi/util.py:44:12: error: Incompatible return value type (got "_Wrapped[[VarArg(Any), KwArg(Any)], Iterable[T], [VarArg(Any), KwArg(Any)], list[T]]", expected "Callable[..., list[T]]")  [return-value]
+ mkosi/util.py:44:12: note: "_Wrapped[[VarArg(Any), KwArg(Any)], Iterable[T], [VarArg(Any), KwArg(Any)], list[T]].__call__" has type "Callable[[VarArg(Any), KwArg(Any)], Iterable[T]]"
+ mkosi/util.py:51:12: error: Incompatible return value type (got "_Wrapped[[VarArg(Any), KwArg(Any)], Iterable[T], [VarArg(Any), KwArg(Any)], tuple[T, ...]]", expected "Callable[..., tuple[T, ...]]")  [return-value]
+ mkosi/util.py:51:12: note: "_Wrapped[[VarArg(Any), KwArg(Any)], Iterable[T], [VarArg(Any), KwArg(Any)], tuple[T, ...]].__call__" has type "Callable[[VarArg(Any), KwArg(Any)], Iterable[T]]"

scrapy (https://github.com/scrapy/scrapy)
+ scrapy/utils/decorators.py:38: error: Incompatible return value type (got "_WrappedMethod[Never, Never, _P, Any]", expected "Callable[_P, _T]")  [return-value]
+ scrapy/utils/decorators.py:38: note: "_WrappedMethod[Never, Never, _P, Any].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ scrapy/utils/decorators.py:53: error: Incompatible return value type (got "_WrappedMethod[Never, Never, _P, Any]", expected "Callable[_P, Any]")  [return-value]
+ scrapy/utils/decorators.py:53: note: "_WrappedMethod[Never, Never, _P, Any].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ scrapy/utils/decorators.py:65: error: Incompatible return value type (got "_WrappedMethod[Never, Never, _P, Any]", expected "Callable[_P, Any]")  [return-value]
+ scrapy/utils/decorators.py:65: note: "_WrappedMethod[Never, Never, _P, Any].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ scrapy/utils/python.py:201: error: Incompatible return value type (got "_WrappedMethod[Never, Never, [_SelfT, **_P], _T]", expected "Callable[[_SelfT, **_P], _T]")  [return-value]
+ scrapy/utils/python.py:201: note: "_WrappedMethod[Never, Never, [_SelfT, **_P], _T].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ scrapy/utils/defer.py:401: error: Incompatible return value type (got "_WrappedMethod[Never, Never, _P, Any]", expected "Callable[_P, Any]")  [return-value]
+ scrapy/utils/defer.py:401: note: "_WrappedMethod[Never, Never, _P, Any].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"

black (https://github.com/psf/black)
+ src/black/linegen.py:1161:12: error: Incompatible return value type (got "_WrappedMethod[Never, Never, [Line, Collection[Feature], Mode], Iterator[Line]]", expected "Callable[[Line, Collection[Feature], Mode], Iterator[Line]]")  [return-value]
+ src/black/linegen.py:1161:12: note: "_WrappedMethod[Never, Never, [Line, Collection[Feature], Mode], Iterator[Line]].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"

ibis (https://github.com/ibis-project/ibis)
- ibis/expr/types/relations.py:3247: error: Missing positional argument "predicates" in call to "__call__" of "_Wrapped"  [call-arg]
+ ibis/expr/types/relations.py:3248: error: Argument 2 to "__call__" of "_WrappedMethod" has incompatible type "str | Sequence[Literal[True, False] | str | BooleanColumn | tuple[str | Column | Deferred, str | Column | Deferred]]"; expected Never  [arg-type]
+ ibis/expr/types/relations.py:3248: error: Argument "how" to "__call__" of "_WrappedMethod" has incompatible type "Literal['inner', 'left', 'right', 'outer', 'asof', 'semi', 'anti', 'any_inner', 'any_left', 'cross']"; expected Never  [arg-type]
+ ibis/expr/types/relations.py:3248: error: Argument "lname" to "__call__" of "_WrappedMethod" has incompatible type "str"; expected Never  [arg-type]
+ ibis/expr/types/relations.py:3248: error: Argument "rname" to "__call__" of "_WrappedMethod" has incompatible type "str"; expected Never  [arg-type]
+ ibis/expr/types/relations.py:3293: error: Argument 2 to "__call__" of "_WrappedMethod" has incompatible type "str | BooleanColumn"; expected Never  [arg-type]
+ ibis/expr/types/relations.py:3293: error: Argument 3 to "__call__" of "_WrappedMethod" has incompatible type "str | Column | Sequence[str | Column]"; expected Never  [arg-type]
+ ibis/expr/types/relations.py:3293: error: Argument "tolerance" to "__call__" of "_WrappedMethod" has incompatible type "str | IntervalScalar | None"; expected Never  [arg-type]
+ ibis/expr/types/relations.py:3293: error: Argument "lname" to "__call__" of "_WrappedMethod" has incompatible type "str"; expected Never  [arg-type]
+ ibis/expr/types/relations.py:3293: error: Argument "rname" to "__call__" of "_WrappedMethod" has incompatible type "str"; expected Never  [arg-type]
+ ibis/expr/types/relations.py:3376: error: Argument "lname" to "__call__" of "_WrappedMethod" has incompatible type "str"; expected Never  [arg-type]
+ ibis/expr/types/relations.py:3376: error: Argument "rname" to "__call__" of "_WrappedMethod" has incompatible type "str"; expected Never  [arg-type]

jax (https://github.com/google/jax)
+ jax/_src/ad_checkpoint.py:767: error: Argument 2 to "__call__" of "_WrappedMethod" has incompatible type "Callable[[VarArg(Any)], Any]"; expected Never  [arg-type]
+ jax/_src/ad_checkpoint.py:767: error: Argument 3 to "__call__" of "_WrappedMethod" has incompatible type "Callable[[VarArg(Any)], Any]"; expected Never  [arg-type]
+ jax/_src/scipy/linalg.py:1189: error: Need type annotation for "R"  [var-annotated]
+ jax/_src/scipy/linalg.py:1189: error: Argument 2 to "__call__" of "_WrappedMethod" has incompatible type "Callable[[Any], Any]"; expected Never  [arg-type]
+ jax/_src/scipy/linalg.py:1189: error: Argument 3 to "__call__" of "_WrappedMethod" has incompatible type "Callable[[Any], Any]"; expected Never  [arg-type]
+ jax/_src/scipy/linalg.py:1189: error: Argument 4 to "__call__" of "_WrappedMethod" has incompatible type "tuple[Array, Any, Any]"; expected Never  [arg-type]
+ jax/_src/scipy/special.py:2570: error: Need type annotation for "result"  [var-annotated]
+ jax/_src/scipy/special.py:2570: error: Argument 1 to "__call__" of "_WrappedMethod" has incompatible type "Array"; expected Never  [arg-type]
+ jax/_src/scipy/special.py:2570: error: Argument 2 to "__call__" of "_WrappedMethod" has incompatible type "Callable[[Any, Any, Any], Any]"; expected Never  [arg-type]
+ jax/_src/scipy/special.py:2570: error: Argument 3 to "__call__" of "_WrappedMethod" has incompatible type "Callable[[Any, Any, Any], Any]"; expected Never  [arg-type]
+ jax/_src/scipy/special.py:2570: error: Argument 4 to "__call__" of "_WrappedMethod" has incompatible type "Array"; expected Never  [arg-type]
+ jax/_src/scipy/special.py:2570: error: Argument 5 to "__call__" of "_WrappedMethod" has incompatible type "Array"; expected Never  [arg-type]
+ jax/_src/scipy/special.py:2570: error: Argument 6 to "__call__" of "_WrappedMethod" has incompatible type "Array"; expected Never  [arg-type]
+ jax/experimental/sparse/coo.py:129: error: Argument 1 to "__call__" of "_WrappedMethod" has incompatible type "bool"; expected Never  [arg-type]
+ jax/experimental/sparse/coo.py:129: error: Argument 2 to "__call__" of "_WrappedMethod" has incompatible type "Callable[[], Any]"; expected Never  [arg-type]
+ jax/experimental/sparse/coo.py:129: error: Argument 3 to "__call__" of "_WrappedMethod" has incompatible type "Callable[[], int]"; expected Never  [arg-type]
+ jax/experimental/sparse/coo.py:130: error: Argument 1 to "__call__" of "_WrappedMethod" has incompatible type "bool"; expected Never  [arg-type]
+ jax/experimental/sparse/coo.py:130: error: Argument 2 to "__call__" of "_WrappedMethod" has incompatible type "Callable[[], Any]"; expected Never  [arg-type]
+ jax/experimental/sparse/coo.py:130: error: Argument 3 to "__call__" of "_WrappedMethod" has incompatible type "Callable[[], int]"; expected Never  [arg-type]
+ jax/experimental/sparse/bcoo.py:2575: error: Argument 1 to "__call__" of "_WrappedMethod" has incompatible type "bool"; expected Never  [arg-type]
+ jax/experimental/sparse/bcoo.py:2575: error: Argument 2 to "__call__" of "_WrappedMethod" has incompatible type "Callable[[], Any]"; expected Never  [arg-type]
+ jax/experimental/sparse/bcoo.py:2575: error: Argument 3 to "__call__" of "_WrappedMethod" has incompatible type "Callable[[], int]"; expected Never  [arg-type]
+ jax/experimental/sparse/bcoo.py:2576: error: Argument 1 to "__call__" of "_WrappedMethod" has incompatible type "bool"; expected Never  [arg-type]
+ jax/experimental/sparse/bcoo.py:2576: error: Argument 2 to "__call__" of "_WrappedMethod" has incompatible type "Callable[[], Any]"; expected Never  [arg-type]
+ jax/experimental/sparse/bcoo.py:2576: error: Argument 3 to "__call__" of "_WrappedMethod" has incompatible type "Callable[[], int]"; expected Never  [arg-type]

discord.py (https://github.com/Rapptz/discord.py)
+ discord/utils.py:309: error: Incompatible return value type (got "_WrappedMethod[Never, Never, P, T]", expected "Callable[P, T]")  [return-value]
+ discord/utils.py:309: note: "_WrappedMethod[Never, Never, P, T].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ discord/ext/commands/core.py:226: error: Incompatible return value type (got "_WrappedMethod[Never, Never, P, Coroutine[Any, Any, T | None]]", expected "Callable[P, Coroutine[Any, Any, T | None]]")  [return-value]
+ discord/ext/commands/core.py:226: note: "_WrappedMethod[Never, Never, P, Coroutine[Any, Any, T | None]].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ discord/ext/commands/core.py:252: error: Incompatible return value type (got "_WrappedMethod[Never, Never, P, Coroutine[Any, Any, T | None]]", expected "Callable[P, Coroutine[Any, Any, T | None]]")  [return-value]
+ discord/ext/commands/core.py:252: note: "_WrappedMethod[Never, Never, P, Coroutine[Any, Any, T | None]].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"

schemathesis (https://github.com/schemathesis/schemathesis)
+ src/schemathesis/specs/openapi/negative/mutations.py: note: In function "for_types":
+ src/schemathesis/specs/openapi/negative/mutations.py:158: error: Incompatible return value type (got "_WrappedMethod[Never, Never, [MutationContext, Callable[[Any], Any], Dict[str, Any]], MutationResult]", expected "Callable[[MutationContext, Callable[[Any], Any], Dict[str, Any]], MutationResult]")  [return-value]
+ src/schemathesis/specs/openapi/negative/mutations.py:158: note: "_WrappedMethod[Never, Never, [MutationContext, Callable[[Any], Any], Dict[str, Any]], MutationResult].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"
+ src/schemathesis/specs/openapi/negative/mutations.py: note: At top level:

bokeh (https://github.com/bokeh/bokeh)
+ release/credentials.py: note: In function "collect_credential":
+ release/credentials.py:61:16: error: Incompatible return value type (got "_WrappedMethod[Never, Never, [Config, System], ActionReturn]", expected "Callable[[Config, System], ActionReturn]")  [return-value]
+ release/credentials.py:61:16: note: "_WrappedMethod[Never, Never, [Config, System], ActionReturn].__call__" has type "Callable[[VarArg(Never), KwArg(Never)], Never]"

streamlit (https://github.com/streamlit/streamlit)
+ lib/streamlit/runtime/fragment.py: note: In function "_fragment":
+ lib/streamlit/runtime/fragment.py:212:12: error: Incompatible return value type (got "_WrappedMethod[Never, Never, [VarArg(Any), KwArg(Any)], Any]", expected "Union[Callable[[F], F], F]")  [return-value]

@srittau
Copy link
Collaborator

srittau commented Jun 24, 2024

Unfortunately, I don't think this going to work like this. We need a solution like discussed here or in #10653 to be able to overload the function, depending on whether a function or method is passed.

@srittau srittau added the reason: inexpressible Closed, because this can't be expressed within the current type system label Jun 26, 2024
@srittau
Copy link
Collaborator

srittau commented Jun 26, 2024

I've marked this inexpressible and I'm closing it per my previous comment. Thanks for the effort! I hope we'll have a working solution for this at some point.

@srittau srittau closed this Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

reason: inexpressible Closed, because this can't be expressed within the current type system

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants