Use __init__ if we have it instead of the actual type.#20208
Use __init__ if we have it instead of the actual type.#20208noobCodec wants to merge 4 commits intopython:masterfrom
Conversation
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
A5rocks
left a comment
There was a problem hiding this comment.
I'm not convinced this is the right level to solve the issue at.
| ): | ||
| s = f"{definition.name}({s})" | ||
| else: | ||
| s = f"{tp.name.split()[0]}({s})" # skip "of Class" part |
There was a problem hiding this comment.
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?
| PREFIX = provided_prefix | ||
| else: | ||
| this_file_dir = os.path.dirname(os.path.realpath(__file__)) | ||
| this_file_dir = os.path.dirname(os.path.abspath(__file__)) |
There was a problem hiding this comment.
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.
This pull request fixes #20016.
Updated pretty_callable to use the definition name if it matches 'init' instead of the type name for consistency. Not sure if this is correct, but appears to be what the issue is calling for.
Updated TC "testSerializeOverloaded__init__" to account for this change.