From 7f9a18d7f01958eb23d8684694bcceb1d06178c2 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 21 Feb 2026 15:16:02 -0800 Subject: [PATCH 1/2] conformance: allow emitting an error on missing return with Any annotation Pycroscope produces an error on the existing open() function in this file because it is annotated as returning Any, but doesn't have a return statement. There's some existing discussion of this case in https://github.com/python/mypy/issues/10297 showing that it is intentional for mypy to not error here, but I don't think we need to prohibit type checkers from emitting an error in this case if they choose. --- conformance/tests/literals_interactions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conformance/tests/literals_interactions.py b/conformance/tests/literals_interactions.py index 14488132..b7277325 100644 --- a/conformance/tests/literals_interactions.py +++ b/conformance/tests/literals_interactions.py @@ -43,7 +43,7 @@ def open(path: _PathType, mode: str) -> IO[Any]: def open(path: _PathType, mode: Any) -> Any: - pass + raise NotImplementedError assert_type(open("path", "r"), IO[str]) From 0a2e48befd702e5277c517914d471857e8e89b13 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 21 Feb 2026 18:53:12 -0800 Subject: [PATCH 2/2] more of the same --- conformance/tests/callables_protocol.py | 6 +++--- conformance/tests/dataclasses_transform_class.py | 2 +- conformance/tests/dataclasses_transform_field.py | 2 +- conformance/tests/dataclasses_transform_func.py | 2 +- conformance/tests/dataclasses_transform_meta.py | 2 +- conformance/tests/generics_typevartuple_overloads.py | 2 +- conformance/tests/literals_literalstring.py | 2 +- conformance/tests/overloads_basic.py | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/conformance/tests/callables_protocol.py b/conformance/tests/callables_protocol.py index c9c8cdf0..0ee1b5d3 100644 --- a/conformance/tests/callables_protocol.py +++ b/conformance/tests/callables_protocol.py @@ -222,15 +222,15 @@ def __call__(self, x: int, /, y: str) -> Any: def cb11_good1(x: int, /, y: str, z: None = None) -> Any: - pass + raise NotImplementedError def cb11_good2(x: int, y: str, z: None = None) -> Any: - pass + raise NotImplementedError def cb11_bad1(x: int, y: str, /) -> Any: - pass + raise NotImplementedError cb11: Proto11 = cb11_good1 # OK diff --git a/conformance/tests/dataclasses_transform_class.py b/conformance/tests/dataclasses_transform_class.py index ad0aa835..da7ab82d 100644 --- a/conformance/tests/dataclasses_transform_class.py +++ b/conformance/tests/dataclasses_transform_class.py @@ -17,7 +17,7 @@ def __init__(self, *, init: bool = True, default: Any | None = None) -> None: def model_field( *, init: bool = True, default: Any | None = None, alias: str | None = None ) -> Any: - ... + raise NotImplementedError @dataclass_transform( diff --git a/conformance/tests/dataclasses_transform_field.py b/conformance/tests/dataclasses_transform_field.py index c6ccb8b7..14df5677 100644 --- a/conformance/tests/dataclasses_transform_field.py +++ b/conformance/tests/dataclasses_transform_field.py @@ -42,7 +42,7 @@ def field1( def field2(*, init: bool = False, kw_only: bool = True) -> Any: - ... + raise NotImplementedError @dataclass_transform(kw_only_default=True, field_specifiers=(field1, field2)) diff --git a/conformance/tests/dataclasses_transform_func.py b/conformance/tests/dataclasses_transform_func.py index 0a792271..bdff17c8 100644 --- a/conformance/tests/dataclasses_transform_func.py +++ b/conformance/tests/dataclasses_transform_func.py @@ -26,7 +26,7 @@ def create_model( def create_model(*args: Any, **kwargs: Any) -> Any: - ... + raise NotImplementedError @create_model(kw_only=False, order=False) diff --git a/conformance/tests/dataclasses_transform_meta.py b/conformance/tests/dataclasses_transform_meta.py index dff70a2e..c38b077a 100644 --- a/conformance/tests/dataclasses_transform_meta.py +++ b/conformance/tests/dataclasses_transform_meta.py @@ -15,7 +15,7 @@ def __init__(self, *, init: bool = True, default: Any | None = None) -> None: def model_field( *, init: bool = True, default: Any | None = None, alias: str | None = None ) -> Any: - ... + raise NotImplementedError @dataclass_transform( diff --git a/conformance/tests/generics_typevartuple_overloads.py b/conformance/tests/generics_typevartuple_overloads.py index 26c38a67..7f6fa030 100644 --- a/conformance/tests/generics_typevartuple_overloads.py +++ b/conformance/tests/generics_typevartuple_overloads.py @@ -23,7 +23,7 @@ def transpose(self: "Array[Axis1, Axis2, Axis3]") -> "Array[Axis3, Axis2, Axis1] ... def transpose(self) -> Any: - pass + raise NotImplementedError def func1(a: Array[Axis1, Axis2], b: Array[Axis1, Axis2, Axis3]): diff --git a/conformance/tests/literals_literalstring.py b/conformance/tests/literals_literalstring.py index 70f13f17..e299fa43 100644 --- a/conformance/tests/literals_literalstring.py +++ b/conformance/tests/literals_literalstring.py @@ -158,7 +158,7 @@ def func8(x: str) -> A: def func8(x: Any) -> Any: - ... + raise NotImplementedError assert_type(func8("foo"), C) # First overload diff --git a/conformance/tests/overloads_basic.py b/conformance/tests/overloads_basic.py index ec0fd069..7aee51d8 100644 --- a/conformance/tests/overloads_basic.py +++ b/conformance/tests/overloads_basic.py @@ -57,5 +57,5 @@ def map( def map(func: Any, iter1: Any, iter2: Any = ...) -> Any: - pass + raise NotImplementedError