python / mypy

Optional static typing for Python
https://www.mypy-lang.org/
Other
18.56k stars 2.84k forks source link

special support for types from importlib.import_module and pkgutil.resolve_name with Literal arguments #9356

Open graingert opened 4 years ago

graingert commented 4 years ago

Note: if you are reporting a wrong signature of a function or a class in the standard library, then the typeshed tracker is better suited for this report: https://github.com/python/typeshed/issues

Please provide more information to help us understand the issue:

def get_mock_module(v: Literal["mock"] | Literal["unittest.mock"]) -> ...:
     return pkgutils.resolve_name(v)

I think https://github.com/python/mypy/issues/5059 was closed because it was opened as a bug rather than a feature request

graingert commented 4 years ago

this will also require passing around Module types