8000 Allow using super() in methods with self-types by ilevkivskyi · Pull Request #13488 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@ilevkivskyi
Copy link
Member

Fixes #9282

It looks like super() checking is too strict for methods with self-types. Mypy explicitly allows self-type annotation to be a supertype of current class, so to be consistent, I relax the check for super() as well.

Copy link
Member
@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Looks great! Just a minor nit about the is_self_type_like function -- I think the code might be more readable if the parameter is named is_classmethod rather than is_class :-)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/orion/utilities/schemas.py:282: error: Argument 2 for "super" not an instance of argument 1

@ilevkivskyi ilevkivskyi merged commit a6e3454 into python:master Aug 23, 2022
@ilevkivskyi ilevkivskyi deleted the self-type-super branch August 23, 2022 19:38
dreua added a commit to dreua/flatpak-external-data-checker that referenced this pull request Feb 16, 2025
Has been fixed in the meantime: python/mypy#13488
bbhtt pushed a commit to flathub-infra/flatpak-external-data-checker that referenced this pull request Feb 17, 2025
Has been fixed in the meantime: python/mypy#13488
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.

Super in a generic classmethod gives error

3 participants

0