Skip to content

pathlib.Path property access is considered a Callable #2481

@thomascellerier

Description

@thomascellerier

Using mypy 0.4.6.

repro.py:

import pathlib

file_dir = pathlib.Path(__file__).parent

def some_file() -> pathlib.Path:
    return file_dir / 'foo.txt'

if __name__ == '__main__':
     print(str(some_file()))

output:

$ python3 repro.py 
foo.txt
$ mypy repro.py 
repro.py: note: In function "some_file":
repro.py:8: error: Unsupported left operand type for / (Callable[[], Path])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions