Skip to content

Conversation

@mtshiba
Copy link
Collaborator

@mtshiba mtshiba commented Apr 13, 2025

Summary

This PR closes astral-sh/ty#128.

FunctionType::infer_return_type is added to infer the return type of a function when its return type is not specified.

TODOs

  • infer simple function's return type
    - [ ] infer generator's return type
    - [ ] infer coroutine's return type
    - [ ] infer lambda function's return type

Test Plan

New test cases are added to mdtest/function/return_type.md.

@github-actions
Copy link
Contributor

github-actions bot commented Apr 13, 2025

mypy_primer results

Changes were detected when running on open source projects
zipp (https://github.com/jaraco/zipp)
+ zipp/__init__.py:373:29: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `str | PathLike[str]`, found `Unknown | str | None`
+ zipp/__init__.py:433:16: error[no-matching-overload] No overload of function `join` matches arguments
+ zipp/glob.py:67:16: error[no-matching-overload] No overload of bound method `join` matches arguments
- Found 4 diagnostics
+ Found 7 diagnostics

attrs (https://github.com/python-attrs/attrs)
+ src/attr/_make.py:453:19: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `Self@from_counting_attr | Unknown`
+ src/attr/_make.py:457:19: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `Self@from_counting_attr | Unknown`
- src/attr/_make.py:475:35: warning[possibly-missing-attribute] Attribute `init` may be missing on object of type `Attribute | Unknown`
+ src/attr/_make.py:475:35: warning[possibly-missing-attribute] Attribute `init` may be missing on object of type `Unknown | Self@evolve`
- src/attr/_make.py:475:59: warning[possibly-missing-attribute] Attribute `kw_only` may be missing on object of type `Attribute | Unknown`
+ src/attr/_make.py:475:59: warning[possibly-missing-attribute] Attribute `kw_only` may be missing on object of type `Unknown | Self@evolve`
- src/attr/_make.py:480:37: warning[possibly-missing-attribute] Attribute `default` may be missing on object of type `Attribute | Unknown`
+ src/attr/_make.py:480:37: warning[possibly-missing-attribute] Attribute `default` may be missing on object of type `Unknown | Self@evolve`
- src/attr/_make.py:487:16: warning[possibly-missing-attribute] Attribute `alias` may be missing on object of type `Attribute | Unknown`
+ src/attr/_make.py:487:16: warning[possibly-missing-attribute] Attribute `alias` may be missing on object of type `Unknown | Self@evolve`
- src/attr/_make.py:489:70: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `Attribute | Unknown`
+ src/attr/_make.py:489:70: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `Unknown | Self@evolve`
- src/attr/_make.py:493:19: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `Attribute | Unknown`
+ src/attr/_make.py:493:19: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `Unknown | Self@evolve`
- src/attr/_make.py:797:13: error[invalid-assignment] Object of type `ReferenceType[Unknown]` is not assignable to attribute `__attrs_base_of_slotted__` on type `Unknown | type`
+ src/attr/_make.py:797:13: error[invalid-assignment] Object of type `ReferenceType[Unknown | type]` is not assignable to attribute `__attrs_base_of_slotted__` on type `Unknown | type`
+ src/attr/_make.py:809:13: warning[possibly-missing-attribute] Attribute `__attrs_init_subclass__` may be missing on object of type `Unknown | type`
- src/attr/_make.py:1061:13: error[invalid-argument-type] Argument to function `_make_hash_script` is incorrect: Expected `list[Attribute | Unknown]`, found `Unknown | type`
+ src/attr/_make.py:1061:13: error[invalid-argument-type] Argument to function `_make_hash_script` is incorrect: Expected `list[Attribute]`, found `Unknown | type`
- src/attr/_make.py:1608:13: error[invalid-assignment] Object of type `tuple[Attribute | Unknown, ...]` is not assignable to `list[Attribute | Unknown]`
+ src/attr/_make.py:1608:13: error[invalid-assignment] Object of type `tuple[Attribute, ...]` is not assignable to `list[Attribute]`
- src/attr/_make.py:1609:29: warning[possibly-missing-attribute] Attribute `hash` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:1609:48: warning[possibly-missing-attribute] Attribute `hash` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:1609:67: warning[possibly-missing-attribute] Attribute `eq` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:1647:16: warning[possibly-missing-attribute] Attribute `eq_key` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:1648:32: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:1649:35: warning[possibly-missing-attribute] Attribute `eq_key` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:1651:57: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:1654:62: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2189:12: warning[possibly-missing-attribute] Attribute `validator` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2192:21: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2193:26: warning[possibly-missing-attribute] Attribute `on_setattr` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2194:13: warning[possibly-missing-attribute] Attribute `on_setattr` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2198:20: warning[possibly-missing-attribute] Attribute `alias` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2200:34: warning[possibly-missing-attribute] Attribute `default` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2201:48: warning[possibly-missing-attribute] Attribute `default` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2203:12: warning[possibly-missing-attribute] Attribute `converter` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2203:55: warning[possibly-missing-attribute] Attribute `converter` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2204:35: warning[possibly-missing-attribute] Attribute `converter` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2206:25: warning[possibly-missing-attribute] Attribute `converter` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2208:12: warning[possibly-missing-attribute] Attribute `init` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2210:58: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2220:66: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2231:56: warning[possibly-missing-attribute] Attribute `default` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2241:62: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2252:14: warning[possibly-missing-attribute] Attribute `default` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2254:16: warning[possibly-missing-attribute] Attribute `kw_only` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2266:62: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2274:16: warning[possibly-missing-attribute] Attribute `kw_only` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2281:54: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2299:62: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2315:52: warning[possibly-missing-attribute] Attribute `default` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2317:16: warning[possibly-missing-attribute] Attribute `kw_only` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2329:62: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2335:12: warning[possibly-missing-attribute] Attribute `init` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2336:16: warning[possibly-missing-attribute] Attribute `type` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2337:41: warning[possibly-missing-attribute] Attribute `type` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2373:33: warning[possibly-missing-attribute] Attribute `name` may be missing on object of type `Attribute | Unknown`
- src/attr/_make.py:2373:60: warning[possibly-missing-attribute] Attribute `init` may be missing on object of type `Attribute | Unknown`
+ src/attr/_make.py:1609:29: error[unresolved-attribute] Object of type `Attribute` has no attribute `hash`
+ src/attr/_make.py:1609:48: error[unresolved-attribute] Object of type `Attribute` has no attribute `hash`
+ src/attr/_make.py:1609:67: error[unresolved-attribute] Object of type `Attribute` has no attribute `eq`
+ src/attr/_make.py:1647:16: error[unresolved-attribute] Object of type `Attribute` has no attribute `eq_key`
+ src/attr/_make.py:1648:32: error[unresolved-attribute] Object of type `Attribute` has no attribute `name`
+ src/attr/_make.py:1649:35: error[unresolved-attribute] Object of type `Attribute` has no attribute `eq_key`
+ src/attr/_make.py:1651:57: error[unresolved-attribute] Object of type `Attribute` has no attribute `name`
+ src/attr/_make.py:1654:62: error[unresolved-attribute] Object of type `Attribute` has no attribute `name`
+ src/attr/_make.py:2189:12: error[unresolved-attribute] Object of type `Attribute` has no attribute `validator`
+ src/attr/_make.py:2192:21: error[unresolved-attribute] Object of type `Attribute` has no attribute `name`
+ src/attr/_make.py:2193:26: error[unresolved-attribute] Object of type `Attribute` has no attribute `on_setattr`
+ src/attr/_make.py:2194:13: error[unresolved-attribute] Object of type `Attribute` has no attribute `on_setattr`
+ src/attr/_make.py:2198:20: error[unresolved-attribute] Object of type `Attribute` has no attribute `alias`
+ src/attr/_make.py:2200:34: error[unresolved-attribute] Object of type `Attribute` has no attribute `default`
+ src/attr/_make.py:2201:48: error[unresolved-attribute] Object of type `Attribute` has no attribute `default`
+ src/attr/_make.py:2203:12: error[unresolved-attribute] Object of type `Attribute` has no attribute `converter`
+ src/attr/_make.py:2203:55: error[unresolved-attribute] Object of type `Attribute` has no attribute `converter`
+ src/attr/_make.py:2204:35: error[unresolved-attribute] Object of type `Attribute` has no attribute `converter`
+ src/attr/_make.py:2206:25: error[unresolved-attribute] Object of type `Attribute` has no attribute `converter`
+ src/attr/_make.py:2208:12: error[unresolved-attribute] Object of type `Attribute` has no attribute `init`
+ src/attr/_make.py:2210:58: error[unresolved-attribute] Object of type `Attribute` has no attribute `name`
+ src/attr/_make.py:2220:66: error[unresolved-attribute] Object of type `Attribute` has no attribute `name`
+ src/attr/_make.py:2231:56: error[unresolved-attribute] Object of type `Attribute` has no attribute `default`
+ src/attr/_make.py:2241:62: error[unresolved-attribute] Object of type `Attribute` has no attribute `name`
+ src/attr/_make.py:2252:14: error[unresolved-attribute] Object of type `Attribute` has no attribute `default`
+ src/attr/_make.py:2254:16: error[unresolved-attribute] Object of type `Attribute` has no attribute `kw_only`
+ src/attr/_make.py:2266:62: error[unresolved-attribute] Object of type `Attribute` has no attribute `name`
+ src/attr/_make.py:2274:16: error[unresolved-attribute] Object of type `Attribute` has no attribute `kw_only`
+ src/attr/_make.py:2281:54: error[unresolved-attribute] Object of type `Attribute` has no attribute `name`
+ src/attr/_make.py:2299:62: error[unresolved-attribute] Object of type `Attribute` has no attribute `name`
+ src/attr/_make.py:2315:52: error[unresolved-attribute] Object of type `Attribute` has no attribute `default`
+ src/attr/_make.py:2317:16: error[unresolved-attribute] Object of type `Attribute` has no attribute `kw_only`
+ src/attr/_make.py:2329:62: error[unresolved-attribute] Object of type `Attribute` has no attribute `name`
+ src/attr/_make.py:2335:12: error[unresolved-attribute] Object of type `Attribute` has no attribute `init`
+ src/attr/_make.py:2336:16: error[unresolved-attribute] Object of type `Attribute` has no attribute `type`
+ src/attr/_make.py:2337:41: error[unresolved-attribute] Object of type `Attribute` has no attribute `type`
+ src/attr/_make.py:2373:33: error[unresolved-attribute] Object of type `Attribute` has no attribute `name`
+ src/attr/_make.py:2373:60: error[unresolved-attribute] Object of type `Attribute` has no attribute `init`
+ src/attr/_make.py:2641:13: error[invalid-assignment] Object of type `type` is not assignable to `<class 'Attribute'>`
+ src/attr/_make.py:3038:11: error[invalid-assignment] Object of type `type` is not assignable to `<class 'Factory'>`
+ src/attr/_make.py:3157:13: error[invalid-assignment] Object of type `type` is not assignable to `<class 'Converter'>`
+ src/attr/_make.py:3278:18: error[not-iterable] Object of type `Unknown | _CountingAttr` may not be iterable
+ src/attr/_version_info.py:86:16: error[unsupported-operator] Operator `<` is not supported between objects of type `list[Unknown] | @Todo | tuple[Unknown, ...]` and `Unknown | tuple[Unknown, ...]`
+ src/attr/validators.py:98:34: error[invalid-argument-type] Argument to function `isinstance` is incorrect: Expected `type | tuple[Divergent, ...]`, found `Unknown | _CountingAttr`
+ src/attr/validators.py:137:16: error[call-non-callable] Object of type `_CountingAttr` is not callable
+ src/attr/validators.py:138:53: warning[possibly-missing-attribute] Attribute `pattern` may be missing on object of type `Unknown | _CountingAttr`
+ src/attr/validators.py:206:9: error[call-non-callable] Object of type `_CountingAttr` is not callable
+ src/attr/validators.py:240:26: error[unsupported-operator] Operator `in` is not supported between objects of type `Unknown` and `Unknown | _CountingAttr`
+ src/attr/validators.py:342:13: error[call-non-callable] Object of type `_CountingAttr` is not callable
+ src/attr/validators.py:345:13: error[call-non-callable] Object of type `_CountingAttr` is not callable
+ src/attr/validators.py:396:13: error[call-non-callable] Object of type `_CountingAttr` is not callable
+ src/attr/validators.py:400:17: error[call-non-callable] Object of type `_CountingAttr` is not callable
+ src/attr/validators.py:402:17: error[call-non-callable] Object of type `_CountingAttr` is not callable
+ src/attr/validators.py:468:16: error[call-non-callable] Object of type `_CountingAttr` is not callable
+ src/attr/validators.py:544:12: error[unsupported-operator] Operator `>` is not supported between objects of type `int` and `Unknown | _CountingAttr`
+ src/attr/validators.py:573:12: error[unsupported-operator] Operator `<` is not supported between objects of type `int` and `Unknown | _CountingAttr`
+ src/attr/validators.py:602:34: error[invalid-argument-type] Argument to function `issubclass` is incorrect: Expected `type | tuple[Divergent, ...]`, found `Unknown | _CountingAttr`
+ src/attr/validators.py:650:13: error[call-non-callable] Object of type `_CountingAttr` is not callable
+ src/attr/validators.py:651:16: error[invalid-exception-caught] Invalid object caught in an exception handler: Object has type `Unknown | _CountingAttr`
+ src/attr/validators.py:655:17: warning[possibly-missing-attribute] Attribute `format` may be missing on object of type `Unknown | _CountingAttr`
+ src/attr/validators.py:710:18: error[not-iterable] Object of type `Unknown | _CountingAttr` may not be iterable
+ tests/test_make.py:1365:16: warning[possibly-missing-attribute] Attribute `__attrs_attrs__` may be missing on object of type `Unknown | type`
+ tests/test_make.py:1380:16: warning[possibly-missing-attribute] Attribute `__attrs_attrs__` may be missing on object of type `Unknown | type`
+ tests/test_make.py:1468:30: warning[possibly-missing-attribute] Attribute `echo` may be missing on object of type `Unknown | type`
+ tests/test_make.py:1487:25: warning[possibly-missing-attribute] Attribute `__attrs_attrs__` may be missing on object of type `Unknown | type`
+ tests/test_make.py:3051:30: warning[possibly-missing-attribute] Attribute `__match_args__` may be missing on object of type `Unknown | type`
+ tests/test_make.py:3057:22: warning[possibly-missing-attribute] Attribute `__match_args__` may be missing on object of type `Unknown | type`
+ tests/test_make.py:3060:26: warning[possibly-missing-attribute] Attribute `__match_args__` may be missing on object of type `Unknown | type`
- Found 616 diagnostics
+ Found 649 diagnostics

parso (https://github.com/davidhalter/parso)
+ parso/__init__.py:58:26: error[invalid-argument-type] Argument to bound method `parse` is incorrect: Expected `str | bytes`, found `Unknown | None`
- parso/grammar.py:163:27: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
+ parso/grammar.py:199:16: warning[possibly-missing-attribute] Attribute `walk` may be missing on object of type `Unknown | None | Normalizer`
+ parso/grammar.py:203:9: warning[possibly-missing-attribute] Attribute `walk` may be missing on object of type `Unknown | None | Normalizer`
+ parso/grammar.py:204:16: warning[possibly-missing-attribute] Attribute `issues` may be missing on object of type `Unknown | None | Normalizer`
+ parso/pgen2/grammar_parser.py:106:20: error[not-iterable] Object of type `None` is not iterable
+ parso/python/diff.py:423:17: error[not-subscriptable] Cannot subscript object of type `None` with no `__getitem__` method
+ parso/python/diff.py:621:16: warning[possibly-missing-attribute] Attribute `tree_node` may be missing on object of type `Unknown | None`
+ parso/python/diff.py:622:9: warning[possibly-missing-attribute] Attribute `add_tree_nodes` may be missing on object of type `Unknown | None`
+ parso/python/errors.py:783:12: warning[possibly-missing-attribute] Attribute `type` may be missing on object of type `Unknown | None`
+ parso/python/errors.py:784:26: warning[possibly-missing-attribute] Attribute `type` may be missing on object of type `Unknown | None`
+ parso/python/errors.py:784:54: warning[possibly-missing-attribute] Attribute `children` may be missing on object of type `Unknown | None`
+ parso/python/errors.py:1166:20: warning[possibly-missing-attribute] Attribute `type` may be missing on object of type `Unknown | None`
+ parso/python/errors.py:1167:34: warning[possibly-missing-attribute] Attribute `type` may be missing on object of type `Unknown | None`
+ parso/python/errors.py:1167:62: warning[possibly-missing-attribute] Attribute `children` may be missing on object of type `Unknown | None`
- parso/python/pep8.py:362:17: warning[possibly-missing-attribute] Attribute `type` may be missing on object of type `Unknown | IndentationNode | None`
+ parso/python/pep8.py:362:17: warning[possibly-missing-attribute] Attribute `type` may be missing on object of type `Unknown | None | IndentationNode`
- parso/python/pep8.py:363:37: warning[possibly-missing-attribute] Attribute `parent` may be missing on object of type `Unknown | IndentationNode | None`
+ parso/python/pep8.py:363:37: warning[possibly-missing-attribute] Attribute `parent` may be missing on object of type `Unknown | None | IndentationNode`
- parso/python/tokenize.py:109:9: error[invalid-assignment] Invalid subscript assignment with key of type `tuple[Unknown, ...]` and value of type `Unknown` on object of type `dict[PythonVersionInfo, TokenCollection]`
+ parso/python/tokenize.py:109:9: error[invalid-assignment] Invalid subscript assignment with key of type `tuple[Unknown, ...]` and value of type `TokenCollection` on object of type `dict[PythonVersionInfo, TokenCollection]`
+ parso/python/tokenize.py:588:31: error[invalid-assignment] Object of type `Pattern[Unknown] | None` is not assignable to `Pattern[Unknown]`
+ parso/python/tree.py:135:21: warning[possibly-missing-attribute] Attribute `token_type` may be missing on object of type `(Unknown & ~None) | NodeOrLeaf`
+ parso/python/tree.py:1129:20: warning[possibly-missing-attribute] Attribute `children` may be missing on object of type `Unknown | NodeOrLeaf`
+ parso/python/tree.py:1130:24: warning[possibly-missing-attribute] Attribute `children` may be missing on object of type `Unknown | NodeOrLeaf`
+ parso/python/tree.py:1131:26: warning[possibly-missing-attribute] Attribute `children` may be missing on object of type `Unknown | NodeOrLeaf`
+ parso/python/tree.py:1149:20: warning[possibly-missing-attribute] Attribute `children` may be missing on object of type `Unknown | NodeOrLeaf`
+ parso/tree.py:447:16: warning[possibly-missing-attribute] Attribute `replace` may be missing on object of type `Unknown | None`
- Found 199 diagnostics
+ Found 219 diagnostics

kornia (https://github.com/kornia/kornia)
+ kornia/feature/dedode/transformer/dinov2.py:317:30: error[invalid-argument-type] Method `__getitem__` of type `Overload[(i: SupportsIndex, /) -> Unknown, (s: slice[Any, Any, Any], /) -> list[Unknown]]` cannot be called with key of type `Literal["x_norm_clstoken"]` on object of type `list[Unknown]`
- Found 758 diagnostics
+ Found 759 diagnostics

pip (https://github.com/pypa/pip)
+ src/pip/_internal/cli/cmdoptions.py:123:51: error[invalid-argument-type] Argument to function `get_file_content` is incorrect: Expected `PipSession`, found `Self@__enter__ | Unknown`
+ src/pip/_internal/commands/index.py:119:17: error[invalid-argument-type] Argument to bound method `_build_package_finder` is incorrect: Expected `PipSession`, found `Self@__enter__ | Unknown`
+ src/pip/_internal/commands/list.py:245:58: error[invalid-argument-type] Argument to bound method `_build_package_finder` is incorrect: Expected `PipSession`, found `Self@__enter__ | Unknown`
+ src/pip/_internal/index/collector.py:311:9: error[invalid-argument-type] Argument is incorrect: Expected `bytes`, found `(Unknown & ~Literal[False]) | None | (bytes & ~AlwaysFalsy) | Literal[b""]`
- src/pip/_vendor/cachecontrol/adapter.py:162:39: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- src/pip/_vendor/cachecontrol/serialize.py:35:46: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
+ src/pip/_vendor/cachecontrol/serialize.py:36:45: error[invalid-argument-type] Argument to function `len` is incorrect: Expected `Sized`, found `None | bytes | Unknown`
+ src/pip/_vendor/cachecontrol/serialize.py:146:47: error[invalid-argument-type] Argument to bound method `prepare_response` is incorrect: Expected `Mapping[str, Any]`, found `int | Unknown | None | ... omitted 9 union elements`
+ src/pip/_vendor/distlib/compat.py:1127:22: error[call-non-callable] Object of type `ModuleType` is not callable
+ src/pip/_vendor/distlib/resources.py:196:33: error[not-iterable] Object of type `Unknown | Self@__get__` may not be iterable
+ src/pip/_vendor/distlib/resources.py:196:33: warning[possibly-missing-attribute] Attribute `resources` may be missing on object of type `Unknown | ResourceContainer | Resource`
+ src/pip/_vendor/distlib/resources.py:202:28: warning[possibly-missing-attribute] Attribute `is_container` may be missing on object of type `None | ResourceContainer | Resource | Unknown`
+ src/pip/_vendor/msgpack/fallback.py:540:29: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[SupportsIndex] | SupportsIndex | SupportsBytes | Buffer`, found `None | Unknown | int | bytearray`
+ src/pip/_vendor/msgpack/fallback.py:542:23: warning[possibly-missing-attribute] Attribute `decode` may be missing on object of type `None | Unknown | int | bytearray`
+ src/pip/_vendor/msgpack/fallback.py:545:26: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[SupportsIndex] | SupportsIndex | SupportsBytes | Buffer`, found `None | Unknown | int | bytearray`
+ src/pip/_vendor/msgpack/fallback.py:548:49: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[SupportsIndex] | SupportsIndex | SupportsBytes | Buffer`, found `None | Unknown | int | bytearray`
+ src/pip/_vendor/msgpack/fallback.py:558:48: error[invalid-argument-type] Argument to function `__new__` is incorrect: Expected `Iterable[SupportsIndex] | SupportsIndex | SupportsBytes | Buffer`, found `None | Unknown | int | bytearray`
+ src/pip/_vendor/pkg_resources/__init__.py:2308:28: error[invalid-argument-type] Argument to function `distributions_from_metadata` is incorrect: Expected `str`, found `str | bytes`
+ src/pip/_vendor/pkg_resources/__init__.py:2308:28: error[invalid-argument-type] Argument to function `find_distributions` is incorrect: Expected `str`, found `str | bytes`
+ src/pip/_vendor/pkg_resources/__init__.py:2828:13: error[invalid-assignment] Invalid subscript assignment with key of type `Unknown | str` and value of type `Self@parse | Unknown` on object of type `dict[str, Self@parse_group]`
+ src/pip/_vendor/pkg_resources/__init__.py:2852:13: error[invalid-assignment] Invalid subscript assignment with key of type `str` and value of type `dict[str, Self@parse_group] | Unknown` on object of type `dict[str, dict[str, Self@parse_map]]`
+ src/pip/_vendor/pkg_resources/__init__.py:2941:16: error[unsupported-operator] Operator `<` is not supported between two objects of type `tuple[Unknown | Version, Unknown | int, Unknown | str, Unknown | str | None, (Unknown & ~AlwaysFalsy) | (str & ~AlwaysFalsy) | Literal[""], (Unknown & ~AlwaysFalsy) | (str & ~AlwaysFalsy) | Literal[""]]`
+ src/pip/_vendor/pkg_resources/__init__.py:2944:16: error[unsupported-operator] Operator `<=` is not supported between two objects of type `tuple[Unknown | Version, Unknown | int, Unknown | str, Unknown | str | None, (Unknown & ~AlwaysFalsy) | (str & ~AlwaysFalsy) | Literal[""], (Unknown & ~AlwaysFalsy) | (str & ~AlwaysFalsy) | Literal[""]]`
+ src/pip/_vendor/pkg_resources/__init__.py:2947:16: error[unsupported-operator] Operator `>` is not supported between two objects of type `tuple[Unknown | Version, Unknown | int, Unknown | str, Unknown | str | None, (Unknown & ~AlwaysFalsy) | (str & ~AlwaysFalsy) | Literal[""], (Unknown & ~AlwaysFalsy) | (str & ~AlwaysFalsy) | Literal[""]]`
+ src/pip/_vendor/pkg_resources/__init__.py:2950:16: error[unsupported-operator] Operator `>=` is not supported between two objects of type `tuple[Unknown | Version, Unknown | int, Unknown | str, Unknown | str | None, (Unknown & ~AlwaysFalsy) | (str & ~AlwaysFalsy) | Literal[""], (Unknown & ~AlwaysFalsy) | (str & ~AlwaysFalsy) | Literal[""]]`
- src/pip/_vendor/pkg_resources/__init__.py:3466:40: error[invalid-argument-type] Argument to bound method `contains` is incorrect: Expected `Version | str`, found `(str & ~Distribution) | (tuple[str, ...] & ~Distribution) | Unknown`
+ src/pip/_vendor/pkg_resources/__init__.py:3466:40: error[invalid-argument-type] Argument to bound method `contains` is incorrect: Expected `Version | str`, found `str | (tuple[str, ...] & ~Distribution) | Unknown`
+ src/pip/_vendor/pygments/lexers/python.py:362:42: error[invalid-argument-type] Argument to function `fstring_rules` is incorrect: Expected `PythonLexer`, found `Any | _TokenType`
+ src/pip/_vendor/pygments/lexers/python.py:363:42: error[invalid-argument-type] Argument to function `fstring_rules` is incorrect: Expected `PythonLexer`, found `Any | _TokenType`
+ src/pip/_vendor/pygments/lexers/python.py:364:45: error[invalid-argument-type] Argument to function `innerstring_rules` is incorrect: Expected `PythonLexer`, found `Any | _TokenType`
+ src/pip/_vendor/pygments/lexers/python.py:365:45: error[invalid-argument-type] Argument to function `innerstring_rules` is incorrect: Expected `PythonLexer`, found `Any | _TokenType`
+ src/pip/_vendor/pygments/lexers/python.py:611:45: error[invalid-argument-type] Argument to function `innerstring_rules` is incorrect: Expected `Python2Lexer`, found `Any | _TokenType`
+ src/pip/_vendor/pygments/lexers/python.py:612:45: error[invalid-argument-type] Argument to function `innerstring_rules` is incorrect: Expected `Python2Lexer`, found `Any | _TokenType`
+ src/pip/_vendor/pygments/sphinxext.py:108:26: warning[possibly-missing-attribute] Attribute `filenames` may be missing on object of type `Unknown | None`
+ src/pip/_vendor/pygments/sphinxext.py:108:48: warning[possibly-missing-attribute] Attribute `alias_filenames` may be missing on object of type `Unknown | None`
+ src/pip/_vendor/pygments/sphinxext.py:111:46: warning[possibly-missing-attribute] Attribute `url` may be missing on object of type `Unknown | None`
+ src/pip/_vendor/requests/models.py:121:26: error[not-iterable] Object of type `None | list[Unknown]` may not be iterable
+ src/pip/_vendor/requests/models.py:155:27: error[not-iterable] Object of type `None | list[Unknown]` may not be iterable
+ src/pip/_vendor/requests/models.py:173:21: error[not-iterable] Object of type `None | list[Unknown]` may not be iterable
+ src/pip/_vendor/requests/models.py:602:17: error[call-non-callable] Object of type `tuple[str, str]` is not callable
- src/pip/_vendor/requests/models.py:935:41: error[invalid-argument-type] Argument to class `str` is incorrect: Expected `str`, found `Unknown | None`
+ src/pip/_vendor/requests/models.py:935:41: error[invalid-argument-type] Argument to class `str` is incorrect: Expected `str`, found `Unknown | None | Literal["utf-8"]`
+ src/pip/_vendor/requests/sessions.py:80:5: error[no-matching-overload] No overload of bound method `update` matches arguments
+ src/pip/_vendor/requests/utils.py:615:31: error[invalid-argument-type] Argument to class `str` is incorrect: Expected `str`, found `None | Unknown | Literal["ISO-8859-1", "utf-8"]`
+ src/pip/_vendor/rich/syntax.py:167:27: error[unsupported-operator] Operator `+` is not supported between objects of type `Literal["#"]` and `(Unknown & ~AlwaysFalsy) | (str & ~AlwaysFalsy) | Literal[True]`
+ src/pip/_vendor/rich/syntax.py:168:29: error[unsupported-operator] Operator `+` is not supported between objects of type `Literal["#"]` and `(Unknown & ~AlwaysFalsy) | (str & ~AlwaysFalsy) | Literal[True]`
+ src/pip/_vendor/rich/syntax.py:169:21: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `bool | None`, found `Unknown | str | None | bool`
+ src/pip/_vendor/rich/syntax.py:170:21: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `bool | None`, found `Unknown | str | None | bool`
+ src/pip/_vendor/rich/syntax.py:171:21: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `bool | None`, found `Unknown | str | None | bool`
- src/pip/_vendor/urllib3/connectionpool.py:785:21: warning[possibly-missing-attribute] Attribute `proxy` may be missing on object of type `None | Unknown`
+ src/pip/_vendor/urllib3/connectionpool.py:785:21: warning[possibly-missing-attribute] Attribute `proxy` may be missing on object of type `None | Unknown | HTTPConnection`
- src/pip/_vendor/urllib3/connectionpool.py:786:21: warning[possibly-missing-attribute] Attribute `proxy` may be missing on object of type `None | Unknown`
+ src/pip/_vendor/urllib3/connectionpool.py:786:21: warning[possibly-missing-attribute] Attribute `proxy` may be missing on object of type `None | Unknown | HTTPConnection`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:136:5: warning[possibly-missing-attribute] Attribute `SecItemImport` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:146:5: warning[possibly-missing-attribute] Attribute `SecItemImport` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:148:5: warning[possibly-missing-attribute] Attribute `SecCertificateGetTypeID` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:149:5: warning[possibly-missing-attribute] Attribute `SecCertificateGetTypeID` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:151:5: warning[possibly-missing-attribute] Attribute `SecIdentityGetTypeID` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:152:5: warning[possibly-missing-attribute] Attribute `SecIdentityGetTypeID` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:154:5: warning[possibly-missing-attribute] Attribute `SecKeyGetTypeID` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:155:5: warning[possibly-missing-attribute] Attribute `SecKeyGetTypeID` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:157:5: warning[possibly-missing-attribute] Attribute `SecCertificateCreateWithData` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:158:5: warning[possibly-missing-attribute] Attribute `SecCertificateCreateWithData` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:160:5: warning[possibly-missing-attribute] Attribute `SecCertificateCopyData` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:161:5: warning[possibly-missing-attribute] Attribute `SecCertificateCopyData` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:163:5: warning[possibly-missing-attribute] Attribute `SecCopyErrorMessageString` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:164:5: warning[possibly-missing-attribute] Attribute `SecCopyErrorMessageString` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:166:5: warning[possibly-missing-attribute] Attribute `SecIdentityCreateWithCertificate` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:171:5: warning[possibly-missing-attribute] Attribute `SecIdentityCreateWithCertificate` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:173:5: warning[possibly-missing-attribute] Attribute `SecKeychainCreate` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:181:5: warning[possibly-missing-attribute] Attribute `SecKeychainCreate` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:183:5: warning[possibly-missing-attribute] Attribute `SecKeychainDelete` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:184:5: warning[possibly-missing-attribute] Attribute `SecKeychainDelete` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:186:5: warning[possibly-missing-attribute] Attribute `SecPKCS12Import` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:191:5: warning[possibly-missing-attribute] Attribute `SecPKCS12Import` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:198:5: warning[possibly-missing-attribute] Attribute `SSLSetIOFuncs` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:199:5: warning[possibly-missing-attribute] Attribute `SSLSetIOFuncs` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:201:5: warning[possibly-missing-attribute] Attribute `SSLSetPeerID` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:202:5: warning[possibly-missing-attribute] Attribute `SSLSetPeerID` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:204:5: warning[possibly-missing-attribute] Attribute `SSLSetCertificate` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:205:5: warning[possibly-missing-attribute] Attribute `SSLSetCertificate` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:207:5: warning[possibly-missing-attribute] Attribute `SSLSetCertificateAuthorities` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:208:5: warning[possibly-missing-attribute] Attribute `SSLSetCertificateAuthorities` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:210:5: warning[possibly-missing-attribute] Attribute `SSLSetConnection` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:211:5: warning[possibly-missing-attribute] Attribute `SSLSetConnection` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:213:5: warning[possibly-missing-attribute] Attribute `SSLSetPeerDomainName` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:214:5: warning[possibly-missing-attribute] Attribute `SSLSetPeerDomainName` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:216:5: warning[possibly-missing-attribute] Attribute `SSLHandshake` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:217:5: warning[possibly-missing-attribute] Attribute `SSLHandshake` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:219:5: warning[possibly-missing-attribute] Attribute `SSLRead` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:220:5: warning[possibly-missing-attribute] Attribute `SSLRead` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:222:5: warning[possibly-missing-attribute] Attribute `SSLWrite` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:223:5: warning[possibly-missing-attribute] Attribute `SSLWrite` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:225:5: warning[possibly-missing-attribute] Attribute `SSLClose` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:226:5: warning[possibly-missing-attribute] Attribute `SSLClose` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:228:5: warning[possibly-missing-attribute] Attribute `SSLGetNumberSupportedCiphers` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:229:5: warning[possibly-missing-attribute] Attribute `SSLGetNumberSupportedCiphers` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:231:5: warning[possibly-missing-attribute] Attribute `SSLGetSupportedCiphers` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:236:5: warning[possibly-missing-attribute] Attribute `SSLGetSupportedCiphers` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:238:5: warning[possibly-missing-attribute] Attribute `SSLSetEnabledCiphers` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:243:5: warning[possibly-missing-attribute] Attribute `SSLSetEnabledCiphers` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:245:5: error[unresolved-attribute] Unresolved attribute `argtype` on type `_NamedFuncPointer`.
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:245:5: warning[possibly-missing-attribute] Attribute `SSLGetNumberEnabledCiphers` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:246:5: warning[possibly-missing-attribute] Attribute `SSLGetNumberEnabledCiphers` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:248:5: warning[possibly-missing-attribute] Attribute `SSLGetEnabledCiphers` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:253:5: warning[possibly-missing-attribute] Attribute `SSLGetEnabledCiphers` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:255:5: warning[possibly-missing-attribute] Attribute `SSLGetNegotiatedCipher` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:256:5: warning[possibly-missing-attribute] Attribute `SSLGetNegotiatedCipher` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:258:5: warning[possibly-missing-attribute] Attribute `SSLGetNegotiatedProtocolVersion` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:262:5: warning[possibly-missing-attribute] Attribute `SSLGetNegotiatedProtocolVersion` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:264:5: warning[possibly-missing-attribute] Attribute `SSLCopyPeerTrust` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:265:5: warning[possibly-missing-attribute] Attribute `SSLCopyPeerTrust` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:267:5: warning[possibly-missing-attribute] Attribute `SecTrustSetAnchorCertificates` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:268:5: warning[possibly-missing-attribute] Attribute `SecTrustSetAnchorCertificates` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:270:5: error[unresolved-attribute] Unresolved attribute `argstypes` on type `_NamedFuncPointer`.
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:270:5: warning[possibly-missing-attribute] Attribute `SecTrustSetAnchorCertificatesOnly` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:271:5: warning[possibly-missing-attribute] Attribute `SecTrustSetAnchorCertificatesOnly` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:273:5: warning[possibly-missing-attribute] Attribute `SecTrustEvaluate` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:274:5: warning[possibly-missing-attribute] Attribute `SecTrustEvaluate` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:276:5: warning[possibly-missing-attribute] Attribute `SecTrustGetCertificateCount` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:277:5: warning[possibly-missing-attribute] Attribute `SecTrustGetCertificateCount` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:279:5: warning[possibly-missing-attribute] Attribute `SecTrustGetCertificateAtIndex` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:280:5: warning[possibly-missing-attribute] Attribute `SecTrustGetCertificateAtIndex` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:282:5: warning[possibly-missing-attribute] Attribute `SSLCreateContext` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:287:5: warning[possibly-missing-attribute] Attribute `SSLCreateContext` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:289:5: warning[possibly-missing-attribute] Attribute `SSLSetSessionOption` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:290:5: warning[possibly-missing-attribute] Attribute `SSLSetSessionOption` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:292:5: warning[possibly-missing-attribute] Attribute `SSLSetProtocolVersionMin` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:293:5: warning[possibly-missing-attribute] Attribute `SSLSetProtocolVersionMin` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:295:5: warning[possibly-missing-attribute] Attribute `SSLSetProtocolVersionMax` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:296:5: warning[possibly-missing-attribute] Attribute `SSLSetProtocolVersionMax` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:299:9: warning[possibly-missing-attribute] Attribute `SSLSetALPNProtocols` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:300:9: warning[possibly-missing-attribute] Attribute `SSLSetALPNProtocols` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:305:5: warning[possibly-missing-attribute] Attribute `SecCopyErrorMessageString` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:306:5: warning[possibly-missing-attribute] Attribute `SecCopyErrorMessageString` may be missing on object of type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:308:5: error[invalid-assignment] Object of type `type[_CFunctionType]` is not assignable to attribute `SSLReadFunc` on type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:309:5: error[invalid-assignment] Object of type `type[_CFunctionType]` is not assignable to attribute `SSLWriteFunc` on type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:310:5: error[invalid-assignment] Object of type `type[_Pointer[c_void_p]]` is not assignable to attribute `SSLContextRef` on type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:311:5: error[invalid-assignment] Object of type `<class 'c_uint32'>` is not assignable to attribute `SSLProtocol` on type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:312:5: error[invalid-assignment] Object of type `<class 'c_uint32'>` is not assignable to attribute `SSLCipherSuite` on type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:313:5: error[invalid-assignment] Object of type `type[_Pointer[c_void_p]]` is not assignable to attribute `SecIdentityRef` on type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:314:5: error[invalid-assignment] Object of type `type[_Pointer[c_void_p]]` is not assignable to attribute `SecKeychainRef` on type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:315:5: error[invalid-assignment] Object of type `type[_Pointer[c_void_p]]` is not assignable to attribute `SecTrustRef` on type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:316:5: error[invalid-assignment] Object of type `<class 'c_uint32'>` is not assignable to attribute `SecTrustResultType` on type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:317:5: error[invalid-assignment] Object of type `<class 'c_uint32'>` is not assignable to attribute `SecExternalFormat` on type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:318:5: error[invalid-assignment] Object of type `<class 'c_int32'>` is not assignable to attribute `OSStatus` on type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:320:5: error[invalid-assignment] Object of type `_Pointer[c_void_p]` is not assignable to attribute `kSecImportExportPassphrase` on type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:321:9: error[invalid-argument-type] Argument to bound method `in_dll` is incorrect: Expected `CDLL`, found `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:323:5: error[invalid-assignment] Object of type `_Pointer[c_void_p]` is not assignable to attribute `kSecImportItemIdentity` on type `CDLL | None`
+ src/pip/_vendor/urllib3/contrib/_securetransport/bindings.py:324:9: error[invalid-argument-type] Argument to bound method `in_dll` is 

... (truncated 65012 lines) ...
Memory usage changes were detected when running on open source projects
trio (https://github.com/python-trio/trio)
-     struct metadata = ~10MB
+     struct metadata = ~11MB
-     struct fields = ~11MB
+     struct fields = ~12MB
-     memo fields = ~108MB
+     memo fields = ~113MB

prefect (https://github.com/PrefectHQ/prefect)
-     memo metadata = ~167MB
+     memo metadata = ~176MB

@mtshiba

This comment was marked as resolved.

@AlexWaygood AlexWaygood added the ty Multi-file analysis & type inference label Apr 13, 2025
@sharkdp

This comment was marked as resolved.

@mtshiba
Copy link
Collaborator Author

mtshiba commented Apr 15, 2025

If a function contains a yield expression, i.e. if it is a generator, current type inference is incorrect. But supporting this requires solving another issues, so I will leave it as a TODO for now.

As for return type inference for normal functions, I think the work is completed.

@AlexWaygood AlexWaygood removed their request for review April 15, 2025 17:42
@mtshiba mtshiba force-pushed the infer-return-type branch 4 times, most recently from 3ba99d1 to 35f4a75 Compare May 8, 2025 15:56
@MichaReiser MichaReiser changed the title [red-knot] infer function's return type [ty] infer function's return type May 8, 2025
@mtshiba mtshiba force-pushed the infer-return-type branch from 404c1da to 80f2b5c Compare May 8, 2025 17:35
@carljm
Copy link
Contributor

carljm commented May 9, 2025

Sorry that I haven't gotten around to reviewing this PR yet. There's just been a lot to do, and providing this feature is lower on my priority list than some other features. But I realize that places a burden on you to keep it up to date with (rapidly changing) main branch. But I will try to find time to review it soon.

@mtshiba mtshiba force-pushed the infer-return-type branch from 0a16b46 to 126aef8 Compare May 11, 2025 12:18
@mtshiba mtshiba force-pushed the infer-return-type branch from 91c66c1 to 22e8594 Compare May 11, 2025 12:45
@mtshiba mtshiba force-pushed the infer-return-type branch from 22e8594 to 391ee91 Compare May 11, 2025 12:50
Copy link
Contributor

@carljm carljm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partial review here; plane is landing now so submitting the comments I have. Will come back to this later.

Thank you for working on this, and sorry for the slow review! It's a very useful feature.

@mtshiba
Copy link
Collaborator Author

mtshiba commented Dec 18, 2025

It appears that abnormal memory consumption was occurring during the scipy inspection and ty was killed.

The profiling result seem to suggest that IntersectionBuilder is a hotspot.
In particular, cloning and dropping IntersectionBuilder take a long time and huge amounts of memory.

@mtshiba
Copy link
Collaborator Author

mtshiba commented Dec 18, 2025

Hmm, in fact, this is a result of fixed-point iterations not converging and the intersection type growing without bound?

@mtshiba
Copy link
Collaborator Author

mtshiba commented Dec 18, 2025

The handling of unions in IntersectionBuilder::add_positive_impl seems to exponentially increase the number of intersections, which seems inherently problematic?

@mtshiba
Copy link
Collaborator Author

mtshiba commented Dec 18, 2025

mypy_primer: #17371 (comment)
codspeed: #17371 (comment)
type conformance test: #17371 (comment)
ruff_ecosystem: #17371 (comment)

@carljm
Copy link
Contributor

carljm commented Dec 18, 2025

The handling of unions in IntersectionBuilder::add_positive_impl seems to exponentially increase the number of intersections, which seems inherently problematic?

Yes, it could be problematic, but it's required to keep set-theoretic types in disjunctive normal form, which is valuable, and in most practical cases, unions/intersections don't grow large enough for it to be a problem. We could set some size-maximums with fallback to a less precise type, would have to look at the specific case that causes a blowup. If it's due to fixpoint iteration not converging, then that seems like the key issue to fix.

@mtshiba
Copy link
Collaborator Author

mtshiba commented Dec 18, 2025

Fixed IntersectionBuilder to not have multiple identical InnerIntersectionBuilders.
The pydantic result is interesting. It might be worth breaking out as a separate PR.

@mtshiba
Copy link
Collaborator Author

mtshiba commented Dec 18, 2025

Opened #22055. Thanks to this change, scipy no longer seems to be killed.

@astral-sh-bot
Copy link

astral-sh-bot bot commented Dec 19, 2025

ecosystem-analyzer results

Lint rule Added Removed Changed
unsupported-operator 35,575 0 73
possibly-missing-attribute 15,046 86 339
invalid-argument-type 3,481 82 239
non-subscriptable 2,222 0 0
invalid-assignment 1,638 11 33
not-iterable 1,341 0 8
unresolved-attribute 1,209 12 3
no-matching-overload 728 0 0
call-non-callable 703 2 0
invalid-return-type 363 2 26
too-many-positional-arguments 290 3 0
unknown-argument 146 8 0
unsupported-base 145 0 0
invalid-await 115 0 6
invalid-key 115 0 0
unused-ignore-comment 20 83 0
missing-argument 44 4 0
index-out-of-bounds 43 4 0
parameter-already-assigned 2 19 0
division-by-zero 8 0 0
invalid-context-manager 7 0 0
deprecated 3 2 0
invalid-type-form 2 0 0
possibly-unresolved-reference 0 2 0
invalid-exception-caught 1 0 0
invalid-method-override 1 0 0
Total 63,248 320 727

@mtshiba mtshiba marked this pull request as ready for review December 19, 2025 17:25
@mtshiba mtshiba requested a review from carljm December 19, 2025 17:26
@MichaReiser
Copy link
Member

Given the many new diagnostics, I think we should consider adding a new analysis.<option> to control whether return type inference is on.

I also suggest running the ty-benchmarks on this o get a better sense for the performance impact (note that ty-benchmarks turns off return type inference for all other type checkers that support it for a fair comparison)

if self
.signature_type
.as_bound_method()
.is_none_or(|method| !method.is_init(self.db))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This addresses a pattern that was not considered in #22068, but I'm not sure if this is the best approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ecosystem-analyzer ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Return type inference

5 participants