support modules as parameters in generic functions
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 20.6k
- Fork
- 3.3k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Iniziare eseguendo l'esempio minimal.py con la configurazione mypy segnalata e verificare che non si verifichi l'errore «Module has no attribute "TypeVar"». Nell'issue non sono indicati né un file sorgente né un test; tracciare come vengono gestiti i risultati delle funzioni generiche quando l'argomento è un modulo, quindi aggiungere una copertura che mostri il comportamento previsto senza errori.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100