False positive Argument 2 to "get" of "Message" has incompatible type "str"; expected "bool"
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Inizia con il repro Python minimo e la firma mostrata di Message.get in typeshed, usando mypy 0.711, Python 3.6.7 e i flag di mypy elencati. Confronta i due falsi positivi segnalati con il comportamento atteso senza errori, quindi traccia il percorso del controllo dei tipi che gestisce la chiamata a get e l’espressione booleana.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Note: I wasn't sure what a proper title was for this issue, so I chose one that is specific to the issue at hand. I checked typeshed, it looks like the issue is about mypy, not typeshed. I wouldn't be surprised if an issue already existed for this false positive.
Minimal repro:
assert isinstance(email, EmailMessage)
# Fine
r1 = email.get("List-Id", "")
# Fine
r2 = email.get("List-Id", "") or email.get("List-Unsubscribe", "")
# Fine
r3 = bool(email.get("List-Id", "") or email.get("List-Unsubscribe", ""))
# FAILS: Argument 2 to "get" of "Message" has incompatible type "str"; expected "bool"
r4 = bool(
email.get("Auto-Submitted", "") in ("no", "")
or email.get("List-Unsubscribe", "")
)
# FAILS: Argument 2 to "get" of "Message" has incompatible type "str"; expected "bool"
r5 = email.get("Auto-Submitted", "") in ("no", "") or email.get(
"List-Unsubscribe", ""
)
Both are false positives.
Typeshed:
_T = TypeVar('_T')
class Message:
...
def get(self, name: str, failobj: _T = ...) -> Union[_HeaderType, _T]: ...
-
What is the actual behavior/output?
Argument 2 to "get" of "Message" has incompatible type "str"; expected "bool" -
What is the behavior/output you expect? No error.
-
What are the versions of mypy and Python you are using? mypy 0.711, Python 3.6.7
Do you see the same issue after installing mypy from Git master? haven't tried it but since 0.711 is fairly recent... -
What are the mypy flags you are using? (For example --strict-optional)
[mypy]
ignore_missing_imports = True
follow_imports = skip
check_untyped_defs = False
strict_equality = True
disallow_incomplete_defs = True
- Lingua principale
- Python
- Stelle
- 20.6k
- Fork
- 3.3k
- Merge medio
- 1g 18h
- PR unite (30g)
- 54
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.
Altre issue di python/mypy
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
bug topic-configuration topic-error-reporting
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Issue simili
-
🐛 Bug 🔔 Pending processing
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
jumpserver/jumpserver#17584 ·
-
link-check link-check:sphinx-theme
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
OpenHands/extensions#626 · 1 commento ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
CSCfi/sd-search-api#39 ·