Consider this simple snippet:
# mod.py
import inspect
import pathlib
inspect.getmodulename(pathlib.PurePosixPath('foo.py'))
Run it with Python 3.8 or later and it runs fine (I don't have Python 3.7 due to ARM).
Check it with mypy and it fails:
draft $ mypy mod.py
mod.py:4: error: Argument 1 to "getmodulename" has incompatible type "PurePosixPath"; expected "str" [arg-type]
Found 1 error in 1 file (checked 1 source file)
Indeed the definition indicates that only str is allowed for input.
The implementation passes the input through to os.path.basename, which accepts pathlib.Path. Probably the typeshed should reflect this behavior, especially considering that the docs suggest that the input is a "path".
Consider this simple snippet:
Run it with Python 3.8 or later and it runs fine (I don't have Python 3.7 due to ARM).
Check it with mypy and it fails:
Indeed the definition indicates that only
stris allowed for input.The implementation passes the input through to
os.path.basename, which acceptspathlib.Path. Probably the typeshed should reflect this behavior, especially considering that the docs suggest that the input is a "path".