-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
map(os.path.basename, ...): Argument 1 to "map" has incompatible type overloaded function; expected "Callable[[str], AnyStr]" #9864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is a reduced version of the example above that shows the problem without involving typeshed types (or overloads): from typing import Callable, List, TypeVar
_B = TypeVar("_B")
_T = TypeVar("_T")
_S = TypeVar("_S")
def bar(x: _B) -> _B:
return x
def foo(func: Callable[[_T], _S], y: _T) -> _S:
return func(y)
foo(bar, "") # <-- error This results in:
I believe this is a mypy problem. Could a mypy maintainer move this issue? In typeshed we could probably work around the problem by adding additional overloads for |
Possibly related: #3644. |
Also possibly related: #5738 (comment) |
Similar to #2389, but I'm not sure that it's a dupe. |
This now typechecks correctly. |
Minimal code example:
Actual result:
Expected: No error. This seems like an acceptable use of
os.path.basename
.I'm happy to lend a hand to resolve this issue, but it is not clear to me how to fix it. Is this an issue with
os.path.basename
ormap
or something else?The text was updated successfully, but these errors were encountered: