Skip to content

map(os.path.basename, ...): Argument 1 to "map" has incompatible type overloaded function; expected "Callable[[str], AnyStr]" #9864

Closed
@jdufresne

Description

@jdufresne
$ python --version
Python 3.9.1
$ mypy --version
mypy 0.790

Minimal code example:

import os

filenames = map(os.path.basename, ["hello/world.txt"])

Actual result:

$ mypy ~/test.py
/home/jon/test.py:3: error: Argument 1 to "map" has incompatible type overloaded function; expected "Callable[[str], AnyStr]"
Found 1 error in 1 file (checked 1 source file)

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 or map or something else?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions