Skip to content
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

Disallow all super calls to methods with trivial bodies #16756

Merged
merged 3 commits into from
Mar 8, 2024

Conversation

hauntsaninja
Copy link
Collaborator

@hauntsaninja hauntsaninja commented Jan 7, 2024

Relates to:
https://discuss.python.org/t/calling-abstract-methods/42576

I think this makes mypy's behaviour more predictable

This comment has been minimized.

@hauntsaninja hauntsaninja marked this pull request as ready for review March 7, 2024 01:20

This comment has been minimized.

Copy link
Contributor

github-actions bot commented Mar 7, 2024

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

antidote (https://github.com/Finistere/antidote)
+ tests/core/test_provider.py:23: error: Call to abstract method "unsafe_maybe_provide" of "Provider" with trivial body via super() is unsafe  [safe-super]

ignite (https://github.com/pytorch/ignite)
+ ignite/metrics/frequency.py:52: error: Call to abstract method "reset" of "Metric" with trivial body via super() is unsafe  [safe-super]
+ ignite/metrics/gan/inception_score.py:109: error: Call to abstract method "reset" of "Metric" with trivial body via super() is unsafe  [safe-super]
+ ignite/metrics/gan/fid.py:228: error: Call to abstract method "reset" of "Metric" with trivial body via super() is unsafe  [safe-super]

Copy link
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.

I agree that the special casing some return types (that None is compatible with) was pretty confusing. It doesn't seem to cause much of a backward compatibility break either, based on mypy primer results, so this seems good to me.

@JukkaL JukkaL merged commit e0ad952 into python:master Mar 8, 2024
18 checks passed
@hauntsaninja hauntsaninja deleted the empty-none branch March 8, 2024 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants