fix False positive: incompatible default value error on TypeVar-typed parameter when default satisfies Literal bound #3418#3419
Conversation
|
Diff from mypy_primer, showing the effect of this PR on open source code: pwndbg (https://github.com/pwndbg/pwndbg)
- ERROR pwndbg/aglib/kernel/__init__.py:69:50-54: Default `None` is not assignable to parameter `default` with type `D` [bad-function-definition]
- ERROR pwndbg/aglib/kernel/__init__.py:91:38-42: Default `None` is not assignable to parameter `default` with type `D` [bad-function-definition]
- ERROR pwndbg/decorators.py:46:19-23: Default `None` is not assignable to parameter `fallback` with type `K` [bad-function-definition]
steam.py (https://github.com/Gobot1234/steam.py)
- ERROR steam/app.py:101:23-27: Default `None` is not assignable to parameter `name` with type `NameT` [bad-function-definition]
- ERROR steam/app.py:646:78-82: Default `None` is not assignable to parameter `name` with type `NameT` [bad-function-definition]
- ERROR steam/bundle.py:36:54-58: Default `None` is not assignable to parameter `name` with type `NameT` [bad-function-definition]
- ERROR steam/clan.py:211:30-45: Default `int` is not assignable to parameter `type` with type `BoringEventT` [bad-function-definition]
- ERROR steam/package.py:55:54-58: Default `None` is not assignable to parameter `name` with type `NameT` [bad-function-definition]
- ERROR steam/package.py:75:75-79: Default `None` is not assignable to parameter `name` with type `NameT` [bad-function-definition]
- ERROR steam/tag.py:35:72-76: Default `None` is not assignable to parameter `name` with type `NameT` [bad-function-definition]
- ERROR steam/tag.py:77:72-76: Default `None` is not assignable to parameter `name` with type `NameT` [bad-function-definition]
- ERROR steam/tag.py:99:72-76: Default `None` is not assignable to parameter `name` with type `NameT` [bad-function-definition]
mypy (https://github.com/python/mypy)
- ERROR mypyc/test-data/fixtures/ir.py:302:45-48: Default `Ellipsis` is not assignable to parameter `val` with type `_V` [bad-function-definition]
artigraph (https://github.com/artigraph/artigraph)
- ERROR src/arti/internal/models.py:203:54-71: Default `PydanticUndefinedType` is not assignable to parameter `fallback` with type `T` [bad-function-definition]
- ERROR src/arti/internal/type_hints.py:119:78-82: Default `None` is not assignable to parameter `default` with type `D` [bad-function-definition]
- ERROR src/arti/internal/type_hints.py:125:79-83: Default `None` is not assignable to parameter `default` with type `D` [bad-function-definition]
- ERROR src/arti/internal/type_hints.py:130:88-92: Default `None` is not assignable to parameter `default` with type `D` [bad-function-definition]
- ERROR src/arti/internal/utils.py:213:63-67: Default `None` is not assignable to parameter `default` with type `D` [bad-function-definition]
|
Primer Diff Classification✅ 4 improvement(s) | 4 project(s) total | -18 errors 4 improvement(s) across pwndbg, steam.py, mypy, artigraph.
Detailed analysis✅ Improvement (4)pwndbg (-3)
steam.py (-9)
mypy (-1)
artigraph (-5)
Was this helpful? React with 👍 or 👎 Classification by primer-classifier (4 LLM) |
Summary
Fixes #3418
a bare TypeVar parameter default is checked against the TypeVar’s bound instead of against the unresolved quantified type itself.
Test Plan
add test