Skip to content

Allow covariant args in constructor #2888

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 21, 2017
Merged

Conversation

ilevkivskyi
Copy link
Member

Fixes #2850

It looks like we could make a simple exclusion for __init__ and __new__.


class C(Generic[T_co]):
def __init__(self, x: T_co) -> None: # This should be allowed
pass
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also try assignment self.x = x in __init__ and reveal_type(self.x) in a method other than __init__.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in a new commit.

@JukkaL
Copy link
Collaborator

JukkaL commented Feb 21, 2017

Looks good now -- thanks for the PR!

@JukkaL JukkaL merged commit 95e58fa into python:master Feb 21, 2017
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