Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion mypy/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -3015,7 +3015,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
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not entirely sure this is the right approach? Like, obviously this works. But I feel like the issue only being produced with cache means we're forgetting to cache some attribute, which might cause more issues than just this!

Do you know what exactly differs between the object in the first and the second runs that causes the printing to be different before?

else:
s = f"({s})"

Expand Down
2 changes: 1 addition & 1 deletion mypy/test/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))
Copy link
Collaborator

Choose a reason for hiding this comment

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

This isn't the same thing, I think? To be honest I think this should probably use pathlib instead (seriously? 3 os.path.dirnames? That's awful!)

But I think any improvements should be in another PR.

PREFIX = os.path.dirname(os.path.dirname(this_file_dir))

# Location of test data files such as test case descriptions.
Expand Down
4 changes: 2 additions & 2 deletions test-data/unit/check-serialize.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down