10000 Don't instantiate types in `__init__` based on `self` by A5rocks · Pull Request #16753 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Don't instantiate types in __init__ based on self #16753

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

Closed
wants to merge 5 commits into from

Conversation

A5rocks
Copy link
Collaborator
@A5rocks A5rocks commented Jan 6, 2024

Fixes #16752

This comment has been minimized.

(this might be wrong? but I can't think of a counterexample)

This comment has been minimized.

@A5rocks
Copy link
Collaborator Author
A5rocks commented May 11, 2024

I'm still not confident that this is the best way to do this, but I think this is ready for a review by someone else (hopefully?) or a merge.

@A5rocks
Copy link
Collaborator Author
A5rocks commented Jun 16, 2024

Bump on this. I was actually thinking about how I would do this today and I think it might be nicer to try adding constraints from the self arg compared to the instance with all generics, but I'm not really sure how to do that.

This works as a hack though rereading it I'm not sure how it works.

Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@A5rocks
Copy link
Collaborator Author
A5rocks commented Jun 16, 2024

This works now without this PR.

@A5rocks A5rocks closed this Jun 16, 2024
@A5rocks A5rocks deleted the fancy-selftypes-in-init branch June 16, 2024 05:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
< 4E69 div class="discussion-sidebar-item js-discussion-sidebar-item js-socket-channel js-updatable-content" data-channel="eyJjIjoicHVsbF9yZXF1ZXN0OjE2NjcxMTU4MzAiLCJ0IjoxNzQ3OTMwMjI1fQ==--5f3c15e78e835f96a333a97de5872694b33a830a7cabf73d4f2e67fb34001524" data-gid="PR_kwDOAGuhRc5jXis2" data-url="/python/mypy/issues/16753/show_partial?partial=issues%2Fsidebar%2Fshow%2Flabels" data-channel-event-name="labels_updated" >
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use self-type in __init__ to add extra generic types
3 participants
0