Binder should reason about complex expressions
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
Direzione di ricerca
Start by reproducing the reported example with mypy and read the Binder's handling of type narrowing for indexed and chained expressions. The issue's requested behavior is complete when the guard on a[i] narrows the later a[i] expression enough to remove the Optional[str] error, with coverage for the example and the mentioned p[i].arg case.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Here's a very simple example:
from typing import *
a = ['x', None] # type: List[Optional[str]]
for i in range(len(a)):
if a[i]:
print(i, '<' + a[i] + '>')
We get an error on the last line:
__tmp__.py:5: error: Unsupported operand types for + ("str" and "Optional[str]")
Of course I can refactor this by using
for i in range(len(a)):
ai = a[i]
if ai:
print(i, '<' + ai + '>')
but that's just busy-work and doesn't necessarily make the code more readable.
(I found this in some mypy test code where the actual expression was p[i].arg so this probably needs to become fairly powerful.)
- 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
-
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 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100