Promote inferred type to matching constraint for constrained TypeVars#2660
Promote inferred type to matching constraint for constrained TypeVars#2660yangdanny97 wants to merge 1 commit intofacebook:mainfrom
Conversation
Summary: I'm hoping we could make some progress towards addressing facebook#2419 The typing spec requires that a constrained TypeVar (`T = TypeVar("T", int, str)`) resolves to exactly one of its constraint types — never a subtype like `bool` or `Literal[42]`. For example, calling `f(True)` where `f[T: (int, str)](x: T) -> T` should yield `int`, not `bool`. Previously, the solver pinned the TypeVar to the raw argument type and validated it against the union of constraints. This meant subtypes like `bool` or user-defined subclasses like `MyStr(str)` leaked through as the resolved type, causing `assert_type` failures and spurious errors when mixing a subclass with its base in the same call (e.g., `concat(m: MyStr, s: str)` would error because `str` is not assignable to `MyStr`). The fix introduces constraint promotion in the TypeVar solving arms of the solver. When we encounter a constrained TypeVar, instead of recording the raw argument type directly, we search for the narrowest constraint the argument is assignable to and pin the TypeVar to that constraint. "Narrowest" means: among all matching constraints, pick the one that is itself a subtype of all others (e.g., for a class D inheriting from both B and C, prefer C over B if both are constraints). If no constraint matches, we report the existing specialization error. This also happens to resolve conformance failures in `generics_basic.py` (3 differences → 2; the remaining one is an unrelated `AnyStr` issue). Differential Revision: D95010963
|
@yangdanny97 has exported this pull request. If you are a Meta employee, you can view the originating Diff in D95010963. |
|
Diff from mypy_primer, showing the effect of this PR on open source code: trio (https://github.com/python-trio/trio)
+ ERROR src/trio/_file_io.py:269:35-37: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
colour (https://github.com/colour-science/colour)
+ ERROR colour/models/cie_luv.py:346:18-47: Argument `list[_NestedSequence[bytes | complex | str] | bytes | complex | ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]] | str]` is not assignable to parameter `a` with type `Buffer | _NestedSequence[bytes | complex | str] | _NestedSequence[_SupportsArray[dtype]] | _SupportsArray[dtype] | bytes | complex | str` in function `colour.utilities.array.tstack` [bad-argument-type]
+ ERROR colour/models/cie_ucs.py:245:22-86: Argument `list[_NestedSequence[bytes | complex | str] | bytes | complex | ndarray[tuple[Any, ...], dtype[float64 | floating[_16Bit] | floating[_32Bit]]] | str]` is not assignable to parameter `a` with type `Buffer | _NestedSequence[bytes | complex | str] | _NestedSequence[_SupportsArray[dtype]] | _SupportsArray[dtype] | bytes | complex | str` in function `colour.utilities.array.tstack` [bad-argument-type]
- ERROR colour/models/cie_xyy.py:284:18-47: Argument `list[_NestedSequence[bytes | complex | str] | bytes | complex | ndarray[tuple[int], dtype[float64 | floating[_16Bit] | floating[_32Bit]]] | str]` is not assignable to parameter `a` with type `Buffer | _NestedSequence[bytes | complex | str] | _NestedSequence[_SupportsArray[dtype]] | _SupportsArray[dtype] | bytes | complex | str` in function `colour.utilities.array.tstack` [bad-argument-type]
hydpy (https://github.com/hydpy-dev/hydpy)
+ ERROR hydpy/auxs/calibtools.py:3169:5-15: Overload signature `(*, rule: type[TypeRule], names: Sequence[str], parameters: Sequence[Parameter | str], values: Sequence[float], lowers: Sequence[float], uppers: Sequence[float], parametersteps: Sequence1 = None, model: ModuleType | str | None = None, selections: None = None) -> list[TypeRule]` is not consistent with implementation signature `(*, rule: type[TypeRule], calibspecs: CalibSpecs | None = None, names: Sequence[str] | None = None, parameters: Sequence[Parameter | str] | None = None, values: Sequence[float] | None = None, keywords: Sequence[str | None] | None = None, lowers: Sequence[float] | None = None, uppers: Sequence[float] | None = None, parametersteps: Sequence1 = None, model: ModuleType | str | None = None, selections: Iterable[Selection | str] | None = None, product: bool = False) -> list[TypeRule]` [inconsistent-overload]
+ ERROR hydpy/auxs/calibtools.py:3184:5-15: Overload signature `(*, rule: type[TypeRule], names: Sequence[str], parameters: Sequence[Parameter | str], values: Sequence[float], keywords: Sequence[str | None] | None = None, lowers: Sequence[float], uppers: Sequence[float], parametersteps: Sequence1 = None, model: ModuleType | str | None = None, selections: Iterable[Selection | str], product: bool = False) -> list[TypeRule]` is not consistent with implementation signature `(*, rule: type[TypeRule], calibspecs: CalibSpecs | None = None, names: Sequence[str] | None = None, parameters: Sequence[Parameter | str] | None = None, values: Sequence[float] | None = None, keywords: Sequence[str | None] | None = None, lowers: Sequence[float] | None = None, uppers: Sequence[float] | None = None, parametersteps: Sequence1 = None, model: ModuleType | str | None = None, selections: Iterable[Selection | str] | None = None, product: bool = False) -> list[TypeRule]` [inconsistent-overload]
+ ERROR hydpy/auxs/calibtools.py:3201:5-15: Overload signature `(*, rule: type[TypeRule], calibspecs: CalibSpecs, names: Sequence[str] | None = None, parameters: Sequence[Parameter | str] | None = None, values: Sequence[float] | None = None, keywords: Sequence[str | None] | None = None, lowers: Sequence[float] | None = None, uppers: Sequence[float] | None = None, model: ModuleType | str | None = None, selections: None = None) -> list[TypeRule]` is not consistent with implementation signature `(*, rule: type[TypeRule], calibspecs: CalibSpecs | None = None, names: Sequence[str] | None = None, parameters: Sequence[Parameter | str] | None = None, values: Sequence[float] | None = None, keywords: Sequence[str | None] | None = None, lowers: Sequence[float] | None = None, uppers: Sequence[float] | None = None, parametersteps: Sequence1 = None, model: ModuleType | str | None = None, selections: Iterable[Selection | str] | None = None, product: bool = False) -> list[TypeRule]` [inconsistent-overload]
+ ERROR hydpy/auxs/calibtools.py:3217:5-15: Overload signature `(*, rule: type[TypeRule], calibspecs: CalibSpecs, names: Sequence[str] | None = None, parameters: Sequence[Parameter | str] | None = None, values: Sequence[float] | None = None, keywords: Sequence[str | None] | None = None, lowers: Sequence[float] | None = None, uppers: Sequence[float] | None = None, model: ModuleType | str | None = None, selections: Iterable[Selection | str], product: bool = False) -> list[TypeRule]` is not consistent with implementation signature `(*, rule: type[TypeRule], calibspecs: CalibSpecs | None = None, names: Sequence[str] | None = None, parameters: Sequence[Parameter | str] | None = None, values: Sequence[float] | None = None, keywords: Sequence[str | None] | None = None, lowers: Sequence[float] | None = None, uppers: Sequence[float] | None = None, parametersteps: Sequence1 = None, model: ModuleType | str | None = None, selections: Iterable[Selection | str] | None = None, product: bool = False) -> list[TypeRule]` [inconsistent-overload]
- ERROR hydpy/core/devicetools.py:2574:36-46: Argument `Literal['-', '--', '-.', ':', 'dashdot', 'dashed', 'dotted', 'solid'] | tuple[LineStyle, LineStyle] | None` is not assignable to parameter `x` with type `Literal['-'] | tuple[Literal['-'] | None, Literal['-'] | None] | None` in function `_make_tuple` [bad-argument-type]
- ERROR hydpy/core/devicetools.py:2757:36-46: Argument `Literal['-', '--', '-.', ':', 'dashdot', 'dashed', 'dotted', 'solid'] | tuple[LineStyle, LineStyle] | None` is not assignable to parameter `x` with type `Literal['-'] | tuple[Literal['-'] | None, Literal['-'] | None] | None` in function `_make_tuple` [bad-argument-type]
+ ERROR hydpy/core/importtools.py:642:9-17: Overload signature `(self: SubmodelAdder[Literal[0], TM_contra, TI_contra], *, wrapped: PrepSub0D[TM_contra, TI_contra], submodelname: str, submodelinterface: type[TI_contra], methods: Iterable[(NoReturn, NoReturn) -> None], dimensionality: TD, landtype_constants: Constants | None, soiltype_constants: Constants | None, landtype_refindices: type[NameParameter] | None, soiltype_refindices: type[NameParameter] | None, refweights: type[Parameter] | None) -> None` is not consistent with implementation signature `(self: Self@SubmodelAdder, *, wrapped: PrepSub0D[TM_contra, TI_contra] | PrepSub1D[TM_contra, TI_contra], submodelname: str, submodelinterface: type[TI_contra], methods: Iterable[(NoReturn, NoReturn) -> None], dimensionality: TD, landtype_constants: Constants | None, soiltype_constants: Constants | None, landtype_refindices: type[NameParameter] | None, soiltype_refindices: type[NameParameter] | None, refweights: type[Parameter] | None) -> None` [inconsistent-overload]
+ ERROR hydpy/core/importtools.py:658:9-17: Overload signature `(self: SubmodelAdder[Literal[1], TM_contra, TI_contra], *, wrapped: PrepSub1D[TM_contra, TI_contra], submodelname: str, submodelinterface: type[TI_contra], methods: Iterable[(NoReturn, NoReturn) -> None], dimensionality: TD, landtype_constants: Constants | None, soiltype_constants: Constants | None, landtype_refindices: type[NameParameter] | None, soiltype_refindices: type[NameParameter] | None, refweights: type[Parameter] | None) -> None` is not consistent with implementation signature `(self: Self@SubmodelAdder, *, wrapped: PrepSub0D[TM_contra, TI_contra] | PrepSub1D[TM_contra, TI_contra], submodelname: str, submodelinterface: type[TI_contra], methods: Iterable[(NoReturn, NoReturn) -> None], dimensionality: TD, landtype_constants: Constants | None, soiltype_constants: Constants | None, landtype_refindices: type[NameParameter] | None, soiltype_refindices: type[NameParameter] | None, refweights: type[Parameter] | None) -> None` [inconsistent-overload]
+ ERROR hydpy/core/parametertools.py:3942:45-59: Cannot index into `float` [bad-index]
tornado (https://github.com/tornadoweb/tornado)
- ERROR tornado/options.py:657:50-64: No matching overload found for function `re.Pattern.match` called with arguments: (str, @_) [no-matching-overload]
Tanjun (https://github.com/FasterSpeeding/Tanjun)
+ ERROR tanjun/context/autocomplete.py:218:15-26: Class member `AutocompleteContext.set_choices` overrides parent class `AutocompleteContext` in an inconsistent manner [bad-override]
core (https://github.com/home-assistant/core)
+ ERROR homeassistant/components/media_source/local_source.py:147:56-65: Argument `BufferedWriter` is not assignable to parameter `fdst` with type `SupportsWrite[str]` in function `shutil.copyfileobj` [bad-argument-type]
koda-validate (https://github.com/keithasaurus/koda-validate)
+ ERROR koda_validate/generic.py:152:55-62: `ExactMatchT` is not assignable to upper bound `Decimal | UUID | bool | bytes | date | datetime | float | int | str` of type variable `ExactMatchT` [bad-specialization]
+ ERROR koda_validate/serialization/json_schema.py:328:20-42: Object of class `int` has no attribute `isoformat` [missing-attribute]
+ ERROR koda_validate/serialization/json_schema.py:349:20-42: Object of class `int` has no attribute `isoformat` [missing-attribute]
+ ERROR koda_validate/serialization/json_schema.py:378:22-42: Object of class `bool` has no attribute `isoformat` [missing-attribute]
+ ERROR koda_validate/serialization/json_schema.py:380:22-42: Object of class `bool` has no attribute `isoformat` [missing-attribute]
+ ERROR koda_validate/serialization/json_schema.py:386:22-39: Object of class `bool` has no attribute `decode` [missing-attribute]
mongo-python-driver (https://github.com/mongodb/mongo-python-driver)
+ ERROR bson/json_util.py:537:17-33: `bytes | str` is not assignable to upper bound `bytes | str` of type variable `_T` [bad-specialization]
+ ERROR bson/regex.py:83:16-49: Returned type `Regex[str]` is not assignable to declared return type `Regex[_T]` [bad-return]
+ ERROR bson/regex.py:83:21-49: `_T` is not assignable to upper bound `bytes | str` of type variable `_T` [bad-specialization]
+ ERROR bson/regex.py:133:26-52: No matching overload found for function `re.compile` called with arguments: (_T, int) [no-matching-overload]
pydantic (https://github.com/pydantic/pydantic)
+ ERROR pydantic/_internal/_validators.py:174:26-35: No matching overload found for function `re.compile` called with arguments: (PatternType) [no-matching-overload]
dd-trace-py (https://github.com/DataDog/dd-trace-py)
- ERROR ddtrace/internal/runtime/container.py:106:43-56: No matching overload found for function `re.Pattern.match` called with arguments: (str | Unknown) [no-matching-overload]
- ERROR ddtrace/internal/runtime/container.py:113:37-50: No matching overload found for function `re.Pattern.match` called with arguments: (str | Unknown) [no-matching-overload]
streamlit (https://github.com/streamlit/streamlit)
- ERROR lib/tests/streamlit/web/server/server_test_case.py:89:13-47: Argument `Literal[b'']` is not assignable to parameter `url` with type `HTTPRequest | str` in function `tornado.websocket.websocket_connect` [bad-argument-type]
cloud-init (https://github.com/canonical/cloud-init)
- ERROR cloudinit/sources/DataSourceCloudCIX.py:90:16-34: Returned type `Literal[b''] | Unknown | None` is not assignable to declared return type `str | None` [bad-return]
- ERROR cloudinit/sources/DataSourceLXD.py:356:53-63: Argument `Literal[b''] | Unknown` is not assignable to parameter `url` with type `str` in function `_get_json_response` [bad-argument-type]
- ERROR cloudinit/sources/DataSourceLXD.py:364:26-42: Argument `Literal[b''] | Unknown` is not assignable to parameter `url` with type `str` in function `_do_request` [bad-argument-type]
- ERROR cloudinit/sources/DataSourceLXD.py:406:30-38: Argument `Literal[b''] | Unknown` is not assignable to parameter `url` with type `str` in function `_do_request` [bad-argument-type]
- ERROR cloudinit/sources/DataSourceLXD.py:412:55-58: Argument `Literal[b''] | Unknown` is not assignable to parameter `url` with type `str` in function `_get_json_response` [bad-argument-type]
- ERROR cloudinit/sources/helpers/ec2.py:119:39-42: Argument `Literal['/']` is not assignable to parameter `suffix` with type `Buffer | tuple[Buffer, ...]` in function `bytes.endswith` [bad-argument-type]
- ERROR cloudinit/sources/helpers/ec2.py:120:17-33: `+=` is not supported between `Literal[b'']` and `Literal['/']` [unsupported-operation]
- ERROR cloudinit/sources/helpers/openstack.py:518:9-19: Class member `MetadataReader._path_join` overrides parent class `BaseReader` in an inconsistent manner [bad-override]
- ERROR cloudinit/url_helper.py:513:26-40: `str | Unknown` is not assignable to TypedDict key `method` with type `Literal[b''] | bool` [bad-typed-dict-key]
- ERROR cloudinit/url_helper.py:516:35-42: `tuple[Unknown, ...]` is not assignable to TypedDict key `timeout` with type `Literal[b''] | bool` [bad-typed-dict-key]
- ERROR cloudinit/url_helper.py:518:35-57: `float` is not assignable to TypedDict key `timeout` with type `Literal[b''] | bool` [bad-typed-dict-key]
- ERROR cloudinit/url_helper.py:548:31-38: `dict[Unknown, Unknown] | Unknown` is not assignable to TypedDict key `headers` with type `Literal[b''] | bool` [bad-typed-dict-key]
- ERROR cloudinit/url_helper.py:554:65-70: Object of class `bool` has no attribute `get`
+ ERROR cloudinit/url_helper.py:554:65-70: Object of class `bool` has no attribute `get` [missing-attribute]
- Object of class `bytes` has no attribute `get` [missing-attribute]
- ERROR cloudinit/url_helper.py:558:25-50: Cannot set item in `Literal[b'']` [unsupported-operation]
- ERROR cloudinit/url_helper.py:590:35-38: Argument `Literal[b'']` is not assignable to parameter `url` with type `str | None` in function `UrlError.__init__` [bad-argument-type]
- ERROR cloudinit/url_helper.py:596:21-24: Argument `Literal[b'']` is not assignable to parameter `url` with type `str | None` in function `UrlError.__init__` [bad-argument-type]
- ERROR cloudinit/url_helper.py:600:41-44: Argument `Literal[b'']` is not assignable to parameter `url` with type `str | None` in function `UrlError.__init__` [bad-argument-type]
- ERROR tests/unittests/helpers.py:160:9-163:46: Pyrefly detected conflicting types while breaking a dependency cycle: `str | Unknown` is not assignable to `LiteralString`. Adding explicit type annotations might possibly help. [bad-assignment]
- ERROR tests/unittests/helpers.py:160:9-163:46: Pyrefly detected conflicting types while breaking a dependency cycle: `str | Unknown` is not assignable to `PathLike[bytes] | bytes`. Adding explicit type annotations might possibly help. [bad-assignment]
- ERROR tests/unittests/sources/test_cloudcix.py:309:17-30: Argument `Literal[b''] | Unknown` is not assignable to parameter `base_url` with type `str` in function `cloudinit.sources.DataSourceCloudCIX.read_metadata` [bad-argument-type]
- ERROR tests/unittests/sources/test_cloudcix.py:333:17-30: Argument `Literal[b''] | Unknown` is not assignable to parameter `base_url` with type `str` in function `cloudinit.sources.DataSourceCloudCIX.read_metadata` [bad-argument-type]
discord.py (https://github.com/Rapptz/discord.py)
+ ERROR discord/app_commands/transformers.py:411:9-16: Class member `LiteralTransformer.choices` overrides parent class `IdentityTransformer` in an inconsistent manner [bad-override]
+ ERROR discord/app_commands/transformers.py:462:9-16: Class member `EnumValueTransformer.choices` overrides parent class `Transformer` in an inconsistent manner [bad-override]
+ ERROR discord/app_commands/transformers.py:489:9-16: Class member `EnumNameTransformer.choices` overrides parent class `Transformer` in an inconsistent manner [bad-override]
setuptools (https://github.com/pypa/setuptools)
+ ERROR setuptools/command/bdist_egg.py:50:37-42: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR setuptools/glob.py:34:22-53: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR setuptools/glob.py:48:16-37: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
- ERROR setuptools/glob.py:70:31-50: No matching overload found for function `glob2` called with arguments: (AnyStr, AnyStr) [no-matching-overload]
+ ERROR setuptools/glob.py:56:38-48: No matching overload found for function `posixpath.split` called with arguments: (AnyStr) [no-matching-overload]
- ERROR setuptools/glob.py:70:31-50: No matching overload found for function `glob1` called with arguments: (AnyStr, AnyStr) [no-matching-overload]
- ERROR setuptools/glob.py:82:32-51: No matching overload found for function `glob2` called with arguments: (AnyStr, AnyStr) [no-matching-overload]
+ ERROR setuptools/glob.py:82:32-51: No matching overload found for function `glob2` called with arguments: (AnyStr, Unknown) [no-matching-overload]
- ERROR setuptools/glob.py:82:32-51: No matching overload found for function `glob1` called with arguments: (AnyStr, AnyStr) [no-matching-overload]
+ ERROR setuptools/glob.py:82:32-51: No matching overload found for function `glob1` called with arguments: (AnyStr, Unknown) [no-matching-overload]
mitmproxy (https://github.com/mitmproxy/mitmproxy)
+ ERROR mitmproxy/flowfilter.py:266:40-66: No matching overload found for function `re.Pattern.search` called with arguments: (bytes) [no-matching-overload]
+ ERROR mitmproxy/flowfilter.py:268:41-68: No matching overload found for function `re.Pattern.search` called with arguments: (bytes) [no-matching-overload]
+ ERROR mitmproxy/flowfilter.py:280:40-66: No matching overload found for function `re.Pattern.search` called with arguments: (bytes) [no-matching-overload]
+ ERROR mitmproxy/flowfilter.py:291:41-68: No matching overload found for function `re.Pattern.search` called with arguments: (bytes) [no-matching-overload]
+ ERROR mitmproxy/flowfilter.py:307:34-43: No matching overload found for function `re.Pattern.search` called with arguments: (bytes) [no-matching-overload]
+ ERROR mitmproxy/flowfilter.py:313:34-43: No matching overload found for function `re.Pattern.search` called with arguments: (bytes) [no-matching-overload]
+ ERROR mitmproxy/flowfilter.py:317:67-81: No matching overload found for function `re.Pattern.search` called with arguments: (bytes) [no-matching-overload]
+ ERROR mitmproxy/flowfilter.py:324:44-69: No matching overload found for function `re.Pattern.search` called with arguments: (bytes) [no-matching-overload]
+ ERROR mitmproxy/flowfilter.py:326:45-71: No matching overload found for function `re.Pattern.search` called with arguments: (bytes) [no-matching-overload]
+ ERROR mitmproxy/flowfilter.py:343:34-43: No matching overload found for function `re.Pattern.search` called with arguments: (bytes) [no-matching-overload]
+ ERROR mitmproxy/flowfilter.py:347:59-73: No matching overload found for function `re.Pattern.search` called with arguments: (bytes) [no-matching-overload]
+ ERROR mitmproxy/flowfilter.py:354:44-69: No matching overload found for function `re.Pattern.search` called with arguments: (bytes) [no-matching-overload]
+ ERROR mitmproxy/flowfilter.py:370:34-43: No matching overload found for function `re.Pattern.search` called with arguments: (bytes) [no-matching-overload]
+ ERROR mitmproxy/flowfilter.py:374:63-77: No matching overload found for function `re.Pattern.search` called with arguments: (bytes) [no-matching-overload]
+ ERROR mitmproxy/flowfilter.py:381:45-71: No matching overload found for function `re.Pattern.search` called with arguments: (bytes) [no-matching-overload]
+ ERROR mitmproxy/net/http/url.py:147:20-28: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR test/mitmproxy/net/http/test_url.py:193:27-45: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR test/mitmproxy/net/http/test_url.py:196:31-48: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR test/mitmproxy/net/http/test_url.py:199:28-45: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
pyinstrument (https://github.com/joerick/pyinstrument)
+ ERROR pyinstrument/util.py:65:29-39: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
parso (https://github.com/davidhalter/parso)
+ ERROR parso/python/prefix.py:84:19-30: Object of class `NoneType` has no attribute `group` [missing-attribute]
+ ERROR parso/python/prefix.py:85:17-28: Object of class `NoneType` has no attribute `group` [missing-attribute]
+ ERROR parso/python/prefix.py:96:17-26: Object of class `NoneType` has no attribute `end` [missing-attribute]
aioredis (https://github.com/aio-libs/aioredis)
+ ERROR aioredis/client.py:3138:32-70: `AnyKeyT` is not assignable to upper bound `bytes | memoryview | str` of type variable `AnyKeyT` [bad-specialization]
+ ERROR aioredis/client.py:3417:32-70: `AnyKeyT` is not assignable to upper bound `bytes | memoryview | str` of type variable `AnyKeyT` [bad-specialization]
static-frame (https://github.com/static-frame/static-frame)
+ ERROR static_frame/core/index.py:582:38-57: `TVContainer_co` is not assignable to upper bound `Batch | Bus | Frame | FrameAssignILoc | FrameGO | FrameHE | Index | IndexHierarchy | MaskedArray[Any, Any] | Series | SeriesAssign | SeriesHE | TypeBlocks | Yarn | ndarray[Any, Any]` of type variable `TVContainer_co` [bad-specialization]
+ ERROR static_frame/core/index.py:603:23-27: Argument `Self@Index` is not assignable to parameter `container` with type `Frame` in function `static_frame.core.node_iter.IterNode.__init__` [bad-argument-type]
+ ERROR static_frame/core/index_hierarchy.py:1355:23-27: Argument `Self@IndexHierarchy` is not assignable to parameter `container` with type `Frame` in function `static_frame.core.node_iter.IterNode.__init__` [bad-argument-type]
+ ERROR static_frame/core/node_dt.py:140:30-144:10: `TVContainer_co` is not assignable to upper bound `Batch | Bus | Frame | FrameAssignILoc | FrameGO | FrameHE | Index | IndexHierarchy | MaskedArray[Any, Any] | Series | SeriesAssign | SeriesHE | TypeBlocks | Yarn | ndarray[Any, Any]` of type variable `TVContainer_co` [bad-specialization]
+ ERROR static_frame/core/node_iter.py:867:32-71: `TContainerAny` is not assignable to upper bound `Bus | Frame | Quilt | Series | Yarn` of type variable `TContainerAny` [bad-specialization]
+ ERROR static_frame/core/node_iter.py:873:41-80: `TContainerAny` is not assignable to upper bound `Bus | Frame | Quilt | Series | Yarn` of type variable `TContainerAny` [bad-specialization]
+ ERROR static_frame/core/node_iter.py:879:39-78: `TContainerAny` is not assignable to upper bound `Bus | Frame | Quilt | Series | Yarn` of type variable `TContainerAny` [bad-specialization]
+ ERROR static_frame/core/node_iter.py:893:37-43: `TContainerAny` is not assignable to upper bound `Bus | Frame | Quilt | Series | Yarn` of type variable `TContainerAny` [bad-specialization]
+ ERROR static_frame/core/node_iter.py:903:45-51: `TContainerAny` is not assignable to upper bound `Bus | Frame | Quilt | Series | Yarn` of type variable `TContainerAny` [bad-specialization]
+ ERROR static_frame/core/node_iter.py:913:47-53: `TContainerAny` is not assignable to upper bound `Bus | Frame | Quilt | Series | Yarn` of type variable `TContainerAny` [bad-specialization]
+ ERROR static_frame/core/node_iter.py:921:45-62: `TContainerAny` is not assignable to upper bound `Bus | Frame | Quilt | Series | Yarn` of type variable `TContainerAny` [bad-specialization]
+ ERROR static_frame/core/node_iter.py:928:45-62: `TContainerAny` is not assignable to upper bound `Bus | Frame | Quilt | Series | Yarn` of type variable `TContainerAny` [bad-specialization]
+ ERROR static_frame/core/node_iter.py:941:45-945:10: `TContainerAny` is not assignable to upper bound `Bus | Frame | Quilt | Series | Yarn` of type variable `TContainerAny` [bad-specialization]
+ ERROR static_frame/core/node_iter.py:956:37-54: `TContainerAny` is not assignable to upper bound `Bus | Frame | Quilt | Series | Yarn` of type variable `TContainerAny` [bad-specialization]
+ ERROR static_frame/core/node_iter.py:975:47-84: `TContainerAny` is not assignable to upper bound `Bus | Frame | Quilt | Series | Yarn` of type variable `TContainerAny` [bad-specialization]
+ ERROR static_frame/core/node_iter.py:1002:37-1006:10: `TContainerAny` is not assignable to upper bound `Bus | Frame | Quilt | Series | Yarn` of type variable `TContainerAny` [bad-specialization]
+ ERROR static_frame/core/node_iter.py:1033:47-1037:10: `TContainerAny` is not assignable to upper bound `Bus | Frame | Quilt | Series | Yarn` of type variable `TContainerAny` [bad-specialization]
+ ERROR static_frame/core/node_iter.py:1048:45-76: `TContainerAny` is not assignable to upper bound `Bus | Frame | Quilt | Series | Yarn` of type variable `TContainerAny` [bad-specialization]
+ ERROR static_frame/core/node_iter.py:1057:37-79: `TContainerAny` is not assignable to upper bound `Bus | Frame | Quilt | Series | Yarn` of type variable `TContainerAny` [bad-specialization]
+ ERROR static_frame/core/node_iter.py:1079:37-1092:10: `TContainerAny` is not assignable to upper bound `Bus | Frame | Quilt | Series | Yarn` of type variable `TContainerAny` [bad-specialization]
+ ERROR static_frame/core/node_iter.py:1114:47-1127:10: `TContainerAny` is not assignable to upper bound `Bus | Frame | Quilt | Series | Yarn` of type variable `TContainerAny` [bad-specialization]
+ ERROR static_frame/core/node_selector.py:452:39-56: `TVContainer_co` is not assignable to upper bound `Batch | Bus | Frame | FrameAssignILoc | FrameGO | FrameHE | Index | IndexHierarchy | MaskedArray[Any, Any] | Series | SeriesAssign | SeriesHE | TypeBlocks | Yarn | ndarray[Any, Any]` of type variable `TVContainer_co` [bad-specialization]
+ ERROR static_frame/core/node_selector.py:456:38-54: `TVContainer_co` is not assignable to upper bound `Batch | Bus | Frame | FrameAssignILoc | FrameGO | FrameHE | Index | IndexHierarchy | MaskedArray[Any, Any] | Series | SeriesAssign | SeriesHE | TypeBlocks | Yarn | ndarray[Any, Any]` of type variable `TVContainer_co` [bad-specialization]
+ ERROR static_frame/core/node_selector.py:487:32-49: `TVContainer_co` is not assignable to upper bound `Batch | Bus | Frame | FrameAssignILoc | FrameGO | FrameHE | Index | IndexHierarchy | MaskedArray[Any, Any] | Series | SeriesAssign | SeriesHE | TypeBlocks | Yarn | ndarray[Any, Any]` of type variable `TVContainer_co` [bad-specialization]
+ ERROR static_frame/core/node_selector.py:492:31-47: `TVContainer_co` is not assignable to upper bound `Batch | Bus | Frame | FrameAssignILoc | FrameGO | FrameHE | Index | IndexHierarchy | MaskedArray[Any, Any] | Series | SeriesAssign | SeriesHE | TypeBlocks | Yarn | ndarray[Any, Any]` of type variable `TVContainer_co` [bad-specialization]
+ ERROR static_frame/core/node_selector.py:526:38-55: `TVContainer_co` is not assignable to upper bound `Batch | Bus | Frame | FrameAssignILoc | FrameGO | FrameHE | Index | IndexHierarchy | MaskedArray[Any, Any] | Series | SeriesAssign | SeriesHE | TypeBlocks | Yarn | ndarray[Any, Any]` of type variable `TVContainer_co` [bad-specialization]
+ ERROR static_frame/core/node_selector.py:531:39-56: `TVContainer_co` is not assignable to upper bound `Batch | Bus | Frame | FrameAssignILoc | FrameGO | FrameHE | Index | IndexHierarchy | MaskedArray[Any, Any] | Series | SeriesAssign | SeriesHE | TypeBlocks | Yarn | ndarray[Any, Any]` of type variable `TVContainer_co` [bad-specialization]
+ ERROR static_frame/core/node_selector.py:536:38-54: `TVContainer_co` is not assignable to upper bound `Batch | Bus | Frame | FrameAssignILoc | FrameGO | FrameHE | Index | IndexHierarchy | MaskedArray[Any, Any] | Series | SeriesAssign | SeriesHE | TypeBlocks | Yarn | ndarray[Any, Any]` of type variable `TVContainer_co` [bad-specialization]
+ ERROR static_frame/core/node_selector.py:555:37-560:10: `TVContainer_co` is not assignable to upper bound `Batch | Bus | Frame | FrameAssignILoc | FrameGO | FrameHE | Index | IndexHierarchy | MaskedArray[Any, Any] | Series | SeriesAssign | SeriesHE | TypeBlocks | Yarn | ndarray[Any, Any]` of type variable `TVContainer_co` [bad-specialization]
+ ERROR static_frame/core/node_selector.py:578:40-584:10: `TVContainer_co` is not assignable to upper bound `Batch | Bus | Frame | FrameAssignILoc | FrameGO | FrameHE | Index | IndexHierarchy | MaskedArray[Any, Any] | Series | SeriesAssign | SeriesHE | TypeBlocks | Yarn | ndarray[Any, Any]` of type variable `TVContainer_co` [bad-specialization]
+ ERROR static_frame/core/node_selector.py:653:39-56: `TVContainer_co` is not assignable to upper bound `Batch | Bus | Frame | FrameAssignILoc | FrameGO | FrameHE | Index | IndexHierarchy | MaskedArray[Any, Any] | Series | SeriesAssign | SeriesHE | TypeBlocks | Yarn | ndarray[Any, Any]` of type variable `TVContainer_co` [bad-specialization]
+ ERROR static_frame/core/node_selector.py:658:38-54: `TVContainer_co` is not assignable to upper bound `Batch | Bus | Frame | FrameAssignILoc | FrameGO | FrameHE | Index | IndexHierarchy | MaskedArray[Any, Any] | Series | SeriesAssign | SeriesHE | TypeBlocks | Yarn | ndarray[Any, Any]` of type variable `TVContainer_co` [bad-specialization]
+ ERROR static_frame/core/node_values.py:79:30-84:10: `TVContainer_co` is not assignable to upper bound `Frame | Index | IndexHierarchy | Series` of type variable `TVContainer_co` [bad-specialization]
- ERROR static_frame/core/type_blocks.py:3700:9-3750:74: Pyrefly detected conflicting types while breaking a dependency cycle: `ndarray[tuple[Any, ...], dtype[numpy.bool]] | Unknown | None` is not assignable to `None`. Adding explicit type annotations might possibly help. [bad-assignment]
+ ERROR static_frame/core/util.py:1429:34-54: No matching overload found for function `numpy._core.multiarray._ConstructorEmpty.__call__` called with arguments: (tuple[int, int] | None, dtype=dtype | Any | None) [no-matching-overload]
prefect (https://github.com/PrefectHQ/prefect)
- ERROR src/prefect/cli/deploy/_core.py:94:33-81: No matching overload found for function `prefect.utilities.templating.apply_values` called with arguments: (dict[str, Any], _Environ[str], remove_notset=Literal[False]) [no-matching-overload]
+ ERROR src/prefect/cli/deploy/_core.py:94:33-81: No matching overload found for function `prefect.utilities.templating.apply_values` called with arguments: (dict[Any, Any], _Environ[str], remove_notset=Literal[False]) [no-matching-overload]
- ERROR src/prefect/cli/deploy/_core.py:376:34-44: Argument `list[dict[str, Any]] | list[Unknown] | type[NotSet] | Unknown` is not assignable to parameter `pull_steps` with type `list[dict[str, Any]]` in function `prefect.cli.deploy._storage._PullStepStorage.__init__` [bad-argument-type]
+ ERROR src/prefect/cli/deploy/_core.py:376:34-44: Argument `list[Any] | type[NotSet]` is not assignable to parameter `pull_steps` with type `list[dict[str, Any]]` in function `prefect.cli.deploy._storage._PullStepStorage.__init__` [bad-argument-type]
- ERROR src/prefect/cli/deploy/_core.py:436:28-46: Argument `list[dict[str, Any]] | list[Unknown] | type[NotSet] | Unknown | None` is not assignable to parameter `pull_steps` with type `list[dict[str, Any]] | None` in function `prefect.deployments.base._save_deployment_to_prefect_file` [bad-argument-type]
+ ERROR src/prefect/cli/deploy/_core.py:436:28-46: Argument `list[Any] | type[NotSet] | None` is not assignable to parameter `pull_steps` with type `list[dict[str, Any]] | None` in function `prefect.deployments.base._save_deployment_to_prefect_file` [bad-argument-type]
- ERROR src/prefect/deployments/steps/core.py:138:26-46: No matching overload found for function `prefect.utilities.templating.apply_values` called with arguments: (dict[str, Any] | dict[Unknown, Unknown], _Environ[str]) [no-matching-overload]
+ ERROR src/prefect/deployments/steps/core.py:138:26-46: No matching overload found for function `prefect.utilities.templating.apply_values` called with arguments: (dict[Any, Any], _Environ[str]) [no-matching-overload]
+ ERROR src/prefect/utilities/templating.py:100:5-17: Overload signature `(template: T, values: dict[str, Any], remove_notset: Literal[True] = True, warn_on_notset: bool = False, skip_prefixes: list[str] | None = None) -> T` is not consistent with implementation signature `(template: T, values: dict[str, Any], remove_notset: bool = True, warn_on_notset: bool = False, skip_prefixes: list[str] | None = None) -> T | type[NotSet]` [inconsistent-overload]
+ ERROR src/prefect/utilities/templating.py:110:5-17: Overload signature `(template: T, values: dict[str, Any], remove_notset: Literal[False] = False, warn_on_notset: bool = False, skip_prefixes: list[str] | None = None) -> T | type[NotSet]` is not consistent with implementation signature `(template: T, values: dict[str, Any], remove_notset: bool = True, warn_on_notset: bool = False, skip_prefixes: list[str] | None = None) -> T | type[NotSet]` [inconsistent-overload]
+ ERROR src/prefect/utilities/templating.py:120:5-17: Overload signature `(template: T, values: dict[str, Any], remove_notset: bool = False, warn_on_notset: bool = False, skip_prefixes: list[str] | None = None) -> T | type[NotSet]` is not consistent with implementation signature `(template: T, values: dict[str, Any], remove_notset: bool = True, warn_on_notset: bool = False, skip_prefixes: list[str] | None = None) -> T | type[NotSet]` [inconsistent-overload]
pip (https://github.com/pypa/pip)
- ERROR src/pip/_internal/network/auth.py:336:16-54: Returned type `Literal[b'']` is not assignable to declared return type `str | None` [bad-return]
jax (https://github.com/google/jax)
+ ERROR jax/_src/pallas/mosaic_gpu/primitives.py:256:35-43: Object of class `TMEMRef` has no attribute `type` [missing-attribute]
+ ERROR jax/_src/pallas/mosaic_gpu/primitives.py:559:26-34: Object of class `TMEMRef` has no attribute `type` [missing-attribute]
+ ERROR jax/_src/pallas/mosaic_gpu/primitives.py:1279:34-40: Object of class `TMEMRef` has no attribute `type` [missing-attribute]
+ ERROR jax/_src/pallas/mosaic_gpu/primitives.py:1338:34-40: Object of class `TMEMRef` has no attribute `type` [missing-attribute]
materialize (https://github.com/MaterializeInc/materialize)
+ ERROR misc/python/materialize/feature_benchmark/report.py:39:25-41: `float` is not assignable to attribute `mean` with type `T | None` [bad-assignment]
kopf (https://github.com/nolar/kopf)
- ERROR kopf/_cogs/structs/references.py:87:51-59: Argument `str` is not assignable to parameter `pat` with type `NamespaceName` in function `fnmatch.fnmatch` [bad-argument-type]
- ERROR kopf/_cogs/structs/references.py:90:61-77: Argument `str` is not assignable to parameter `pat` with type `NamespaceName` in function `fnmatch.fnmatch` [bad-argument-type]
- ERROR kopf/_cogs/structs/references.py:92:73-77: Argument `str` is not assignable to parameter `pat` with type `NamespaceName` in function `fnmatch.fnmatch` [bad-argument-type]
schema_salad (https://github.com/common-workflow-language/schema_salad)
+ ERROR schema_salad/sourceline.py:17:29-40: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR schema_salad/sourceline.py:20:29-40: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
anyio (https://github.com/agronholm/anyio)
+ ERROR src/anyio/_core/_fileio.py:201:21-27: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR src/anyio/_core/_tempfile.py:108:37-41: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR src/anyio/_core/_tempfile.py:208:37-41: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
cibuildwheel (https://github.com/pypa/cibuildwheel)
+ ERROR cibuildwheel/logger.py:409:29-39: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
scrapy (https://github.com/scrapy/scrapy)
+ ERROR scrapy/http/headers.py:32:25-30: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR scrapy/http/headers.py:70:9-20: Class member `Headers.__getitem__` overrides parent class `CaselessDict` in an inconsistent manner [bad-override]
+ ERROR scrapy/http/headers.py:72:59-64: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR scrapy/http/headers.py:76:9-12: Class member `Headers.get` overrides parent class `CaselessDict` in an inconsistent manner [bad-override]
+ ERROR scrapy/http/headers.py:78:51-65: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR scrapy/http/headers.py:84:59-64: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR scrapy/http/headers.py:91:9-18: Cannot set item in `Self@Headers` [unsupported-operation]
+ ERROR scrapy/http/headers.py:96:31-50: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR scrapy/http/headers.py:99:27-32: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR scrapy/http/headers.py:101:9-18: Cannot set item in `Self@Headers` [unsupported-operation]
+ ERROR scrapy/http/request/__init__.py:205:20-48: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR scrapy/http/request/__init__.py:320:36-67: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR scrapy/http/response/__init__.py:71:40-55: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR scrapy/http/response/__init__.py:217:23-231:10: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR scrapy/http/response/__init__.py:262:24-276:14: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR scrapy/http/response/text.py:161:9-15: Class member `TextResponse.follow` overrides parent class `Response` in an inconsistent manner [bad-override]
+ ERROR scrapy/http/response/text.py:198:30-212:10: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR scrapy/http/response/text.py:214:9-19: Class member `TextResponse.follow_all` overrides parent class `Response` in an inconsistent manner [bad-override]
+ ERROR scrapy/http/response/text.py:271:34-285:10: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR scrapy/utils/datatypes.py:53:24-29: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR scrapy/utils/datatypes.py:56:52-55: Argument `AnyStr` is not assignable to parameter `key` with type `str` in function `CaselessDict.normkey` [bad-argument-type]
+ ERROR scrapy/utils/datatypes.py:59:45-48: Argument `AnyStr` is not assignable to parameter `key` with type `str` in function `CaselessDict.normkey` [bad-argument-type]
+ ERROR scrapy/utils/datatypes.py:62:45-48: Argument `AnyStr` is not assignable to parameter `key` with type `str` in function `CaselessDict.normkey` [bad-argument-type]
+ ERROR scrapy/utils/datatypes.py:65:52-57: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR scrapy/utils/datatypes.py:83:43-48: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR scrapy/utils/datatypes.py:86:50-55: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR scrapy/utils/datatypes.py:99:43-48: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR scrapy/utils/datatypes.py:112:39-44: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR scrapy/utils/datatypes.py:116:39-44: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR scrapy/utils/datatypes.py:126:39-44: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
+ ERROR scrapy/utils/datatypes.py:131:39-44: `AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
- ERROR tests/test_proxy_connect.py:95:37-82: Cannot set item in `_Environ[str]` [unsupported-operation]
pwndbg (https://github.com/pwndbg/pwndbg)
+ ERROR pwndbg/commands/got_tracking.py:159:24-33: No matching overload found for function `re.Pattern.match` called with arguments: (str | Unknown | None) [no-matching-overload]
meson (https://github.com/mesonbuild/meson)
+ ERROR mesonbuild/cargo/builder.py:33:29-78: `TV_TokenTypes` is not assignable to upper bound `bool | int | str` of type variable `TV_TokenTypes` [bad-specialization]
+ ERROR mesonbuild/cmake/interpreter.py:1013:70-73: Argument `BaseNode | Path | bool | int | str` is not assignable to parameter `value` with type `bool` in function `mesonbuild.mparser.Token.__init__` [bad-argument-type]
- ERROR mesonbuild/mparser.py:175:35-51: No matching overload found for function `re.Pattern.match` called with arguments: (str, @_) [no-matching-overload]
+ ERROR mesonbuild/mparser.py:231:83-88: Argument `str` is not assignable to parameter `value` with type `bool` in function `Token.__init__` [bad-argument-type]
+ ERROR mesonbuild/mparser.py:725:65-69: Argument `None` is not assignable to parameter `value` with type `bool` in function `Token.__init__` [bad-argument-type]
+ ERROR mesonbuild/mparser.py:751:173-177: Argument `None` is not assignable to parameter `value` with type `bool` in function `Token.__init__` [bad-argument-type]
+ ERROR mesonbuild/mparser.py:860:17-32: `int` is not assignable to attribute `value` with type `bool` [bad-assignment]
altair (https://github.com/vega/altair)
- WARN altair/utils/schemapi.py:1133:24-84: Redundant cast: `Self@SchemaBase` is the same type as `Self@SchemaBase` [redundant-cast]
+ ERROR altair/vegalite/v6/api.py:1015:37-58: No matching overload found for function `_Conditional.__init__` called with arguments: (condition=_ConditionExtra) [no-matching-overload]
+ ERROR altair/vegalite/v6/api.py:1097:42-64: No matching overload found for function `_Conditional.__init__` called with arguments: (condition=_ConditionClosed) [no-matching-overload]
+ ERROR altair/vegalite/v6/api.py:1200:28-61: `_C` is not assignable to upper bound `list[_ConditionClosed] | _ConditionExtra` of type variable `_C` [bad-specialization]
+ ERROR altair/vegalite/v6/api.py:1203:39-82: `_C` is not assignable to upper bound `list[_ConditionClosed] | _ConditionExtra` of type variable `_C` [bad-specialization]
|
Primer Diff Classification❌ 9 regression(s) | ✅ 22 improvement(s) | 31 project(s) total 9 regression(s) across trio, colour, hydpy, core, pydantic, materialize, schema_salad, cibuildwheel, pwndbg. error kinds:
Detailed analysis❌ Regression (9)trio (+1)
colour (+2, -1)
hydpy (+7, -2)
core (+1)
pydantic (+1)
materialize (+1)
The issue is that pyrefly is treating this bounded TypeVar like a constrained TypeVar and trying to promote the float return type. But T is bounded by The constraint promotion logic should only apply to constrained TypeVars (created with
schema_salad (+2)
cibuildwheel (+1)
pwndbg (+1)
✅ Improvement (22)tornado (-1)
Tanjun (+1)
koda-validate (+6)
mongo-python-driver (+4)
dd-trace-py (-2)
streamlit (-1)
cloud-init (+1, -19)
discord.py (+3)
setuptools (+5, -2)
mitmproxy (+19)
pyinstrument (+1)
parso (+3)
aioredis (+2)
static-frame (+34, -1)
prefect (+7, -4)
pip (-1)
jax (+4)
kopf (-3)
anyio (+3)
The issue appears to be that
scrapy (+31, -1)
meson (+6, -1)
altair (+4, -1)
Suggested FixSummary: The PR implements constraint promotion for TypeVars per the typing spec, causing 9 regressions where the new logic is too strict for valid code patterns. 1. In
2. In the Variable::Quantified and Variable::PartialQuantified branches in
3. In
4. In
Was this helpful? React with 👍 or 👎 Classification by primer-classifier (31 LLM) |
stroxler
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
Summary:
I'm hoping we could make some progress towards addressing #2419
The typing spec requires that a constrained TypeVar (
T = TypeVar("T", int, str)) resolves to exactly one of its constraint types — never a subtype likeboolorLiteral[42]. For example, callingf(True)wheref[T: (int, str)](x: T) -> Tshould yieldint, notbool.Previously, the solver pinned the TypeVar to the raw argument type and validated it against the union of constraints. This meant subtypes like
boolor user-defined subclasses likeMyStr(str)leaked through as the resolved type, causingassert_typefailures and spurious errors when mixing a subclass with its base in the same call (e.g.,concat(m: MyStr, s: str)would error becausestris not assignable toMyStr).The fix introduces constraint promotion in the TypeVar solving arms of the solver. When we encounter a constrained TypeVar, instead of recording the raw argument type directly, we search for the narrowest constraint the argument is assignable to and pin the TypeVar to that constraint. "Narrowest" means: among all matching constraints, pick the one that is itself a subtype of all others (e.g., for a class D inheriting from both B and C, prefer C over B if both are constraints). If no constraint matches, we report the existing specialization error.
This also happens to resolve conformance failures in
generics_basic.py(3 differences → 2; the remaining one is an unrelatedAnyStrissue).Differential Revision: D95010963