Skip to content

Conversation

@dcreager
Copy link
Member

@dcreager dcreager commented Nov 20, 2025

This is a first stab at solving astral-sh/ty#500, at least in part, with the old solver. We add a new TypeRelation that lets us opt into using constraint sets to describe when a typevar is assignability to some type, and then use that to calculate a constraint set that describes when two callable types are assignable. If the callable types contain typevars, that constraint set will describe their valid specializations. We can then walk through all of the ways the constraint set can be satisfied, and record a type mapping in the old solver for each one.

@astral-sh-bot
Copy link

astral-sh-bot bot commented Nov 20, 2025

Diagnostic diff on typing conformance tests

Changes were detected when running ty on typing conformance tests
--- old-output.txt	2025-11-26 23:39:34.860924727 +0000
+++ new-output.txt	2025-11-26 23:39:38.241947151 +0000
@@ -1,4 +1,5 @@
 _directives_deprecated_library.py:15:31: error[invalid-return-type] Function always implicitly returns `None`, which is not assignable to return type `int`
+_directives_deprecated_library.py:30:5: error[invalid-overload] Overloaded function `foo` requires at least two overloads
 _directives_deprecated_library.py:30:26: error[invalid-return-type] Function always implicitly returns `None`, which is not assignable to return type `str`
 _directives_deprecated_library.py:36:41: error[invalid-return-type] Function always implicitly returns `None`, which is not assignable to return type `Self@__add__`
 _directives_deprecated_library.py:41:25: error[invalid-return-type] Function always implicitly returns `None`, which is not assignable to return type `int | float`
@@ -166,7 +167,7 @@
 callables_protocol.py:169:7: error[invalid-assignment] Object of type `def cb8_bad1(x: int) -> Any` is not assignable to `Proto8`
 callables_protocol.py:186:5: error[invalid-assignment] Object of type `Literal["str"]` is not assignable to attribute `other_attribute` of type `int`
 callables_protocol.py:187:5: error[unresolved-attribute] Unresolved attribute `xxx` on type `Proto9[P@decorator1, R@decorator1]`.
-callables_protocol.py:197:7: error[unresolved-attribute] Object of type `Proto9[Unknown, Unknown]` has no attribute `other_attribute2`
+callables_protocol.py:197:7: error[unresolved-attribute] Object of type `Proto9[Unknown, str] | Proto9[Unknown, Unknown]` has no attribute `other_attribute2`
 callables_protocol.py:238:8: error[invalid-assignment] Object of type `def cb11_bad1(x: int, y: str, /) -> Any` is not assignable to `Proto11`
 callables_protocol.py:260:8: error[invalid-assignment] Object of type `def cb12_bad1(*args: Any, *, kwarg0: Any) -> None` is not assignable to `Proto12`
 callables_protocol.py:284:27: error[invalid-assignment] Object of type `def cb13_no_default(path: str) -> str` is not assignable to `Proto13_Default`
@@ -248,29 +249,22 @@
 constructors_call_type.py:40:5: error[missing-argument] No arguments provided for required parameters `x`, `y` of function `__new__`
 constructors_call_type.py:50:5: error[missing-argument] No arguments provided for required parameters `x`, `y` of bound method `__init__`
 constructors_call_type.py:59:9: error[too-many-positional-arguments] Too many positional arguments to bound method `__init__`: expected 1, got 2
-constructors_callable.py:36:13: info[revealed-type] Revealed type: `(...) -> Unknown`
-constructors_callable.py:37:1: error[type-assertion-failure] Type `Class1` does not match asserted type `Unknown`
-constructors_callable.py:49:13: info[revealed-type] Revealed type: `(...) -> Unknown`
-constructors_callable.py:50:1: error[type-assertion-failure] Type `Class2` does not match asserted type `Unknown`
+constructors_callable.py:36:13: info[revealed-type] Revealed type: `(...) -> Class1`
+constructors_callable.py:49:13: info[revealed-type] Revealed type: `(...) -> Class2`
 constructors_callable.py:57:42: error[invalid-return-type] Function always implicitly returns `None`, which is not assignable to return type `Self@__new__`
 constructors_callable.py:63:13: info[revealed-type] Revealed type: `(...) -> Unknown`
 constructors_callable.py:64:1: error[type-assertion-failure] Type `Class3` does not match asserted type `Unknown`
 constructors_callable.py:73:33: error[invalid-return-type] Function always implicitly returns `None`, which is not assignable to return type `int`
-constructors_callable.py:77:13: info[revealed-type] Revealed type: `(...) -> Unknown`
-constructors_callable.py:78:1: error[type-assertion-failure] Type `int` does not match asserted type `Unknown`
-constructors_callable.py:97:13: info[revealed-type] Revealed type: `(...) -> Unknown`
-constructors_callable.py:100:5: error[type-assertion-failure] Type `Never` does not match asserted type `Unknown`
-constructors_callable.py:105:5: error[type-assertion-failure] Type `Never` does not match asserted type `Unknown`
-constructors_callable.py:125:13: info[revealed-type] Revealed type: `(...) -> Unknown`
-constructors_callable.py:126:1: error[type-assertion-failure] Type `Class6Proxy` does not match asserted type `Unknown`
+constructors_callable.py:77:13: info[revealed-type] Revealed type: `(...) -> int`
+constructors_callable.py:97:13: info[revealed-type] Revealed type: `(...) -> Never`
+constructors_callable.py:125:13: info[revealed-type] Revealed type: `(...) -> Class6Proxy`
 constructors_callable.py:142:13: info[revealed-type] Revealed type: `(...) -> Unknown`
 constructors_callable.py:162:5: info[revealed-type] Revealed type: `(...) -> Unknown`
 constructors_callable.py:164:1: error[type-assertion-failure] Type `Class7[int]` does not match asserted type `Unknown`
 constructors_callable.py:165:1: error[type-assertion-failure] Type `Class7[str]` does not match asserted type `Unknown`
-constructors_callable.py:182:13: info[revealed-type] Revealed type: `(...) -> Unknown`
-constructors_callable.py:183:1: error[type-assertion-failure] Type `Class8[str]` does not match asserted type `Unknown`
-constructors_callable.py:193:13: info[revealed-type] Revealed type: `(...) -> Unknown`
-constructors_callable.py:194:1: error[type-assertion-failure] Type `Class9` does not match asserted type `Unknown`
+constructors_callable.py:182:13: info[revealed-type] Revealed type: `(...) -> Top[Class8[Unknown]]`
+constructors_callable.py:183:1: error[type-assertion-failure] Type `Class8[str]` does not match asserted type `Top[Class8[Unknown]]`
+constructors_callable.py:193:13: info[revealed-type] Revealed type: `(...) -> Class9`
 dataclasses_descriptors.py:23:62: error[invalid-return-type] Function always implicitly returns `None`, which is not assignable to return type `int | Desc1`
 dataclasses_descriptors.py:50:63: error[invalid-return-type] Function always implicitly returns `None`, which is not assignable to return type `list[T@Desc2] | T@Desc2`
 dataclasses_descriptors.py:66:1: error[type-assertion-failure] Type `int` does not match asserted type `int | Desc2[int]`
@@ -371,11 +365,8 @@
 directives_cast.py:16:13: error[invalid-type-form] Int literals are not allowed in this context in a type expression
 directives_cast.py:17:22: error[too-many-positional-arguments] Too many positional arguments to function `cast`: expected 2, got 3
 directives_deprecated.py:18:44: warning[deprecated] The class `Ham` is deprecated: Use Spam instead
-directives_deprecated.py:24:9: warning[deprecated] The function `norwegian_blue` is deprecated: It is pining for the fjords
-directives_deprecated.py:25:13: warning[deprecated] The function `norwegian_blue` is deprecated: It is pining for the fjords
+directives_deprecated.py:30:13: error[invalid-argument-type] Argument to function `foo` is incorrect: Expected `str`, found `Literal[1]`
 directives_deprecated.py:34:7: warning[deprecated] The class `Ham` is deprecated: Use Spam instead
-directives_deprecated.py:69:1: warning[deprecated] The function `lorem` is deprecated: Deprecated
-directives_deprecated.py:98:7: warning[deprecated] The function `foo` is deprecated: Deprecated
 directives_no_type_check.py:15:14: error[invalid-assignment] Object of type `Literal[""]` is not assignable to `int`
 directives_no_type_check.py:29:7: error[invalid-argument-type] Argument to function `func1` is incorrect: Expected `int`, found `Literal[b"invalid"]`
 directives_no_type_check.py:29:19: error[invalid-argument-type] Argument to function `func1` is incorrect: Expected `str`, found `Literal[b"arguments"]`
@@ -408,7 +399,7 @@
 enums_member_values.py:96:1: error[type-assertion-failure] Type `int` does not match asserted type `Unknown`
 enums_members.py:82:1: error[type-assertion-failure] Type `Unknown` does not match asserted type `Unknown | ((x) -> Unknown)`
 enums_members.py:82:37: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member
-enums_members.py:83:1: error[type-assertion-failure] Type `Unknown` does not match asserted type `Unknown | ((...) -> Unknown)`
+enums_members.py:83:1: error[type-assertion-failure] Type `Unknown` does not match asserted type `Unknown | ((...) -> int)`
 enums_members.py:83:37: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member
 enums_members.py:84:1: error[type-assertion-failure] Type `Unknown` does not match asserted type `property`
 enums_members.py:84:35: error[invalid-type-form] Type arguments for `Literal` must be `None`, a literal value (int, bool, str, or bytes), or an enum member
@@ -1031,4 +1022,4 @@
 typeddicts_usage.py:28:17: error[missing-typed-dict-key] Missing required key 'name' in TypedDict `Movie` constructor
 typeddicts_usage.py:28:18: error[invalid-key] Unknown key "title" for TypedDict `Movie`: Unknown key "title"
 typeddicts_usage.py:40:24: error[invalid-type-form] The special form `typing.TypedDict` is not allowed in type expressions
-Found 1033 diagnostics
+Found 1024 diagnostics

@astral-sh-bot
Copy link

astral-sh-bot bot commented Nov 20, 2025

mypy_primer results

Changes were detected when running on open source projects
pegen (https://github.com/we-like-parsers/pegen)
- src/pegen/grammar_parser.py:160:20: error[invalid-return-type] Return type does not match returned value: expected `tuple[str, str] | None`, found `tuple[str, None]`
+ src/pegen/grammar_parser.py:160:20: error[invalid-return-type] Return type does not match returned value: expected `tuple[str, str] | None`, found `tuple[str | Divergent, None]`

anyio (https://github.com/agronholm/anyio)
- src/anyio/__init__.py:49:29: warning[deprecated] The function `wait_socket_readable` is deprecated: This function is deprecated; use `wait_readable` instead
- src/anyio/__init__.py:50:29: warning[deprecated] The function `wait_socket_writable` is deprecated: This function is deprecated; use `wait_writable` instead
+ src/anyio/_backends/_asyncio.py:2568:50: error[invalid-assignment] Object of type `Future[T_Retval@run_async_from_thread] | Future[_T@run_coroutine_threadsafe]` is not assignable to `Future[T_Retval@run_async_from_thread]`
+ src/anyio/_backends/_asyncio.py:2654:31: warning[redundant-cast] Value is already of type `tuple[Transport, StreamProtocol]`
+ src/anyio/streams/memory.py:60:80: error[invalid-assignment] Object of type `dataclasses.Field[Top[OrderedDict[Unknown, Unknown]]]` is not assignable to `OrderedDict[Event, _MemoryObjectItemReceiver[T_Item@_MemoryObjectStreamState]]`
+ src/anyio/streams/memory.py:63:51: error[invalid-assignment] Object of type `dataclasses.Field[Top[OrderedDict[Unknown, Unknown]]]` is not assignable to `OrderedDict[Event, T_Item@_MemoryObjectStreamState]`
- Found 88 diagnostics
+ Found 90 diagnostics

paroxython (https://github.com/laowantong/paroxython)
+ paroxython/map_taxonomy.py:241:26: error[invalid-assignment] Object of type `defaultdict[Unknown, Top[Counter[Unknown]]]` is not assignable to `dict[TaxonName, Counter[Span]]`
- Found 7 diagnostics
+ Found 8 diagnostics

pytest-robotframework (https://github.com/detachhead/pytest-robotframework)
+ pytest_robotframework/__init__.py:326:9: error[invalid-overload] Overloaded function `__call__` requires at least two overloads
+ pytest_robotframework/__init__.py:472:5: error[invalid-overload] Overloaded function `keyword` requires at least two overloads
+ pytest_robotframework/__init__.py:525:12: error[missing-argument] No argument provided for required parameter `fn` of function `keyword`
+ pytest_robotframework/__init__.py:526:9: error[unknown-argument] Argument `name` does not match any known parameter of function `keyword`
+ pytest_robotframework/__init__.py:527:9: error[unknown-argument] Argument `tags` does not match any known parameter of function `keyword`
+ pytest_robotframework/__init__.py:528:9: error[unknown-argument] Argument `module` does not match any known parameter of function `keyword`
+ pytest_robotframework/__init__.py:529:9: error[unknown-argument] Argument `wrap_context_manager` does not match any known parameter of function `keyword`
+ pytest_robotframework/__init__.py:530:9: error[unknown-argument] Argument `max_argument_length_in_log` does not match any known parameter of function `keyword`
+ pytest_robotframework/__init__.py:599:9: error[missing-argument] No argument provided for required parameter `fn` of function `keyword`
+ pytest_robotframework/__init__.py:599:9: error[no-matching-overload] No overload of function `keyword` matches arguments
+ pytest_robotframework/__init__.py:599:9: error[no-matching-overload] No overload of function `keyword` matches arguments
+ pytest_robotframework/__init__.py:599:9: error[no-matching-overload] No overload of function `keyword` matches arguments
+ pytest_robotframework/__init__.py:599:17: error[unknown-argument] Argument `name` does not match any known parameter of function `keyword`
+ pytest_robotframework/__init__.py:599:28: error[unknown-argument] Argument `tags` does not match any known parameter of function `keyword`
+ pytest_robotframework/__init__.py:599:39: error[unknown-argument] Argument `module` does not match any known parameter of function `keyword`
+ pytest_robotframework/__init__.py:599:54: error[unknown-argument] Argument `wrap_context_manager` does not match any known parameter of function `keyword`
+ tests/fixtures/test_python/test_keyword_decorator_args.py:6:2: error[missing-argument] No argument provided for required parameter `fn` of function `keyword`
+ tests/fixtures/test_python/test_keyword_decorator_args.py:6:10: error[unknown-argument] Argument `max_argument_length_in_log` does not match any known parameter of function `keyword`
+ tests/fixtures/test_python/test_keyword_decorator_context_manager_that_doesnt_suppress.py:14:2: error[missing-argument] No argument provided for required parameter `fn` of function `keyword`
+ tests/fixtures/test_python/test_keyword_decorator_context_manager_that_doesnt_suppress.py:14:10: error[unknown-argument] Argument `wrap_context_manager` does not match any known parameter of function `keyword`
+ tests/fixtures/test_python/test_keyword_decorator_context_manager_that_raises_in_body_and_exit.py:14:2: error[missing-argument] No argument provided for required parameter `fn` of function `keyword`
+ tests/fixtures/test_python/test_keyword_decorator_context_manager_that_raises_in_body_and_exit.py:14:10: error[unknown-argument] Argument `wrap_context_manager` does not match any known parameter of function `keyword`
+ tests/fixtures/test_python/test_keyword_decorator_context_manager_that_raises_in_exit.py:14:2: error[missing-argument] No argument provided for required parameter `fn` of function `keyword`
+ tests/fixtures/test_python/test_keyword_decorator_context_manager_that_raises_in_exit.py:14:10: error[unknown-argument] Argument `wrap_context_manager` does not match any known parameter of function `keyword`
+ tests/fixtures/test_python/test_keyword_decorator_custom_name_and_tags.py:6:2: error[missing-argument] No argument provided for required parameter `fn` of function `keyword`
+ tests/fixtures/test_python/test_keyword_decorator_custom_name_and_tags.py:6:10: error[unknown-argument] Argument `name` does not match any known parameter of function `keyword`
+ tests/fixtures/test_python/test_keyword_decorator_custom_name_and_tags.py:6:26: error[unknown-argument] Argument `tags` does not match any known parameter of function `keyword`
+ tests/fixtures/test_python/test_keyword_decorator_returns_context_manager_that_isnt_used.py:14:2: error[missing-argument] No argument provided for required parameter `fn` of function `keyword`
+ tests/fixtures/test_python/test_keyword_decorator_returns_context_manager_that_isnt_used.py:14:10: error[unknown-argument] Argument `wrap_context_manager` does not match any known parameter of function `keyword`
+ tests/type_tests.py:18:6: error[missing-argument] No argument provided for required parameter `fn` of function `keyword`
+ tests/type_tests.py:18:14: error[unknown-argument] Argument `name` does not match any known parameter of function `keyword`
+ tests/type_tests.py:18:30: error[unknown-argument] Argument `tags` does not match any known parameter of function `keyword`
+ tests/type_tests.py:39:6: error[missing-argument] No argument provided for required parameter `fn` of function `keyword`
+ tests/type_tests.py:39:14: error[unknown-argument] Argument `wrap_context_manager` does not match any known parameter of function `keyword`
+ tests/type_tests.py:47:6: error[missing-argument] No argument provided for required parameter `fn` of function `keyword`
+ tests/type_tests.py:47:14: error[unknown-argument] Argument `wrap_context_manager` does not match any known parameter of function `keyword`
+ tests/type_tests.py:60:9: error[type-assertion-failure] Type `Never` does not match asserted type `((...) -> _GeneratorContextManager[None, None, None]) | ((...) -> _GeneratorContextManager[object, None, None])`
+ tests/type_tests.py:64:6: error[missing-argument] No argument provided for required parameter `fn` of function `keyword`
+ tests/type_tests.py:64:14: error[unknown-argument] Argument `wrap_context_manager` does not match any known parameter of function `keyword`
+ tests/type_tests.py:69:6: error[missing-argument] No argument provided for required parameter `fn` of function `keyword`
+ tests/type_tests.py:69:14: error[unknown-argument] Argument `wrap_context_manager` does not match any known parameter of function `keyword`
- Found 167 diagnostics
+ Found 208 diagnostics

python-sop (https://gitlab.com/dkg/python-sop)
- sop/__init__.py:424:29: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ sop/__init__.py:424:20: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`

DateType (https://github.com/glyph/DateType)
- src/datetype/__init__.py:535:32: warning[deprecated] The function `utcfromtimestamp` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .fromtimestamp(datetime.timezone.utc)
- src/datetype/__init__.py:539:32: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ src/datetype/__init__.py:535:22: error[invalid-argument-type] Argument to bound method `utcfromtimestamp` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
+ src/datetype/__init__.py:539:22: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`

pip (https://github.com/pypa/pip)
- src/pip/_vendor/distlib/compat.py:90:21: warning[deprecated] The function `match_hostname` is deprecated: Deprecated since Python 3.7; removed in Python 3.12.
- src/pip/_vendor/urllib3/util/ssl_.py:50:36: warning[deprecated] The function `wrap_socket` is deprecated: Deprecated since Python 3.7; removed in Python 3.12. Use `SSLContext.wrap_socket()` instead.
- src/pip/_vendor/urllib3/util/ssl_.py:182:20: warning[deprecated] The function `wrap_socket` is deprecated: Deprecated since Python 3.7; removed in Python 3.12. Use `SSLContext.wrap_socket()` instead.
- Found 603 diagnostics
+ Found 600 diagnostics

bandersnatch (https://github.com/pypa/bandersnatch)
- src/bandersnatch/utils.py:54:24: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ src/bandersnatch/utils.py:54:15: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`

stone (https://github.com/dropbox/stone)
- test/test_python_gen.py:145:33: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
- test/test_python_gen.py:221:33: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ test/test_python_gen.py:145:15: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
+ test/test_python_gen.py:221:15: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- test/test_python_gen.py:413:33: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ test/test_python_gen.py:413:15: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`

asynq (https://github.com/quora/asynq)
- asynq/tests/test_typing.py:16:9: error[type-assertion-failure] Type `FutureBase[str]` does not match asserted type `FutureBase[Unknown]`
+ asynq/tests/test_typing.py:16:9: error[type-assertion-failure] Type `FutureBase[str]` does not match asserted type `FutureBase[str] | FutureBase[Unknown]`

werkzeug (https://github.com/pallets/werkzeug)
+ src/werkzeug/datastructures/mixins.py:302:18: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
+ src/werkzeug/datastructures/mixins.py:314:19: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- Found 397 diagnostics
+ Found 399 diagnostics

black (https://github.com/psf/black)
+ src/black/files.py:92:16: error[unsupported-operator] Operator `in` is not supported for types `str` and `object`, in comparing `Literal["black"]` with `object`
+ src/black/files.py:127:30: error[unresolved-attribute] Object of type `object` has no attribute `get`
- Found 63 diagnostics
+ Found 65 diagnostics

graphql-core (https://github.com/graphql-python/graphql-core)
+ tests/pyutils/test_is_awaitable.py:90:29: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- tests/validation/test_no_deprecated.py:23:8: warning[unused-ignore-comment] Unused blanket `type: ignore` directive

paasta (https://github.com/yelp/paasta)
- paasta_tools/cli/cmds/local_run.py:1036:39: warning[deprecated] The function `mktemp` is deprecated: Deprecated since Python 2.3. Use `mkstemp()` or `NamedTemporaryFile(delete=False)` instead.
- paasta_tools/cli/cmds/logs.py:1042:46: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ paasta_tools/cli/cmds/logs.py:1042:28: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- paasta_tools/cli/cmds/logs.py:1339:42: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
- paasta_tools/cli/cmds/logs.py:1351:40: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ paasta_tools/cli/cmds/logs.py:1339:24: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
+ paasta_tools/cli/cmds/logs.py:1351:22: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- paasta_tools/cli/cmds/start_stop_restart.py:276:77: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ paasta_tools/cli/cmds/start_stop_restart.py:276:59: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
+ paasta_tools/generate_deployments_for_service.py:245:41: error[invalid-argument-type] Argument to function `dump` is incorrect: Expected `SupportsWrite[str]`, found `Top[IO[Unknown]] | Unknown`
+ paasta_tools/generate_services_file.py:91:9: error[no-matching-overload] No overload of bound method `write` matches arguments
+ paasta_tools/generate_services_file.py:92:9: error[no-matching-overload] No overload of bound method `write` matches arguments
+ paasta_tools/kubernetes_tools.py:4246:47: error[unresolved-attribute] Object of type `object` has no attribute `metadata`
+ paasta_tools/metrics/metastatus_lib.py:843:36: error[unresolved-attribute] Object of type `object` has no attribute `spec`
- paasta_tools/utils.py:1516:30: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ paasta_tools/utils.py:1516:12: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- paasta_tools/utils.py:3728:52: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
- paasta_tools/utils.py:3736:52: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ paasta_tools/utils.py:3728:34: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
+ paasta_tools/utils.py:3736:34: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
+ paasta_tools/utils.py:4335:13: error[invalid-argument-type] Argument to function `dump` is incorrect: Expected `SupportsWrite[str]`, found `Top[IO[Unknown]] | Unknown`
+ paasta_tools/utils.py:4357:9: error[no-matching-overload] No overload of bound method `write` matches arguments
- Found 1112 diagnostics
+ Found 1118 diagnostics

scrapy (https://github.com/scrapy/scrapy)
+ scrapy/utils/decorators.py:111:16: error[invalid-return-type] Return type does not match returned value: expected `((...) -> _T@_warn_spider_arg) | ((...) -> Coroutine[Any, Any, _T@_warn_spider_arg]) | ((...) -> AsyncGenerator[_T@_warn_spider_arg, None])`, found `_Wrapped[Unknown, _T@_warn_spider_arg, Unknown, CoroutineType[object, Never, _T@_warn_spider_arg]] | _Wrapped[Unknown, _T@_warn_spider_arg, Unknown, CoroutineType[object, Never, object]]`
+ tests/test_spidermiddleware_urllength.py:42:17: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `Iterable[Request]`, found `Iterable[object] | Unknown`
- Found 1739 diagnostics
+ Found 1741 diagnostics

pytest (https://github.com/pytest-dev/pytest)
+ src/_pytest/fixtures.py:221:34: error[invalid-assignment] Invalid subscript assignment with key of type `Scope | Unknown` and value of type `defaultdict[Unknown, Top[OrderedDict[Unknown, Unknown]]]` on object of type `dict[Scope, dict[ParamArgKey, OrderedDict[Item, None]]]`
+ src/_pytest/fixtures.py:227:21: error[invalid-assignment] Invalid subscript assignment with key of type `Item` and value of type `None` on object of type `Top[OrderedDict[Unknown, Unknown]]`
- src/_pytest/mark/structures.py:542:13: error[invalid-method-override] Invalid override of method `__call__`: Definition is incompatible with `MarkDecorator.__call__`
- src/_pytest/mark/structures.py:542:13: error[invalid-overload] Overloads for function `__call__` must be followed by a non-`@overload`-decorated implementation function
+ testing/test_compat.py:204:51: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- Found 457 diagnostics
+ Found 458 diagnostics

beartype (https://github.com/beartype/beartype)
- beartype/_util/hint/pep/utilpepsign.py:237:12: error[invalid-return-type] Return type does not match returned value: expected `HintSign`, found `HintSign | None`
+ beartype/_util/hint/pep/utilpepsign.py:237:12: error[invalid-return-type] Return type does not match returned value: expected `HintSign`, found `HintSign | None | Divergent`
+ beartype/claw/_package/clawpkgtrie.py:66:29: warning[unsupported-base] Unsupported class base with type `<class 'dict[str, PackagesTrieBlacklist]'> | <class 'dict[str, Divergent]'>`
+ beartype/claw/_package/clawpkgtrie.py:247:29: warning[unsupported-base] Unsupported class base with type `<class 'dict[str, PackagesTrieWhitelist]'> | <class 'dict[str, Divergent]'>`
- Found 505 diagnostics
+ Found 507 diagnostics

starlette (https://github.com/encode/starlette)
- starlette/routing.py:67:51: error[invalid-assignment] Object of type `((Request, /) -> Awaitable[Response] | Response) | partial[Unknown]` is not assignable to `(Request, /) -> Awaitable[Response]`
+ starlette/routing.py:67:51: error[invalid-assignment] Object of type `((Request, /) -> Awaitable[Response] | Response) | partial[CoroutineType[object, Never, T@run_in_threadpool]]` is not assignable to `(Request, /) -> Awaitable[Response]`

dulwich (https://github.com/dulwich/dulwich)
- dulwich/porcelain.py:8624:25: warning[deprecated] The function `warn` is deprecated: Deprecated since Python 3.3. Use `warning()` instead.
+ dulwich/walk.py:466:35: error[invalid-argument-type] Argument to bound method `_reorder` is incorrect: Expected `Iterator[WalkEntry]`, found `Iterator[WalkEntry | None]`

alerta (https://github.com/alerta/alerta)
- alerta/auth/oidc.py:99:24: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/auth/oidc.py:99:15: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/auth/utils.py:52:20: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/auth/utils.py:52:11: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/commands.py:66:24: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/commands.py:66:15: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/commands.py:74:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `datetime`, found `Unknown | None`
+ alerta/commands.py:74:13: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `datetime`, found `Unknown | Divergent | None`
- alerta/database/backends/mongodb/base.py:190:56: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
- alerta/database/backends/mongodb/base.py:214:24: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/database/backends/mongodb/base.py:190:47: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
+ alerta/database/backends/mongodb/base.py:214:15: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/database/backends/mongodb/base.py:1116:79: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/database/backends/mongodb/base.py:1116:70: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/database/backends/mongodb/base.py:1194:51: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/database/backends/mongodb/base.py:1194:42: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/database/backends/mongodb/base.py:1259:52: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
- alerta/database/backends/mongodb/base.py:1301:67: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/database/backends/mongodb/base.py:1259:43: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
+ alerta/database/backends/mongodb/base.py:1301:58: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/database/backends/mongodb/base.py:1517:41: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
- alerta/database/backends/mongodb/base.py:1603:44: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
- alerta/database/backends/mongodb/base.py:1608:41: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/database/backends/mongodb/base.py:1517:32: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
+ alerta/database/backends/mongodb/base.py:1603:35: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
+ alerta/database/backends/mongodb/base.py:1608:32: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/database/backends/mongodb/base.py:1618:100: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
- alerta/database/backends/mongodb/base.py:1668:95: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
- alerta/database/backends/mongodb/base.py:1718:95: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/database/backends/mongodb/base.py:1618:91: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
+ alerta/database/backends/mongodb/base.py:1668:86: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
+ alerta/database/backends/mongodb/base.py:1718:86: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/database/backends/mongodb/utils.py:250:79: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
- alerta/database/backends/mongodb/utils.py:250:120: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
- alerta/database/backends/mongodb/utils.py:252:68: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
- alerta/database/backends/mongodb/utils.py:254:67: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/database/backends/mongodb/utils.py:250:70: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
+ alerta/database/backends/mongodb/utils.py:250:111: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
+ alerta/database/backends/mongodb/utils.py:252:59: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
+ alerta/database/backends/mongodb/utils.py:254:58: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/database/backends/mongodb/utils.py:345:70: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
- alerta/database/backends/mongodb/utils.py:347:69: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/database/backends/mongodb/utils.py:345:61: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
+ alerta/database/backends/mongodb/utils.py:347:60: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/dev.py:4:23: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/dev.py:4:14: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/management/views.py:144:39: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/management/views.py:144:21: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/models/alert.py:66:72: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
- alerta/models/alert.py:75:74: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/models/alert.py:66:63: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
+ alerta/models/alert.py:75:65: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/models/alert.py:282:24: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
- alerta/models/alert.py:335:24: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
- alerta/models/alert.py:379:24: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/models/alert.py:282:15: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
+ alerta/models/alert.py:335:15: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
+ alerta/models/alert.py:379:15: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/models/alert.py:430:24: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/models/alert.py:430:15: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/models/alert.py:574:34: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
- alerta/models/alert.py:594:34: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/models/alert.py:574:25: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
+ alerta/models/alert.py:594:25: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/models/alert.py:609:24: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/models/alert.py:609:15: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/models/alert.py:637:24: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/models/alert.py:637:15: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/models/blackout.py:37:65: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
- alerta/models/blackout.py:60:91: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
- alerta/models/blackout.py:84:24: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/models/blackout.py:37:56: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
+ alerta/models/blackout.py:60:82: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
+ alerta/models/blackout.py:84:15: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/models/heartbeat.py:56:52: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
- alerta/models/heartbeat.py:59:74: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
- alerta/models/heartbeat.py:61:31: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/models/heartbeat.py:56:43: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
+ alerta/models/heartbeat.py:59:65: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
+ alerta/models/heartbeat.py:61:22: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/models/history.py:16:72: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/models/history.py:16:63: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/models/key.py:31:52: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/models/key.py:31:43: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/models/key.py:42:49: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/models/key.py:42:40: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/models/key.py:164:57: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/models/key.py:164:48: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/models/note.py:25:91: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/models/note.py:25:82: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/models/user.py:41:72: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
- alerta/models/user.py:44:72: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/models/user.py:41:63: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
+ alerta/models/user.py:44:63: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/utils/audit.py:94:36: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/utils/audit.py:94:27: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/utils/client.py:44:45: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/utils/client.py:44:27: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/views/alerts.py:309:27: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ alerta/views/alerts.py:309:18: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- alerta/views/alerts.py:332:26: error[invalid-argument-type] Argument to function `max` is incorrect: Argument type `Unknown | None` does not satisfy upper bound `SupportsDunderLT[Any] | SupportsDunderGT[Any]` of type variable `SupportsRichComparisonT`
+ alerta/views/alerts.py:332:26: error[invalid-argument-type] Argument to function `max` is incorrect: Argument type `Unknown | None | Divergent` does not satisfy upper bound `SupportsDunderLT[Any] | SupportsDunderGT[Any]` of type variable `SupportsRichComparisonT`
- tests/test_blackouts.py:688:42: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ tests/test_blackouts.py:688:33: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`

sockeye (https://github.com/awslabs/sockeye)
- sockeye/model.py:183:20: warning[deprecated] The function `warn` is deprecated: Deprecated since Python 3.3. Use `Logger.warning()` instead.
- sockeye/model.py:187:24: warning[deprecated] The function `warn` is deprecated: Deprecated since Python 3.3. Use `Logger.warning()` instead.
+ sockeye/rerank.py:93:65: error[invalid-argument-type] Argument to function `_sort_by_ranking` is incorrect: Expected `list[int]`, found `Unknown | Top[list[Unknown]]`
+ sockeye/rerank.py:95:46: 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 `object` on object of type `list[Unknown]`
- sockeye/utils.py:843:20: warning[deprecated] The function `warn` is deprecated: Deprecated since Python 3.3. Use `Logger.warning()` instead.
- Found 413 diagnostics
+ Found 412 diagnostics

httpx-caching (https://github.com/johtso/httpx-caching)
- httpx_caching/_heuristics.py:14:29: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ httpx_caching/_heuristics.py:14:20: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`

mkosi (https://github.com/systemd/mkosi)
- mkosi/documentation.py:32:29: warning[deprecated] The function `warn` is deprecated: Deprecated since Python 3.3. Use `warning()` instead.
- Found 96 diagnostics
+ Found 95 diagnostics

poetry (https://github.com/python-poetry/poetry)
- tests/installation/test_executor.py:150:29: warning[deprecated] The function `mktemp` is deprecated: Deprecated since Python 2.3. Use `mkstemp()` or `NamedTemporaryFile(delete=False)` instead.
- tests/utils/env/test_env.py:540:34: warning[unused-ignore-comment] Unused blanket `type: ignore` directive
- Found 970 diagnostics
+ Found 968 diagnostics

tornado (https://github.com/tornadoweb/tornado)
- tornado/test/httpclient_test.py:932:43: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ tornado/test/httpclient_test.py:932:25: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- tornado/test/httputil_test.py:506:42: warning[deprecated] The function `utcfromtimestamp` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .fromtimestamp(datetime.timezone.utc)
+ tornado/test/httputil_test.py:506:24: error[invalid-argument-type] Argument to bound method `utcfromtimestamp` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`

dragonchain (https://github.com/dragonchain/dragonchain)
- dragonchain/lib/authorization.py:51:30: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ dragonchain/lib/authorization.py:51:12: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- dragonchain/lib/dto/smart_contract_model.py:100:95: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
- dragonchain/lib/dto/smart_contract_model.py:300:121: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ dragonchain/lib/dto/smart_contract_model.py:100:86: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
+ dragonchain/lib/dto/smart_contract_model.py:300:112: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- dragonchain/scheduler/scheduler.py:65:51: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ dragonchain/scheduler/scheduler.py:65:42: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`

schemathesis (https://github.com/schemathesis/schemathesis)
+ src/schemathesis/engine/phases/probes.py:159:13: error[no-matching-overload] No overload of bound method `setdefault` matches arguments
+ src/schemathesis/transport/prepare.py:36:5: error[no-matching-overload] No overload of bound method `setdefault` matches arguments
+ src/schemathesis/transport/prepare.py:38:9: error[no-matching-overload] No overload of bound method `update` matches arguments
- Found 290 diagnostics
+ Found 293 diagnostics

typeshed-stats (https://github.com/AlexWaygood/typeshed-stats)
+ src/typeshed_stats/gather.py:403:12: error[invalid-return-type] Return type does not match returned value: expected `str | None`, found `object`
+ src/typeshed_stats/gather.py:424:22: error[unresolved-attribute] Object of type `object` has no attribute `get`
+ src/typeshed_stats/gather.py:875:12: error[invalid-return-type] Return type does not match returned value: expected `str | None`, found `object`
- Found 17 diagnostics
+ Found 20 diagnostics

mitmproxy (https://github.com/mitmproxy/mitmproxy)
- examples/contrib/webscanner_helper/urlindex.py:93:42: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ examples/contrib/webscanner_helper/urlindex.py:93:24: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
- examples/contrib/webscanner_helper/watchdog.py:74:51: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
- examples/contrib/webscanner_helper/watchdog.py:78:51: warning[deprecated] The function `utcnow` is deprecated: Use timezone-aware objects to represent datetimes in UTC; e.g. by calling .now(datetime.timezone.utc)
+ examples/contrib/webscanner_helper/watchdog.py:74:42: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
+ examples/contrib/webscanner_helper/watchdog.py:78:42: error[invalid-argument-type] Argument to bound method `utcnow` is incorrect: Argument type `<class 'datetime'>` does not satisfy upper bound `datetime` of type variable `Self`
+ mitmproxy/addons/save.py:101:45: error[invalid-argument-type] Argument to bound method `__init__` is incorrect: Expected `BinaryIO`, found `IO[Any]`
- mitmproxy/contentviews/__init__.py:20:22: warning[deprecated] The function `get` is deprecated: Use `mitmproxy.contentviews.reg

... (truncated 3310 lines) ...
Memory usage changes were detected when running on open source projects
trio (https://github.com/python-trio/trio)
- TOTAL MEMORY USAGE: ~159MB
+ TOTAL MEMORY USAGE: ~167MB
-     struct metadata = ~10MB
+     struct metadata = ~11MB
-     struct fields = ~11MB
+     struct fields = ~12MB
-     memo metadata = ~33MB
+     memo metadata = ~35MB

prefect (https://github.com/PrefectHQ/prefect)
-     struct metadata = ~40MB
+     struct metadata = ~44MB
-     struct fields = ~44MB
+     struct fields = ~47MB
-     memo metadata = ~138MB
+     memo metadata = ~152MB

@AlexWaygood AlexWaygood added the ty Multi-file analysis & type inference label Nov 21, 2025
@dcreager dcreager force-pushed the dcreager/callable-return branch from 965a9f8 to dbecc68 Compare November 26, 2025 21:22
@dcreager dcreager changed the title [ty] Infer typevar specializations for Callable return types [ty] Infer typevar specializations for Callable types Nov 26, 2025
@dcreager dcreager force-pushed the dcreager/callable-return branch from 7995e43 to f89ec1a Compare November 26, 2025 23:14
return fn(value)

def identity(x: T) -> T:
def identity(x: T, /) -> T:
Copy link
Member Author

Choose a reason for hiding this comment

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

This is an interesting nuance: Callable[[A], B] creates a signature containing positional-only parameters, so we have to make the signature here positional-only as well to make identity pass the assignability check for it to be a valid argument to the fn parameter.

(That said, I'm not convinced that's...correct? Are we mixing up the ordering of the assignability check operands somewhere?)

Comment on lines 390 to 391
# TODO: this should be `Unknown | int`
reveal_type(invoke(head, [1, 2, 3])) # revealed: Unknown
Copy link
Member Author

Choose a reason for hiding this comment

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

This TODO is not also removed because we end up inferring this constraint set when comparing head to Callable[[A], B]:

(B@invoke ≤ T@head) ∧ (list[T@head] ≤ A@invoke)

We then try to remove T@head from the constraint set by calculating

∃T@head ⋅ (B@invoke ≤ T@head) ∧ (list[T@head] ≤ A@invoke)

We should be able to pick T@head = B@invoke and simplify that to

(B@invoke = *) ∧ (list[B@invoke] ≤ A@invoke)

which I think would then be enough to propagate through the return type to discharge this TODO. I think this would require adding more derived facts to the sequent map.


x12: Y[Y[Literal[1]]] = [[1]]
reveal_type(x12) # revealed: list[Y[Literal[1]]]
reveal_type(x12) # revealed: list[list[Literal[1]]]
Copy link
Member Author

Choose a reason for hiding this comment

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

This is because we're now using specialize_recursive instead of specialize_partial.

Comment on lines +1680 to +1718
let when = formal_signature.when_constraint_set_assignable_to(
self.db,
actual_signature,
self.inferable,
);
when.for_each_path(self.db, |path| {
for constraint in path.positive_constraints() {
let typevar = constraint.typevar(self.db);
let lower = constraint.lower(self.db);
let upper = constraint.upper(self.db);
if !upper.is_object() {
self.add_type_mapping(typevar, upper, polarity, &mut f);
}
if let Type::TypeVar(lower_bound_typevar) = lower {
self.add_type_mapping(
lower_bound_typevar,
Type::TypeVar(typevar),
polarity,
&mut f,
);
}
}
});
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the meat of the change. We use the new ConstraintAssignability type relation here to calculate a constraint set describing when the two callables are assignable. That will recurse into any typevars in the callables, and find whatever constraint set allows them to unify.

We then use this new for_each_path method to find each way that constraint set can be satisfied, and add new typevar bindings to the old solver for whatever we find.

Comment on lines +968 to +1020
result.intersect(
db,
ConstraintSet::from(
relation.is_assignability() || relation.is_constraint_set_assignability(),
),
);
return result;
Copy link
Member Author

Choose a reason for hiding this comment

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

We need to combine this with result to hang on to any typevar mapping our constraint set has recorded for the return type comparison above. That's need to support something like

Callable[[int], int] ≤ Callable[..., T]

and have it return int ≤ T.

Comment on lines +1751 to +1973
// A typevar satisfies a relation when...it satisfies the relation. Yes that's a
// tautology! We're moving the caller's subtyping/assignability requirement into a
// constraint set. If the typevar has an upper bound or constraints, then the relation
// only has to hold when the typevar has a valid specialization (i.e., one that
// satisfies the upper bound/constraints).
Copy link
Member Author

Choose a reason for hiding this comment

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

This is what #20093 is trying to add to replace assignability across the board. In the meantime, I've added a new TypeRelation that lets us opt into the new behavior only in certain places.

@dcreager dcreager force-pushed the dcreager/callable-return branch from 3868294 to 2c62674 Compare November 26, 2025 23:37
@dcreager dcreager marked this pull request as ready for review November 26, 2025 23:38
@astral-sh-bot
Copy link

astral-sh-bot bot commented Nov 26, 2025

ecosystem-analyzer results

Lint rule Added Removed Changed
invalid-argument-type 1,565 13 96
non-subscriptable 337 0 0
deprecated 0 255 0
unresolved-attribute 64 125 3
possibly-missing-attribute 141 3 24
invalid-return-type 80 0 5
no-matching-overload 70 15 0
type-assertion-failure 3 19 36
invalid-assignment 43 0 11
unsupported-operator 8 0 26
unused-ignore-comment 16 17 0
call-non-callable 30 0 0
possibly-unresolved-reference 26 4 0
missing-argument 27 0 0
unknown-argument 22 0 0
invalid-overload 9 1 0
invalid-type-form 10 0 0
not-iterable 7 0 0
invalid-method-override 0 5 0
unsupported-base 2 0 0
invalid-await 1 0 0
invalid-context-manager 1 0 0
invalid-raise 1 0 0
redundant-cast 1 0 0
Total 2,464 457 201

Full report with detailed diff (timing results)

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.

3 participants