KEMBAR78
Disallow all super calls to methods with trivial bodies by hauntsaninja · Pull Request #16756 · python/mypy · GitHub
Skip to content

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

@github-actions

This comment has been minimized.

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

This comment has been minimized.

@github-actions
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
@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