Skip to content

Support __new__ in fine grained mode#4763

Merged
ilevkivskyi merged 6 commits intopython:masterfrom
ilevkivskyi:fine-new-support
Mar 21, 2018
Merged

Support __new__ in fine grained mode#4763
ilevkivskyi merged 6 commits intopython:masterfrom
ilevkivskyi:fine-new-support

Conversation

@ilevkivskyi
Copy link
Copy Markdown
Member

This is a straightforward PR that essentially adds same dependencies on __new__ as we have on __init__ for a class as a callable.

Just in case I add few dedicated tests.

Copy link
Copy Markdown
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

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

Looks good, just a few comments about test cases.

==
a.py:3: error: Argument 1 to "C" has incompatible type "int"; expected "str"

[case testDunderNewUpdatedFunc]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not sure if we need both this and the above test case (testMetaclassAttributesDirect) since they are pretty similar.

==
a.py:3: error: Argument 1 to "C" has incompatible type "int"; expected "str"

[case testDunderNewUpdatedMethod]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Again this test case seems redundant.

def __new__(cls, x: str) -> C:
pass
[out]
==
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ideas for additional test cases:

  • Add __new__ when originally there was nothing.
  • Replace __init__ with __new__.

@ilevkivskyi
Copy link
Copy Markdown
Member Author

@JukkaL Thanks for review! I left only one of three boring tests, and added the two other tests you proposed.

@ilevkivskyi ilevkivskyi merged commit b7976e9 into python:master Mar 21, 2018
@ilevkivskyi ilevkivskyi deleted the fine-new-support branch March 21, 2018 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants