Odd error message when kwargs passed as **dict
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Checking this with mypy 0.620:
from concurrent.futures import ThreadPoolExecutor
import sys
opts = {'max_workers': None}
if sys.version_info >= (3, 6):
opts['thread_name_prefix'] = 'SyncWorker'
executor = ThreadPoolExecutor(**opts)
...yields:
mypy_bug.py:6: error: Incompatible types in assignment (expression has type "str", target has type "None")
mypy_bug.py:7: error: Argument 1 to "ThreadPoolExecutor" has incompatible type "**Dict[str, None]"; expected "str"
Let's ignore the first error for now. But the second seems to have an incorrect message, specifically I think the **Dict[str, None] in it is weird. Just guessing, is it trying to assign something to the ThreadPoolExecutor's thread_name_prefix arg which is a str? Maybe the None from max_workers because passing kwargs as a dict like this might result in random/varying order of the dict items? But if that's the case, I'd expect it to say something else than **Dict[str, None] as the culprit, maybe None or int, but not the whole **dict.
Another thought is that when kwargs is passed as **dicts like this, their order is not really defined, so "Argument 1" isn't very helpful. Would be better to say the argument's name.
But maybe I'm just all off track here -- will leave the rest to someone who actually has an informed opinion :)
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem ThreadPoolExecutor-Reproduzierer im Issue und führe ihn mit mypy 0.620 aus, um die gemeldeten Diagnosen für **opts zu untersuchen. Untersuche die Verarbeitung von Schlüsselwortargumenten auf Basis von Dictionaries und bestimme, was der Fehler identifizieren sollte; abgeschlossen ist die Aufgabe, wenn die Diagnose korrekt ist und das relevante Argument oder den relevanten Wert nennt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- devtools
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100