-
Notifications
You must be signed in to change notification settings - Fork 259
Fix isinstance narrowing for unions with supertype members (#2169) #2222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
|
wip |
|
thanks, the mypy primer diff looks promising, lmk when you want a review on this |
|
@jackulau FYI you can convert the PR to a draft to indicate that it's in-progress and back to non-draft when it's ready for review: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-stage-of-a-pull-request. |
Added additional edge case tests for: - Subclass in union (dict with Mapping check) - Collection/Mapping hierarchy - Unrelated classes (Sequence/Mapping) - Superclass as isinstance target
|
Diff from mypy_primer, showing the effect of this PR on open source code: scrapy (https://github.com/scrapy/scrapy)
- ERROR scrapy/http/headers.py:37:15-63: `ItemsView[tuple[AnyStr, Any], Unknown] | ItemsView[AnyStr, Any] | Iterable[tuple[AnyStr, Any]]` is not assignable to variable `seq` with type `Iterable[tuple[AnyStr, Any]] | Mapping[AnyStr, Any]` [bad-assignment]
- ERROR scrapy/http/headers.py:40:41-44: `int | str | AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
- ERROR scrapy/utils/datatypes.py:90:15-63: `ItemsView[tuple[AnyStr, Any], Unknown] | ItemsView[AnyStr, Any] | Iterable[tuple[AnyStr, Any]]` is not assignable to variable `seq` with type `Iterable[tuple[AnyStr, Any]] | Mapping[AnyStr, Any]` [bad-assignment]
- ERROR scrapy/utils/datatypes.py:91:30-33: `int | str | AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr` [bad-specialization]
- ::error file=scrapy/http/headers.py,line=37,col=15,endLine=37,endColumn=63,title=Pyrefly bad-assignment::`ItemsView[tuple[AnyStr, Any], Unknown] | ItemsView[AnyStr, Any] | Iterable[tuple[AnyStr, Any]]` is not assignable to variable `seq` with type `Iterable[tuple[AnyStr, Any]] | Mapping[AnyStr, Any]`
- ::error file=scrapy/http/headers.py,line=40,col=41,endLine=40,endColumn=44,title=Pyrefly bad-specialization::`int | str | AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr`
- ::error file=scrapy/utils/datatypes.py,line=90,col=15,endLine=90,endColumn=63,title=Pyrefly bad-assignment::`ItemsView[tuple[AnyStr, Any], Unknown] | ItemsView[AnyStr, Any] | Iterable[tuple[AnyStr, Any]]` is not assignable to variable `seq` with type `Iterable[tuple[AnyStr, Any]] | Mapping[AnyStr, Any]`
- ::error file=scrapy/utils/datatypes.py,line=91,col=30,endLine=91,endColumn=33,title=Pyrefly bad-specialization::`int | str | AnyStr` is not assignable to upper bound `bytes | str` of type variable `AnyStr`
urllib3 (https://github.com/urllib3/urllib3)
- ERROR src/urllib3/_collections.py:357:26-29: Argument `str | tuple[str, str]` is not assignable to parameter `key` with type `str` in function `HTTPHeaderDict.add` [bad-argument-type]
- ::error file=src/urllib3/_collections.py,line=357,col=26,endLine=357,endColumn=29,title=Pyrefly bad-argument-type::Argument `str | tuple[str, str]` is not assignable to parameter `key` with type `str` in function `HTTPHeaderDict.add`
hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
- ERROR src/hydra_zen/structured_configs/_implementations.py:1205:30-1215:14: No matching overload found for function `BuildsFn.builds` called with arguments: (type[Zen], (...) -> Unknown, exclude=list[str], pre_call=Just[(Any) -> Any] | list[Just[(Any) -> Any]] | None, unpack_kwargs=bool, resolve_pre_call=bool, run_in_context=bool, instantiation_wrapper=((Unknown) -> Unknown) | None, populate_full_signature=Literal[True]) [no-matching-overload]
+ ERROR src/hydra_zen/structured_configs/_implementations.py:1205:30-1215:14: No matching overload found for function `BuildsFn.builds` called with arguments: (type, Never, exclude=list[@_], pre_call=list[Never] | None, unpack_kwargs=Never, resolve_pre_call=Never, run_in_context=Never, instantiation_wrapper=Never, populate_full_signature=Literal[True]) [no-matching-overload]
- ::error file=src/hydra_zen/structured_configs/_implementations.py,line=1205,col=30,endLine=1215,endColumn=14,title=Pyrefly no-matching-overload::No matching overload found for function `BuildsFn.builds` called with arguments: (type[Zen], (...) -> Unknown, exclude=list[str], pre_call=Just[(Any) -> Any] | list[Just[(Any) -> Any]] | None, unpack_kwargs=bool, resolve_pre_call=bool, run_in_context=bool, instantiation_wrapper=((Unknown) -> Unknown) | None, populate_full_signature=Literal[True])%0A Possible overloads:%0A (__hydra_target: type[BuildsWithSig[type[R], P]], *, zen_partial: Literal[False] | None = ..., populate_full_signature: Literal[True], zen_wrappers: ZenWrappers = ..., zen_meta: Mapping[str, SupportedPrimitive] | None = ..., hydra_recursive: bool | None = ..., hydra_convert: Literal['all', 'none', 'object', 'partial'] | None = ..., hydra_defaults: list[DataClass_ | Mapping[str, Sequence[str] | str | None] | str | type[DataClass_]] | None = ..., dataclass_name: str | None = ..., builds_bases: tuple[()] = ..., zen_dataclass: DataclassOptions | None = None, frozen: bool = ..., zen_convert: ZenConvert | None = ...) -> type[BuildsWithSig[type[R], P]]%0A (__hydra_target: (ParamSpec(P)) -> R, *, zen_partial: Literal[False] | None = ..., populate_full_signature: Literal[True], zen_wrappers: ZenWrappers = ..., zen_meta: Mapping[str, SupportedPrimitive] | None = ..., hydra_recursive: bool | None = ..., hydra_convert: Literal['all', 'none', 'object', 'partial'] | None = ..., hydra_defaults: list[DataClass_ | Mapping[str, Sequence[str] | str | None] | str | type[DataClass_]] | None = ..., dataclass_name: str | None = ..., builds_bases: tuple[()] = ..., zen_dataclass: DataclassOptions | None = None, frozen: bool = ..., zen_convert: ZenConvert | None = ...) -> type[BuildsWithSig[type[R], P]]%0A (__hydra_target: type[AnyBuilds], *pos_args: T, *, zen_partial: Literal[False] | None = ..., populate_full_signature: bool = ..., zen_wrappers: ZenWrappers = ..., zen_meta: Mapping[str, SupportedPrimitive] | None = ..., hydra_recursive: bool | None = ..., hydra_convert: Literal['all', 'none', 'object', 'partial'] | None = ..., hydra_defaults: list[DataClass_ | Mapping[str, Sequence[str] | str | None] | str | type[DataClass_]] | None = ..., dataclass_name: str | None = ..., builds_bases: tuple[type[DataClass_], ...] = ..., zen_dataclass: DataclassOptions | None = None, frozen: bool = ..., zen_convert: ZenConvert | None = ..., **kwargs_for_target: T) -> type[Builds[Importable]]%0A (__hydra_target: Importable, *pos_args: T, *, zen_partial: Literal[False] | None = ..., populate_full_signature: bool = ..., zen_wrappers: ZenWrappers = ..., zen_meta: Mapping[str, SupportedPrimitive] | None = ..., hydra_recursive: bool | None = ..., hydra_convert: Literal['all', 'none', 'object', 'partial'] | None = ..., hydra_defaults: list[DataClass_ | Mapping[str, Sequence[str] | str | None] | str | type[DataClass_]] | None = ..., dataclass_name: str | None = ..., builds_bases: tuple[type[DataClass_], ...] = ..., zen_dataclass: DataclassOptions | None = None, frozen: bool = ..., zen_convert: ZenConvert | None = ..., **kwargs_for_target: T) -> type[Builds[Importable]] [closest match]%0A (__hydra_target: type[AnyBuilds], *pos_args: T, *, zen_partial: Literal[True], populate_full_signature: bool = ..., zen_wrappers: ZenWrappers = ..., zen_meta: Mapping[str, SupportedPrimitive] | None = ..., hydra_recursive: bool | None = ..., hydra_convert: Literal['all', 'none', 'object', 'partial'] | None = ..., hydra_defaults: list[DataClass_ | Mapping[str, Sequence[str] | str | None] | str | type[DataClass_]] | None = ..., dataclass_name: str | None = ..., builds_bases: tuple[type[DataClass_], ...] = ..., zen_dataclass: DataclassOptions | None = None, frozen: bool = ..., zen_convert: ZenConvert | None = ..., **kwargs_for_target: T) -> type[PartialBuilds]%0A (__hydra_target: Importable, *pos_args: T, *, zen_partial: Literal[True], populate_full_signature: bool = ..., zen_wrappers: ZenWrappers = ..., zen_meta: Mapping[str, SupportedPrimitive] | None = ..., hydra_recursive: bool | None = ..., hydra_convert: Literal['all', 'none', 'object', 'partial'] | None = ..., hydra_defaults: list[DataClass_ | Mapping[str, Sequence[str] | str | None] | str | type[DataClass_]] | None = ..., dataclass_name: str | None = ..., builds_bases: tuple[type[DataClass_], ...] = ..., zen_dataclass: DataclassOptions | None = None, frozen: bool = ..., zen_convert: ZenConvert | None = ..., **kwargs_for_target: T) -> type[PartialBuilds]%0A (__hydra_target: type[AnyBuilds], *pos_args: T, *, zen_partial: bool | None = ..., populate_full_signature: Literal[False] = ..., zen_wrappers: ZenWrappers = ..., zen_meta: Mapping[str, SupportedPrimitive] | None = ..., hydra_recursive: bool | None = ..., hydra_convert: Literal['all', 'none', 'object', 'partial'] | None = ..., hydra_defaults: list[DataClass_ | Mapping[str, Sequence[str] | str | None] | str | type[DataClass_]] | None = ..., dataclass_name: str | None = ..., builds_bases: tuple[type[DataClass_], ...] = ..., zen_dataclass: DataclassOptions | None = None, frozen: bool = ..., zen_convert: ZenConvert | None = ..., **kwargs_for_target: T) -> type[PartialBuilds] | type[Builds[Importable]]%0A (__hydra_target: Importable, *pos_args: T, *, zen_partial: bool | None = ..., populate_full_signature: Literal[False] = ..., zen_wrappers: ZenWrappers = ..., zen_meta: Mapping[str, SupportedPrimitive] | None = ..., hydra_recursive: bool | None = ..., hydra_convert: Literal['all', 'none', 'object', 'partial'] | None = ..., hydra_defaults: list[DataClass_ | Mapping[str, Sequence[str] | str | None] | str | type[DataClass_]] | None = ..., dataclass_name: str | None = ..., builds_bases: tuple[type[DataClass_], ...] = ..., zen_dataclass: DataclassOptions | None = None, frozen: bool = ..., zen_convert: ZenConvert | None = ..., **kwargs_for_target: T) -> type[PartialBuilds] | type[Builds[Importable]]%0A (__hydra_target: ((ParamSpec(P)) -> R) | Importable | type[Builds[Importable]], *pos_args: T, *, zen_partial: bool | None, populate_full_signature: bool = ..., zen_wrappers: ZenWrappers = ..., zen_meta: Mapping[str, SupportedPrimitive] | None = ..., hydra_recursive: bool | None = ..., hydra_convert: Literal['all', 'none', 'object', 'partial'] | None = ..., hydra_defaults: list[DataClass_ | Mapping[str, Sequence[str] | str | None] | str | type[DataClass_]] | None = ..., dataclass_name: str | None = ..., builds_bases: tuple[type[DataClass_], ...] = ..., zen_dataclass: DataclassOptions | None = None, frozen: bool = ..., zen_convert: ZenConvert | None = ..., **kwargs_for_target: T) -> type[PartialBuilds] | type[Builds[Importable]] | type[BuildsWithSig[type[R], P]]
+ ::error file=src/hydra_zen/structured_configs/_implementations.py,line=1205,col=30,endLine=1215,endColumn=14,title=Pyrefly no-matching-overload::No matching overload found for function `BuildsFn.builds` called with arguments: (type, Never, exclude=list[@_], pre_call=list[Never] | None, unpack_kwargs=Never, resolve_pre_call=Never, run_in_context=Never, instantiation_wrapper=Never, populate_full_signature=Literal[True])%0A Possible overloads:%0A (__hydra_target: type[BuildsWithSig[type[R], P]], *, zen_partial: Literal[False] | None = ..., populate_full_signature: Literal[True], zen_wrappers: ZenWrappers = ..., zen_meta: Mapping[str, SupportedPrimitive] | None = ..., hydra_recursive: bool | None = ..., hydra_convert: Literal['all', 'none', 'object', 'partial'] | None = ..., hydra_defaults: list[DataClass_ | Mapping[str, Sequence[str] | str | None] | str | type[DataClass_]] | None = ..., dataclass_name: str | None = ..., builds_bases: tuple[()] = ..., zen_dataclass: DataclassOptions | None = None, frozen: bool = ..., zen_convert: ZenConvert | None = ...) -> type[BuildsWithSig[type[R], P]]%0A (__hydra_target: (ParamSpec(P)) -> R, *, zen_partial: Literal[False] | None = ..., populate_full_signature: Literal[True], zen_wrappers: ZenWrappers = ..., zen_meta: Mapping[str, SupportedPrimitive] | None = ..., hydra_recursive: bool | None = ..., hydra_convert: Literal['all', 'none', 'object', 'partial'] | None = ..., hydra_defaults: list[DataClass_ | Mapping[str, Sequence[str] | str | None] | str | type[DataClass_]] | None = ..., dataclass_name: str | None = ..., builds_bases: tuple[()] = ..., zen_dataclass: DataclassOptions | None = None, frozen: bool = ..., zen_convert: ZenConvert | None = ...) -> type[BuildsWithSig[type[R], P]]%0A (__hydra_target: type[AnyBuilds], *pos_args: T, *, zen_partial: Literal[False] | None = ..., populate_full_signature: bool = ..., zen_wrappers: ZenWrappers = ..., zen_meta: Mapping[str, SupportedPrimitive] | None = ..., hydra_recursive: bool | None = ..., hydra_convert: Literal['all', 'none', 'object', 'partial'] | None = ..., hydra_defaults: list[DataClass_ | Mapping[str, Sequence[str] | str | None] | str | type[DataClass_]] | None = ..., dataclass_name: str | None = ..., builds_bases: tuple[type[DataClass_], ...] = ..., zen_dataclass: DataclassOptions | None = None, frozen: bool = ..., zen_convert: ZenConvert | None = ..., **kwargs_for_target: T) -> type[Builds[Importable]] [closest match]%0A (__hydra_target: Importable, *pos_args: T, *, zen_partial: Literal[False] | None = ..., populate_full_signature: bool = ..., zen_wrappers: ZenWrappers = ..., zen_meta: Mapping[str, SupportedPrimitive] | None = ..., hydra_recursive: bool | None = ..., hydra_convert: Literal['all', 'none', 'object', 'partial'] | None = ..., hydra_defaults: list[DataClass_ | Mapping[str, Sequence[str] | str | None] | str | type[DataClass_]] | None = ..., dataclass_name: str | None = ..., builds_bases: tuple[type[DataClass_], ...] = ..., zen_dataclass: DataclassOptions | None = None, frozen: bool = ..., zen_convert: ZenConvert | None = ..., **kwargs_for_target: T) -> type[Builds[Importable]]%0A (__hydra_target: type[AnyBuilds], *pos_args: T, *, zen_partial: Literal[True], populate_full_signature: bool = ..., zen_wrappers: ZenWrappers = ..., zen_meta: Mapping[str, SupportedPrimitive] | None = ..., hydra_recursive: bool | None = ..., hydra_convert: Literal['all', 'none', 'object', 'partial'] | None = ..., hydra_defaults: list[DataClass_ | Mapping[str, Sequence[str] | str | None] | str | type[DataClass_]] | None = ..., dataclass_name: str | None = ..., builds_bases: tuple[type[DataClass_], ...] = ..., zen_dataclass: DataclassOptions | None = None, frozen: bool = ..., zen_convert: ZenConvert | None = ..., **kwargs_for_target: T) -> type[PartialBuilds]%0A (__hydra_target: Importable, *pos_args: T, *, zen_partial: Literal[True], populate_full_signature: bool = ..., zen_wrappers: ZenWrappers = ..., zen_meta: Mapping[str, SupportedPrimitive] | None = ..., hydra_recursive: bool | None = ..., hydra_convert: Literal['all', 'none', 'object', 'partial'] | None = ..., hydra_defaults: list[DataClass_ | Mapping[str, Sequence[str] | str | None] | str | type[DataClass_]] | None = ..., dataclass_name: str | None = ..., builds_bases: tuple[type[DataClass_], ...] = ..., zen_dataclass: DataclassOptions | None = None, frozen: bool = ..., zen_convert: ZenConvert | None = ..., **kwargs_for_target: T) -> type[PartialBuilds]%0A (__hydra_target: type[AnyBuilds], *pos_args: T, *, zen_partial: bool | None = ..., populate_full_signature: Literal[False] = ..., zen_wrappers: ZenWrappers = ..., zen_meta: Mapping[str, SupportedPrimitive] | None = ..., hydra_recursive: bool | None = ..., hydra_convert: Literal['all', 'none', 'object', 'partial'] | None = ..., hydra_defaults: list[DataClass_ | Mapping[str, Sequence[str] | str | None] | str | type[DataClass_]] | None = ..., dataclass_name: str | None = ..., builds_bases: tuple[type[DataClass_], ...] = ..., zen_dataclass: DataclassOptions | None = None, frozen: bool = ..., zen_convert: ZenConvert | None = ..., **kwargs_for_target: T) -> type[PartialBuilds] | type[Builds[Importable]]%0A (__hydra_target: Importable, *pos_args: T, *, zen_partial: bool | None = ..., populate_full_signature: Literal[False] = ..., zen_wrappers: ZenWrappers = ..., zen_meta: Mapping[str, SupportedPrimitive] | None = ..., hydra_recursive: bool | None = ..., hydra_convert: Literal['all', 'none', 'object', 'partial'] | None = ..., hydra_defaults: list[DataClass_ | Mapping[str, Sequence[str] | str | None] | str | type[DataClass_]] | None = ..., dataclass_name: str | None = ..., builds_bases: tuple[type[DataClass_], ...] = ..., zen_dataclass: DataclassOptions | None = None, frozen: bool = ..., zen_convert: ZenConvert | None = ..., **kwargs_for_target: T) -> type[PartialBuilds] | type[Builds[Importable]]%0A (__hydra_target: ((ParamSpec(P)) -> R) | Importable | type[Builds[Importable]], *pos_args: T, *, zen_partial: bool | None, populate_full_signature: bool = ..., zen_wrappers: ZenWrappers = ..., zen_meta: Mapping[str, SupportedPrimitive] | None = ..., hydra_recursive: bool | None = ..., hydra_convert: Literal['all', 'none', 'object', 'partial'] | None = ..., hydra_defaults: list[DataClass_ | Mapping[str, Sequence[str] | str | None] | str | type[DataClass_]] | None = ..., dataclass_name: str | None = ..., builds_bases: tuple[type[DataClass_], ...] = ..., zen_dataclass: DataclassOptions | None = None, frozen: bool = ..., zen_convert: ZenConvert | None = ..., **kwargs_for_target: T) -> type[PartialBuilds] | type[Builds[Importable]] | type[BuildsWithSig[type[R], P]]
django-stubs (https://github.com/typeddjango/django-stubs)
+ ERROR mypy_django_plugin/transformers/fields.py:78:38-55: Expected class object, got `Never` [invalid-argument]
+ ::error file=mypy_django_plugin/transformers/fields.py,line=78,col=38,endLine=78,endColumn=55,title=Pyrefly invalid-argument::Expected class object, got `Never`
bidict (https://github.com/jab/bidict)
- ERROR bidict/_base.py:500:15-28: Argument `BidictBase[tuple[KT, VT], Unknown]` is not assignable to parameter `self` with type `BidictBase[tuple[tuple[KT, VT], Unknown], Unknown]` in function `BidictBase.inverse` [bad-argument-type]
- ERROR bidict/_iter.py:26:9-31: yield from value must be iterable, got `ItemsView[tuple[KT, VT], Unknown] | ItemsView[KT, VT]` [invalid-yield]
- ::error file=bidict/_base.py,line=500,col=15,endLine=500,endColumn=28,title=Pyrefly bad-argument-type::Argument `BidictBase[tuple[KT, VT], Unknown]` is not assignable to parameter `self` with type `BidictBase[tuple[tuple[KT, VT], Unknown], Unknown]` in function `BidictBase.inverse`
- ::error file=bidict/_iter.py,line=26,col=9,endLine=26,endColumn=31,title=Pyrefly invalid-yield::yield from value must be iterable, got `ItemsView[tuple[KT, VT], Unknown] | ItemsView[KT, VT]`
schemathesis (https://github.com/schemathesis/schemathesis)
- ERROR src/schemathesis/openapi/checks.py:144:42-59: Argument `Mapping[str, Any] | Unset | bool | dict[str, Any]` is not assignable to parameter `schema` with type `bool | dict[str, Any] | list[JsonSchema]` in function `schemathesis.core.jsonschema.bundler.unbundle` [bad-argument-type]
+ ERROR src/schemathesis/openapi/checks.py:144:42-59: Argument `Mapping[str, Any] | Unset | bool | dict[str, Never]` is not assignable to parameter `schema` with type `bool | dict[str, Any] | list[JsonSchema]` in function `schemathesis.core.jsonschema.bundler.unbundle` [bad-argument-type]
- ::error file=src/schemathesis/openapi/checks.py,line=144,col=42,endLine=144,endColumn=59,title=Pyrefly bad-argument-type::Argument `Mapping[str, Any] | Unset | bool | dict[str, Any]` is not assignable to parameter `schema` with type `bool | dict[str, Any] | list[JsonSchema]` in function `schemathesis.core.jsonschema.bundler.unbundle`
+ ::error file=src/schemathesis/openapi/checks.py,line=144,col=42,endLine=144,endColumn=59,title=Pyrefly bad-argument-type::Argument `Mapping[str, Any] | Unset | bool | dict[str, Never]` is not assignable to parameter `schema` with type `bool | dict[str, Any] | list[JsonSchema]` in function `schemathesis.core.jsonschema.bundler.unbundle`
pwndbg (https://github.com/pwndbg/pwndbg)
- ERROR pwndbg/aglib/heap/ptmalloc.py:268:27-51: No matching overload found for function `int.__new__` called with arguments: (type[int], Value | Unknown | None) [no-matching-overload]
+ ERROR pwndbg/aglib/heap/ptmalloc.py:268:27-51: No matching overload found for function `int.__new__` called with arguments: (type[int], Value | None) [no-matching-overload]
+ ERROR pwndbg/aglib/heap/ptmalloc.py:512:39-88: `in` is not supported between `int` and `Generator[Never, None, None]` [unsupported-operation]
+ ERROR pwndbg/aglib/heap/ptmalloc.py:532:30-34: `None` is not assignable to attribute `arena` with type `Arena` [bad-assignment]
- ERROR pwndbg/aglib/heap/ptmalloc.py:515:45-71: Object of class `NoneType` has no attribute `sizeof` [missing-attribute]
- ERROR pwndbg/aglib/heap/ptmalloc.py:518:25-54: Object of class `NoneType` has no attribute `sizeof` [missing-attribute]
- ERROR pwndbg/aglib/heap/ptmalloc.py:525:18-43: Object of class `NoneType` has no attribute `non_contiguous` [missing-attribute]
- ERROR pwndbg/aglib/heap/ptmalloc.py:601:27-51: No matching overload found for function `int.__new__` called with arguments: (type[int], Value | Unknown | None) [no-matching-overload]
+ ERROR pwndbg/aglib/heap/ptmalloc.py:601:27-51: No matching overload found for function `int.__new__` called with arguments: (type[int], Value | None) [no-matching-overload]
- ERROR pwndbg/aglib/heap/ptmalloc.py:758:20-28: `not in` is not supported between `None` and `Page` [unsupported-operation]
- ERROR pwndbg/aglib/heap/ptmalloc.py:758:20-47: `not in` is not supported between `int` and `None` [not-iterable]
- ERROR pwndbg/aglib/heap/ptmalloc.py:758:20-47: `not in` is not supported between `None` and `None` [not-iterable]
- ERROR pwndbg/aglib/heap/ptmalloc.py:759:43-60: Object of class `NoneType` has no attribute `start` [missing-attribute]
- ERROR pwndbg/aglib/heap/ptmalloc.py:2000:40-81: Object of class `NoneType` has no attribute `next` [missing-attribute]
- ERROR pwndbg/commands/ptmalloc2.py:100:37-43: Argument `int | None` is not assignable to parameter `offset` with type `int` in function `pwndbg.chain.format` [bad-argument-type]
- ERROR pwndbg/commands/ptmalloc2.py:104:61-67: Argument `int | None` is not assignable to parameter `offset` with type `int` in function `pwndbg.chain.format` [bad-argument-type]
- ERROR pwndbg/commands/ptmalloc2.py:122:37-69: Argument `int | None` is not assignable to parameter `offset` with type `int` in function `pwndbg.chain.format` [bad-argument-type]
- ERROR pwndbg/commands/ptmalloc2.py:403:68-88: Object of class `NoneType` has no attribute `address` [missing-attribute]
- ERROR pwndbg/commands/ptmalloc2.py:404:11-47: Object of class `NoneType` has no attribute `value_to_human_readable` [missing-attribute]
- ERROR pwndbg/commands/ptmalloc2.py:507:40-55: Argument `int | None` is not assignable to parameter `size` with type `int` in function `pwndbg.aglib.heap.ptmalloc.Bins.contains_chunk` [bad-argument-type]
- ERROR pwndbg/commands/ptmalloc2.py:520:68-78: Argument `int | None` is not assignable to parameter `size` with type `int` in function `pwndbg.aglib.heap.ptmalloc.GlibcMemoryAllocator.chunk_flags` [bad-argument-type]
+ ERROR pwndbg/commands/ptmalloc2.py:1131:63-78: Argument `list[Unknown] | list[Never]` is not assignable to parameter `collections` with type `list[Bins | None]` in function `bin_labels_mapping` [bad-argument-type]
- ERROR pwndbg/commands/ptmalloc2.py:1444:41-77: `<` is not supported between `int` and `None` [unsupported-operation]
- ERROR pwndbg/commands/ptmalloc2.py:1449:31-61: Object of class `NoneType` has no attribute `address` [missing-attribute]
- ERROR pwndbg/commands/ptmalloc2.py:1464:26-45: `None` is not subscriptable [unsupported-operation]
- ERROR pwndbg/commands/ptmalloc2.py:1466:26-42: `None` is not subscriptable [unsupported-operation]
- ERROR pwndbg/commands/ptmalloc2.py:1479:8-56: `<=` is not supported between `int` and `None` [unsupported-operation]
- ERROR pwndbg/commands/ptmalloc2.py:1483:13-1484:18: Object of class `NoneType` has no attribute `bins` [missing-attribute]
- ERROR pwndbg/commands/ptmalloc2.py:1501:46-92: `>=` is not supported between `int` and `None` [unsupported-operation]
- ERROR pwndbg/commands/ptmalloc2.py:1558:32-46: Argument `int | None` is not assignable to parameter `addr` with type `int` in function `read_chunk` [bad-argument-type]
- ERROR pwndbg/commands/ptmalloc2.py:1562:13-44: `&` is not supported between `None` and `Literal[2]` [unsupported-operation]
- ERROR pwndbg/commands/ptmalloc2.py:1562:74-1564:10: `+` is not supported between `None` and `int` [unsupported-operation]
- ERROR pwndbg/commands/ptmalloc2.py:1568:34-94: `+` is not supported between `None` and `int` [unsupported-operation]
- ERROR pwndbg/commands/ptmalloc2.py:1590:46-81: `>=` is not supported between `int` and `None` [unsupported-operation]
- ERROR pwndbg/gdblib/ptmalloc2_tracking.py:359:45-57: Argument `int | None` is not assignable to parameter `size` with type `int` in function `pwndbg.aglib.heap.ptmalloc.Bins.contains_chunk` [bad-argument-type]
- ::error file=pwndbg/aglib/heap/ptmalloc.py,line=268,col=27,endLine=268,endColumn=51,title=Pyrefly no-matching-overload::No matching overload found for function `int.__new__` called with arguments: (type[int], Value | Unknown | None)%0A Possible overloads:%0A (cls: type[int], x: ConvertibleToInt = 0, /) -> int [closest match]%0A (cls: type[int], x: bytearray | bytes | str, /, base: SupportsIndex) -> int
+ ::error file=pwndbg/aglib/heap/ptmalloc.py,line=268,col=27,endLine=268,endColumn=51,title=Pyrefly no-matching-overload::No matching overload found for function `int.__new__` called with arguments: (type[int], Value | None)%0A Possible overloads:%0A (cls: type[int], x: ConvertibleToInt = 0, /) -> int [closest match]%0A (cls: type[int], x: bytearray | bytes | str, /, base: SupportsIndex) -> int
+ ::error file=pwndbg/aglib/heap/ptmalloc.py,line=512,col=39,endLine=512,endColumn=88,title=Pyrefly unsupported-operation::`in` is not supported between `int` and `Generator[Never, None, None]`%0A `int` is not assignable to contained type `Never`
+ ::error file=pwndbg/aglib/heap/ptmalloc.py,line=532,col=30,endLine=532,endColumn=34,title=Pyrefly bad-assignment::`None` is not assignable to attribute `arena` with type `Arena`
- ::error file=pwndbg/aglib/heap/ptmalloc.py,line=515,col=45,endLine=515,endColumn=71,title=Pyrefly missing-attribute::Object of class `NoneType` has no attribute `sizeof`
- ::error file=pwndbg/aglib/heap/ptmalloc.py,line=518,col=25,endLine=518,endColumn=54,title=Pyrefly missing-attribute::Object of class `NoneType` has no attribute `sizeof`
- ::error file=pwndbg/aglib/heap/ptmalloc.py,line=525,col=18,endLine=525,endColumn=43,title=Pyrefly missing-attribute::Object of class `NoneType` has no attribute `non_contiguous`
- ::error file=pwndbg/aglib/heap/ptmalloc.py,line=601,col=27,endLine=601,endColumn=51,title=Pyrefly no-matching-overload::No matching overload found for function `int.__new__` called with arguments: (type[int], Value | Unknown | None)%0A Possible overloads:%0A (cls: type[int], x: ConvertibleToInt = 0, /) -> int [closest match]%0A (cls: type[int], x: bytearray | bytes | str, /, base: SupportsIndex) -> int
+ ::error file=pwndbg/aglib/heap/ptmalloc.py,line=601,col=27,endLine=601,endColumn=51,title=Pyrefly no-matching-overload::No matching overload found for function `int.__new__` called with arguments: (type[int], Value | None)%0A Possible overloads:%0A (cls: type[int], x: ConvertibleToInt = 0, /) -> int [closest match]%0A (cls: type[int], x: bytearray | bytes | str, /, base: SupportsIndex) -> int
- ::error file=pwndbg/aglib/heap/ptmalloc.py,line=758,col=20,endLine=758,endColumn=28,title=Pyrefly unsupported-operation::`not in` is not supported between `None` and `Page`%0A Argument `None` is not assignable to parameter `addr` with type `int` in function `pwndbg.lib.memory.Page.__contains__`
- ::error file=pwndbg/aglib/heap/ptmalloc.py,line=758,col=20,endLine=758,endColumn=47,title=Pyrefly not-iterable::`not in` is not supported between `int` and `None`
- ::error file=pwndbg/aglib/heap/ptmalloc.py,line=758,col=20,endLine=758,endColumn=47,title=Pyrefly not-iterable::`not in` is not supported between `None` and `None`
- ::error file=pwndbg/aglib/heap/ptmalloc.py,line=759,col=43,endLine=759,endColumn=60,title=Pyrefly missing-attribute::Object of class `NoneType` has no attribute `start`
- ::error file=pwndbg/aglib/heap/ptmalloc.py,line=2000,col=40,endLine=2000,endColumn=81,title=Pyrefly missing-attribute::Object of class `NoneType` has no attribute `next`
- ::error file=pwndbg/commands/ptmalloc2.py,line=100,col=37,endLine=100,endColumn=43,title=Pyrefly bad-argument-type::Argument `int | None` is not assignable to parameter `offset` with type `int` in function `pwndbg.chain.format`
- ::error file=pwndbg/commands/ptmalloc2.py,line=104,col=61,endLine=104,endColumn=67,title=Pyrefly bad-argument-type::Argument `int | None` is not assignable to parameter `offset` with type `int` in function `pwndbg.chain.format`
- ::error file=pwndbg/commands/ptmalloc2.py,line=122,col=37,endLine=122,endColumn=69,title=Pyrefly bad-argument-type::Argument `int | None` is not assignable to parameter `offset` with type `int` in function `pwndbg.chain.format`
- ::error file=pwndbg/commands/ptmalloc2.py,line=403,col=68,endLine=403,endColumn=88,title=Pyrefly missing-attribute::Object of class `NoneType` has no attribute `address`
- ::error file=pwndbg/commands/ptmalloc2.py,line=404,col=11,endLine=404,endColumn=47,title=Pyrefly missing-attribute::Object of class `NoneType` has no attribute `value_to_human_readable`
- ::error file=pwndbg/commands/ptmalloc2.py,line=507,col=40,endLine=507,endColumn=55,title=Pyrefly bad-argument-type::Argument `int | None` is not assignable to parameter `size` with type `int` in function `pwndbg.aglib.heap.ptmalloc.Bins.contains_chunk`
- ::error file=pwndbg/commands/ptmalloc2.py,line=520,col=68,endLine=520,endColumn=78,title=Pyrefly bad-argument-type::Argument `int | None` is not assignable to parameter `size` with type `int` in function `pwndbg.aglib.heap.ptmalloc.GlibcMemoryAllocator.chunk_flags`
+ ::error file=pwndbg/commands/ptmalloc2.py,line=1131,col=63,endLine=1131,endColumn=78,title=Pyrefly bad-argument-type::Argument `list[Unknown] | list[Never]` is not assignable to parameter `collections` with type `list[Bins | None]` in function `bin_labels_mapping`
- ::error file=pwndbg/commands/ptmalloc2.py,line=1444,col=41,endLine=1444,endColumn=77,title=Pyrefly unsupported-operation::`<` is not supported between `int` and `None`%0A Argument `None` is not assignable to parameter `value` with type `int` in function `int.__lt__`
- ::error file=pwndbg/commands/ptmalloc2.py,line=1449,col=31,endLine=1449,endColumn=61,title=Pyrefly missing-attribute::Object of class `NoneType` has no attribute `address`
- ::error file=pwndbg/commands/ptmalloc2.py,line=1464,col=26,endLine=1464,endColumn=45,title=Pyrefly unsupported-operation::`None` is not subscriptable
- ::error file=pwndbg/commands/ptmalloc2.py,line=1466,col=26,endLine=1466,endColumn=42,title=Pyrefly unsupported-operation::`None` is not subscriptable
- ::error file=pwndbg/commands/ptmalloc2.py,line=1479,col=8,endLine=1479,endColumn=56,title=Pyrefly unsupported-operation::`<=` is not supported between `int` and `None`%0A Argument `None` is not assignable to parameter `value` with type `int` in function `int.__le__`
- ::error file=pwndbg/commands/ptmalloc2.py,line=1483,col=13,endLine=1484,endColumn=18,title=Pyrefly missing-attribute::Object of class `NoneType` has no attribute `bins`
- ::error file=pwndbg/commands/ptmalloc2.py,line=1501,col=46,endLine=1501,endColumn=92,title=Pyrefly unsupported-operation::`>=` is not supported between `int` and `None`%0A Argument `None` is not assignable to parameter `value` with type `int` in function `int.__ge__`
- ::error file=pwndbg/commands/ptmalloc2.py,line=1558,col=32,endLine=1558,endColumn=46,title=Pyrefly bad-argument-type::Argument `int | None` is not assignable to parameter `addr` with type `int` in function `read_chunk`
- ::error file=pwndbg/commands/ptmalloc2.py,line=1562,col=13,endLine=1562,endColumn=44,title=Pyrefly unsupported-operation::`&` is not supported between `None` and `Literal[2]`%0A Argument `None` is not assignable to parameter `value` with type `int` in function `int.__rand__`
- ::error file=pwndbg/commands/ptmalloc2.py,line=1562,col=74,endLine=1564,endColumn=10,title=Pyrefly unsupported-operation::`+` is not supported between `None` and `int`%0A Argument `None` is not assignable to parameter `value` with type `int` in function `int.__radd__`
- ::error file=pwndbg/commands/ptmalloc2.py,line=1568,col=34,endLine=1568,endColumn=94,title=Pyrefly unsupported-operation::`+` is not supported between `None` and `int`%0A Argument `None` is not assignable to parameter `value` with type `int` in function `int.__radd__`
- ::error file=pwndbg/commands/ptmalloc2.py,line=1590,col=46,endLine=1590,endColumn=81,title=Pyrefly unsupported-operation::`>=` is not supported between `int` and `None`%0A Argument `None` is not assignable to parameter `value` with type `int` in function `int.__ge__`
- ::error file=pwndbg/gdblib/ptmalloc2_tracking.py,line=359,col=45,endLine=359,endColumn=57,title=Pyrefly bad-argument-type::Argument `int | None` is not assignable to parameter `size` with type `int` in function `pwndbg.aglib.heap.ptmalloc.Bins.contains_chunk`
streamlit (https://github.com/streamlit/streamlit)
- WARN lib/streamlit/dataframe_util.py:952:20-52: Redundant cast: `list[V_co]` is the same type as `list[V_co]` [redundant-cast]
- ::warning file=lib/streamlit/dataframe_util.py,line=952,col=20,endLine=952,endColumn=52,title=Pyrefly redundant-cast::Redundant cast: `list[V_co]` is the same type as `list[V_co]`
ibis (https://github.com/ibis-project/ibis)
- ERROR ibis/util.py:108:16-21: Returned type `list[dict[V, Unknown]]` is not assignable to declared return type `list[V]` [bad-return]
- ::error file=ibis/util.py,line=108,col=16,endLine=108,endColumn=21,title=Pyrefly bad-return::Returned type `list[dict[V, Unknown]]` is not assignable to declared return type `list[V]`
schema_salad (https://github.com/common-workflow-language/schema_salad)
- ERROR schema_salad/jsonld_context.py:234:33-38: No matching overload found for function `urllib.parse.urldefrag` called with arguments: (Iterable[str] | str | Unknown) [no-matching-overload]
+ ERROR schema_salad/jsonld_context.py:234:33-38: No matching overload found for function `urllib.parse.urldefrag` called with arguments: (Iterable[str] | str | Any) [no-matching-overload]
- ::error file=schema_salad/jsonld_context.py,line=234,col=33,endLine=234,endColumn=38,title=Pyrefly no-matching-overload::No matching overload found for function `urllib.parse.urldefrag` called with arguments: (Iterable[str] | str | Unknown)%0A Possible overloads:%0A (url: str) -> DefragResult [closest match]%0A (url: bytearray | bytes | None) -> DefragResultBytes
+ ::error file=schema_salad/jsonld_context.py,line=234,col=33,endLine=234,endColumn=38,title=Pyrefly no-matching-overload::No matching overload found for function `urllib.parse.urldefrag` called with arguments: (Iterable[str] | str | Any)%0A Possible overloads:%0A (url: str) -> DefragResult [closest match]%0A (url: bytearray | bytes | None) -> DefragResultBytes
aiohttp (https://github.com/aio-libs/aiohttp)
- ERROR aiohttp/cookiejar.py:230:23-38: `ItemsView[str, BaseCookie[str] | Morsel[Any] | str] | ItemsView[tuple[str, BaseCookie[str] | Morsel[Any] | str], Unknown] | dict_items[str, Morsel[str]]` is not assignable to variable `cookies` with type `BaseCookie[str] | Iterable[tuple[str, BaseCookie[str] | Morsel[Any] | str]] | Mapping[str, BaseCookie[str] | Morsel[Any] | str]` [bad-assignment]
- ::error file=aiohttp/cookiejar.py,line=230,col=23,endLine=230,endColumn=38,title=Pyrefly bad-assignment::`ItemsView[str, BaseCookie[str] | Morsel[Any] | str] | ItemsView[tuple[str, BaseCookie[str] | Morsel[Any] | str], Unknown] | dict_items[str, Morsel[str]]` is not assignable to variable `cookies` with type `BaseCookie[str] | Iterable[tuple[str, BaseCookie[str] | Morsel[Any] | str]] | Mapping[str, BaseCookie[str] | Morsel[Any] | str]`
nox (https://github.com/wntrblm/nox)
- ERROR nox/manifest.py:318:44-56: Argument `object | str` is not assignable to parameter `*args` with type `str` in function `_unique_list` [bad-argument-type]
+ ERROR nox/manifest.py:318:44-56: Argument `object` is not assignable to parameter `*args` with type `str` in function `_unique_list` [bad-argument-type]
- ERROR nox/manifest.py:337:38-44: `object | str` is not assignable to attribute `python` with type `Sequence[str] | bool | str | None` [bad-assignment]
+ ERROR nox/manifest.py:337:38-44: `object` is not assignable to attribute `python` with type `Sequence[str] | bool | str | None` [bad-assignment]
- ::error file=nox/manifest.py,line=318,col=44,endLine=318,endColumn=56,title=Pyrefly bad-argument-type::Argument `object | str` is not assignable to parameter `*args` with type `str` in function `_unique_list`
+ ::error file=nox/manifest.py,line=318,col=44,endLine=318,endColumn=56,title=Pyrefly bad-argument-type::Argument `object` is not assignable to parameter `*args` with type `str` in function `_unique_list`
- ::error file=nox/manifest.py,line=337,col=38,endLine=337,endColumn=44,title=Pyrefly bad-assignment::`object | str` is not assignable to attribute `python` with type `Sequence[str] | bool | str | None`
+ ::error file=nox/manifest.py,line=337,col=38,endLine=337,endColumn=44,title=Pyrefly bad-assignment::`object` is not assignable to attribute `python` with type `Sequence[str] | bool | str | None`
vision (https://github.com/pytorch/vision)
- ERROR torchvision/transforms/transforms.py:2154:40-50: Argument `Sequence[Unknown] | list[float | object | Unknown] | list[float]` is not assignable to parameter `alpha` with type `list[float]` in function `ElasticTransform.get_params` [bad-argument-type]
+ ERROR torchvision/transforms/transforms.py:2154:40-50: Argument `Sequence[Unknown] | list[float | object] | list[float]` is not assignable to parameter `alpha` with type `list[float]` in function `ElasticTransform.get_params` [bad-argument-type]
- ERROR torchvision/transforms/transforms.py:2154:52-62: Argument `Sequence[Unknown] | list[float | object | Unknown] | list[float]` is not assignable to parameter `sigma` with type `list[float]` in function `ElasticTransform.get_params` [bad-argument-type]
+ ERROR torchvision/transforms/transforms.py:2154:52-62: Argument `Sequence[Unknown] | list[float | object] | list[float]` is not assignable to parameter `sigma` with type `list[float]` in function `ElasticTransform.get_params` [bad-argument-type]
- ::error file=torchvision/transforms/transforms.py,line=2154,col=40,endLine=2154,endColumn=50,title=Pyrefly bad-argument-type::Argument `Sequence[Unknown] | list[float | object | Unknown] | list[float]` is not assignable to parameter `alpha` with type `list[float]` in function `ElasticTransform.get_params`
+ ::error file=torchvision/transforms/transforms.py,line=2154,col=40,endLine=2154,endColumn=50,title=Pyrefly bad-argument-type::Argument `Sequence[Unknown] | list[float | object] | list[float]` is not assignable to parameter `alpha` with type `list[float]` in function `ElasticTransform.get_params`
- ::error file=torchvision/transforms/transforms.py,line=2154,col=52,endLine=2154,endColumn=62,title=Pyrefly bad-argument-type::Argument `Sequence[Unknown] | list[float | object | Unknown] | list[float]` is not assignable to parameter `sigma` with type `list[float]` in function `ElasticTransform.get_params`
+ ::error file=torchvision/transforms/transforms.py,line=2154,col=52,endLine=2154,endColumn=62,title=Pyrefly bad-argument-type::Argument `Sequence[Unknown] | list[float | object] | list[float]` is not assignable to parameter `sigma` with type `list[float]` in function `ElasticTransform.get_params`
cwltool (https://github.com/common-workflow-language/cwltool)
- ERROR cwltool/process.py:318:51-58: Argument `MutableMapping[str, Unknown] | MutableSequence[Unknown] | bool | float | int | str | None` is not assignable to parameter `obj` with type `MutableMapping[str, MutableMapping[str, Unknown] | MutableSequence[Unknown] | bool | float | int | str | None] | MutableSequence[MutableMapping[str, MutableMapping[str, Unknown] | MutableSequence[Unknown] | bool | float | int | str | None]] | None` in function `_collectDirEntries` [bad-argument-type]
- ERROR tests/test_examples.py:327:12-28: Cannot index into `bool` [bad-index]
- ERROR tests/test_examples.py:327:12-28: Cannot index into `float` [bad-index]
- ERROR tests/test_examples.py:327:12-28: Cannot index into `int` [bad-index]
- ERROR tests/test_examples.py:327:12-28: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_examples.py:327:12-40: Cannot index into `str` [bad-index]
- ERROR tests/test_examples.py:327:26-27: Cannot index into `MutableMapping[str, Unknown]` [bad-index]
- ERROR tests/test_examples.py:328:12-28: Cannot index into `bool` [bad-index]
- ERROR tests/test_examples.py:328:12-28: Cannot index into `float` [bad-index]
- ERROR tests/test_examples.py:328:12-28: Cannot index into `int` [bad-index]
- ERROR tests/test_examples.py:328:12-28: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_examples.py:328:26-27: Cannot index into `MutableMapping[str, Unknown]` [bad-index]
- ERROR tests/test_examples.py:329:12-28: Cannot index into `bool` [bad-index]
- ERROR tests/test_examples.py:329:12-28: Cannot index into `float` [bad-index]
- ERROR tests/test_examples.py:329:12-28: Cannot index into `int` [bad-index]
- ERROR tests/test_examples.py:329:12-28: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_examples.py:329:26-27: Cannot index into `MutableMapping[str, Unknown]` [bad-index]
- ERROR tests/test_examples.py:342:12-38: Cannot index into `MutableSequence[Unknown]` [bad-index]
- ERROR tests/test_examples.py:342:12-38: Cannot index into `bool` [bad-index]
- ERROR tests/test_examples.py:342:12-38: Cannot index into `float` [bad-index]
- ERROR tests/test_examples.py:342:12-38: Cannot index into `int` [bad-index]
- ERROR tests/test_examples.py:342:12-38: Cannot index into `str` [bad-index]
- ERROR tests/test_examples.py:342:12-38: `None` is not subscriptable [unsupported-operation]
- ERROR tests/test_examples.py:1674:28-47: Cannot index into `str` [bad-index]
- ERROR tests/test_examples.py:1674:63-79: Type `bool` is not iterable [not-iterable]
- ERROR tests/test_examples.py:1674:63-79: Type `float` is not iterable [not-iterable]
- ERROR tests/test_examples.py:1674:63-79: Type `int` is not iterable [not-iterable]
- ERROR tests/test_examples.py:1674:63-79: Type `None` is not iterable [not-iterable]
- ::error file=cwltool/process.py,line=318,col=51,endLine=318,endColumn=58,title=Pyrefly bad-argument-type::Argument `MutableMapping[str, Unknown] | MutableSequence[Unknown] | bool | float | int | str | None` is not assignable to parameter `obj` with type `MutableMapping[str, MutableMapping[str, Unknown] | MutableSequence[Unknown] | bool | float | int | str | None] | MutableSequence[MutableMapping[str, MutableMapping[str, Unknown] | MutableSequence[Unknown] | bool | float | int | str | None]] | None` in function `_collectDirEntries`
- ::error file=tests/test_examples.py,line=327,col=12,endLine=327,endColumn=28,title=Pyrefly bad-index::Cannot index into `bool`%0A Object of class `bool` has no attribute `__getitem__`
- ::error file=tests/test_examples.py,line=327,col=12,endLine=327,endColumn=28,title=Pyrefly bad-index::Cannot index into `float`%0A Object of class `float` has no attribute `__getitem__`
- ::error file=tests/test_examples.py,line=327,col=12,endLine=327,endColumn=28,title=Pyrefly bad-index::Cannot index into `int`%0A Object of class `int` has no attribute `__getitem__`
- ::error file=tests/test_examples.py,line=327,col=12,endLine=327,endColumn=28,title=Pyrefly unsupported-operation::`None` is not subscriptable
- ::error file=tests/test_examples.py,line=327,col=12,endLine=327,endColumn=40,title=Pyrefly bad-index::Cannot index into `str`%0A No matching overload found for function `str.__getitem__` called with arguments: (Literal['checksum'])%0A Possible overloads:%0A (key: SupportsIndex | slice[Any, Any, Any], /) -> LiteralString%0A (key: SupportsIndex | slice[Any, Any, Any], /) -> str [closest match]
- ::error file=tests/test_examples.py,line=327,col=26,endLine=327,endColumn=27,title=Pyrefly bad-index::Cannot index into `MutableMapping[str, Unknown]`%0A Argument `Literal[0]` is not assignable to parameter `key` with type `str` in function `typing.Mapping.__getitem__`
- ::error file=tests/test_examples.py,line=328,col=12,endLine=328,endColumn=28,title=Pyrefly bad-index::Cannot index into `bool`%0A Object of class `bool` has no attribute `__getitem__`
- ::error file=tests/test_examples.py,line=328,col=12,endLine=328,endColumn=28,title=Pyrefly bad-index::Cannot index into `float`%0A Object of class `float` has no attribute `__getitem__`
- ::error file=tests/test_examples.py,line=328,col=12,endLine=328,endColumn=28,title=Pyrefly bad-index::Cannot index into `int`%0A Object of class `int` has no attribute `__getitem__`
- ::error file=tests/test_examples.py,line=328,col=12,endLine=328,endColumn=28,title=Pyrefly unsupported-operation::`None` is not subscriptable
- ::error file=tests/test_examples.py,line=328,col=26,endLine=328,endColumn=27,title=Pyrefly bad-index::Cannot index into `MutableMapping[str, Unknown]`%0A Argument `Literal[1]` is not assignable to parameter `key` with type `str` in function `typing.Mapping.__getitem__`
- ::error file=tests/test_examples.py,line=329,col=12,endLine=329,endColumn=28,title=Pyrefly bad-index::Cannot index into `bool`%0A Object of class `bool` has no attribute `__getitem__`
- ::error file=tests/test_examples.py,line=329,col=12,endLine=329,endColumn=28,title=Pyrefly bad-index::Cannot index into `float`%0A Object of class `float` has no attribute `__getitem__`
- ::error file=tests/test_examples.py,line=329,col=12,endLine=329,endColumn=28,title=Pyrefly bad-index::Cannot index into `int`%0A Object of class `int` has no attribute `__getitem__`
- ::error file=tests/test_examples.py,line=329,col=12,endLine=329,endColumn=28,title=Pyrefly unsupported-operation::`None` is not subscriptable
- ::error file=tests/test_examples.py,line=329,col=26,endLine=329,endColumn=27,title=Pyrefly bad-index::Cannot index into `MutableMapping[str, Unknown]`%0A Argument `Literal[2]` is not assignable to parameter `key` with type `str` in function `typing.Mapping.__getitem__`
- ::error file=tests/test_examples.py,line=342,col=12,endLine=342,endColumn=38,title=Pyrefly bad-index::Cannot index into `MutableSequence[Unknown]`%0A No matching overload found for function `typing.MutableSequence.__getitem__` called with arguments: (Literal['checksum'])%0A Possible overloads:%0A (index: int) -> Unknown [closest match]%0A (index: slice[Any, Any, Any]) -> MutableSequence[Unknown]
- ::error file=tests/test_examples.py,line=342,col=12,endLine=342,endColumn=38,title=Pyrefly bad-index::Cannot index into `bool`%0A Object of class `bool` has no attribute `__getitem__`
- ::error file=tests/test_examples.py,line=342,col=12,endLine=342,endColumn=38,title=Pyrefly bad-index::Cannot index into `float`%0A Object of class `float` has no attribute `__getitem__`
- ::error file=tests/test_examples.py,line=342,col=12,endLine=342,endColumn=38,title=Pyrefly bad-index::Cannot index into `int`%0A Object of class `int` has no attribute `__getitem__`
- ::error file=tests/test_examples.py,line=342,col=12,endLine=342,endColumn=38,title=Pyrefly bad-index::Cannot index into `str`%0A No matching overload found for function `str.__getitem__` called with arguments: (Literal['checksum'])%0A Possible overloads:%0A (key: SupportsIndex | slice[Any, Any, Any], /) -> LiteralString%0A (key: SupportsIndex | slice[Any, Any, Any], /) -> str [closest match]
- ::error file=tests/test_examples.py,line=342,col=12,endLine=342,endColumn=38,title=Pyrefly unsupported-operation::`None` is not subscriptable
- ::error file=tests/test_examples.py,line=1674,col=28,endLine=1674,endColumn=47,title=Pyrefly bad-index::Cannot index into `str`%0A No matching overload found for function `str.__getitem__` called with arguments: (Literal['location'])%0A Possible overloads:%0A (key: SupportsIndex | slice[Any, Any, Any], /) -> LiteralString%0A (key: SupportsIndex | slice[Any, Any, Any], /) -> str [closest match]
- ::error file=tests/test_examples.py,line=1674,col=63,endLine=1674,endColumn=79,title=Pyrefly not-iterable::Type `bool` is not iterable
- ::error file=tests/test_examples.py,line=1674,col=63,endLine=1674,endColumn=79,title=Pyrefly not-iterable::Type `float` is not iterable
- ::error file=tests/test_examples.py,line=1674,col=63,endLine=1674,endColumn=79,title=Pyrefly not-iterable::Type `int` is not iterable
- ::error file=tests/test_examples.py,line=1674,col=63,endLine=1674,endColumn=79,title=Pyrefly not-iterable::Type `None` is not iterable
mongo-python-driver (https://github.com/mongodb/mongo-python-driver)
- ERROR pymongo/asynchronous/cursor.py:686:25-31: No matching overload found for function `dict.__init__` called with arguments: (list[str | tuple[str, Mapping[str, Any] | int | str]] | tuple[*Sequence[str | tuple[str, Mapping[str, Any] | int | str]]]) [no-matching-overload]
+ ERROR pymongo/asynchronous/cursor.py:686:25-31: No matching overload found for function `dict.__init__` called with arguments: (tuple[*Sequence[str | tuple[str, Mapping[str, Any] | int | str]]]) [no-matching-overload]
- ERROR pymongo/asynchronous/cursor.py:708:25-31: No matching overload found for function `dict.__init__` called with arguments: (list[str | tuple[str, Mapping[str, Any] | int | str]] | tuple[*Sequence[str | tuple[str, Mapping[str, Any] | int | str]]]) [no-matching-overload]
+ ERROR pymongo/asynchronous/cursor.py:708:25-31: No matching overload found for function `dict.__init__` called with arguments: (tuple[*Sequence[str | tuple[str, Mapping[str, Any] | int | str]]]) [no-matching-overload]
- ERROR pymongo/synchronous/cursor.py:684:25-31: No matching overload found for function `dict.__init__` called with arguments: (list[str | tuple[str, Mapping[str, Any] | int | str]] | tuple[*Sequence[str | tuple[str, Mapping[str, Any] | int | str]]]) [no-matching-overload]
... (truncated 69 lines) ...``` |
Summary
Fixes #2169
When narrowing a union type with
isinstance, if a union member is a proper supertype of the isinstance target, we shouldnot narrow that member to the isinstance target with fabricated type arguments.
Before:
After:
def test(arg: Mapping[str, int] | Iterable[tuple[str, int]]) -> None:
if isinstance(arg, Mapping):
reveal_type(arg) # Mapping[str, int] ✅
Problem
The issue occurs when:
tuple[str, int]
This resulted in fabricating Mapping[tuple[str, int], Unknown] from Iterable[tuple[str, int]], which is incorrect.
Solution
Added a check in narrow_isinstance to detect when a union member is a proper supertype of the isinstance target (with type
parameters). In this case, return Never instead of allowing the fabricated type through unification.
let is_supertype_in_union = !tparams.is_empty()
&& left.is_union()
&& self.is_subset_eq(&right, l)
&& !self.is_subset_eq(l, &right);
The condition checks:
Test Plan