support modules as parameters in generic functions
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
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:
- Are you reporting a bug, or opening a feature request?
I think this is a bug (the behaviour is consistent with other kind of objects)
- Please insert below the code you are checking with mypy,
or a mock-up repro if the source is private. We would appreciate
if you try to simplify your case to a minimal repro.
import typing
T = typing.TypeVar('T')
def same(obj: T) -> T:
return obj
add = same(3).__add__
TypeVar = same(typing).TypeVar
- What is the actual behavior/output?
minimal.py:6: error: Module has no attribute "TypeVar"
- What is the behavior/output you expect?
[no errors]
- What are the versions of mypy and Python you are using?
Do you see the same issue after installing mypy from Git master?
0.650
- What are the mypy flags you are using? (For example --strict-optional)
[mypy]
disallow_untyped_defs = True
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the minimal.py example with the reported mypy configuration and confirm the Module has no attribute "TypeVar" error. No source file or test is named in the issue; trace how generic function results are handled when the argument is a module, then add coverage showing the expected no-error behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100