From 5b46b6a66db43b79c73fbda7b7ae95011bcbe853 Mon Sep 17 00:00:00 2001 From: noobCodec <89281257+noobCodec@users.noreply.github.com> Date: Sat, 1 Nov 2025 14:54:53 -0400 Subject: [PATCH 1/4] use abspath if path not provided to preserve symlinks --- mypy/test/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy/test/config.py b/mypy/test/config.py index 2dc4208b1e9d..7dd5e3806e6e 100644 --- a/mypy/test/config.py +++ b/mypy/test/config.py @@ -6,7 +6,7 @@ if provided_prefix: PREFIX = provided_prefix else: - this_file_dir = os.path.dirname(os.path.realpath(__file__)) + this_file_dir = os.path.dirname(os.path.abspath(__file__)) PREFIX = os.path.dirname(os.path.dirname(this_file_dir)) # Location of test data files such as test case descriptions. From ed09c4604fa13218a7c83c1cc82d3a13e0a8a3a7 Mon Sep 17 00:00:00 2001 From: noobCodec Date: Sat, 8 Nov 2025 10:58:47 -0500 Subject: [PATCH 2/4] update message to use __init__ --- mypy/messages.py | 10 ++++++++-- test-data/unit/check-serialize.test | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/mypy/messages.py b/mypy/messages.py index c6378c264757..19413e96953f 100644 --- a/mypy/messages.py +++ b/mypy/messages.py @@ -1123,7 +1123,6 @@ def no_variant_matches_arguments( context, code=code, ) - self.note(f"Possible overload variant{plural_s(len(overload.items))}:", context, code=code) for item in overload.items: self.note(pretty_callable(item, self.options), context, offset=4, code=code) @@ -3015,7 +3014,14 @@ def [T <: int] f(self, x: int, y: T) -> None if s: s = ", " + s s = first_arg + s - s = f"{tp.name.split()[0]}({s})" # skip "of Class" part + if ( + isinstance(definition, FuncDef) + and hasattr(definition, "name") + and definition.name == "__init__" + ): + s = f"{definition.name}({s})" + else: + s = f"{tp.name.split()[0]}({s})" # skip "of Class" part else: s = f"({s})" diff --git a/test-data/unit/check-serialize.test b/test-data/unit/check-serialize.test index 1498c8d82826..9c321f0d3ba4 100644 --- a/test-data/unit/check-serialize.test +++ b/test-data/unit/check-serialize.test @@ -312,8 +312,8 @@ class A: [out2] tmp/a.py:2: error: No overload variant of "A" matches argument type "object" tmp/a.py:2: note: Possible overload variants: -tmp/a.py:2: note: def A(self, x: int) -> A -tmp/a.py:2: note: def A(self, x: str) -> A +tmp/a.py:2: note: def __init__(self, x: int) -> A +tmp/a.py:2: note: def __init__(self, x: str) -> A tmp/a.py:7: error: No overload variant of "__init__" of "A" matches argument type "object" tmp/a.py:7: note: Possible overload variants: tmp/a.py:7: note: def __init__(self, x: int) -> None From f8554512ec768994ccfcb0230d4269f1a2a60037 Mon Sep 17 00:00:00 2001 From: noobCodec Date: Sat, 8 Nov 2025 11:10:37 -0500 Subject: [PATCH 3/4] reintroduce space --- mypy/messages.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mypy/messages.py b/mypy/messages.py index 19413e96953f..5769691e319f 100644 --- a/mypy/messages.py +++ b/mypy/messages.py @@ -1123,6 +1123,7 @@ def no_variant_matches_arguments( context, code=code, ) + self.note(f"Possible overload variant{plural_s(len(overload.items))}:", context, code=code) for item in overload.items: self.note(pretty_callable(item, self.options), context, offset=4, code=code) From 60ae2f0dcd2fa6243c92e4b81240499bda0bf88f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 8 Nov 2025 16:15:01 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mypy/messages.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy/messages.py b/mypy/messages.py index 5769691e319f..fb7eecb273ae 100644 --- a/mypy/messages.py +++ b/mypy/messages.py @@ -1123,7 +1123,7 @@ def no_variant_matches_arguments( context, code=code, ) - + self.note(f"Possible overload variant{plural_s(len(overload.items))}:", context, code=code) for item in overload.items: self.note(pretty_callable(item, self.options), context, offset=4, code=code)