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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make bool error ignorable #13420

Merged
merged 3 commits into from Aug 15, 2022
Merged

Make bool error ignorable #13420

merged 3 commits into from Aug 15, 2022

Conversation

wookie184
Copy link
Contributor

Description

Closes #13411. The error for subclassing bool is now due to it being typed as final rather than a specific check.

This means class A(bool): ... gives error: Cannot inherit from final class "bool" instead of error: "bool" is not a valid base class and is now ignorable with # type: ignore.

Writing this and playing around with it a bit more made me realise my original use case in the issue was a bit silly, although I think this change still makes sense. I wont be offended if the maintainers disagree and decide to close this though 馃槃

Test Plan

I fixed the semantic analyser test as it shouldn't do anything about extending bool now.

I didn't add a new test as I couldn't work out exactly what stubs I needed to include/change to get a bool that's typed as final. I'm also not entirely sure they're necessary, since all the test would be adding is a check that bool is marked as final, which just depends on typeshed. If you would like tests for this i'd be happy to add them with some guidance on how.

Having a test case that reports no errors is not necessarily an issue
This now falls back to being handled due to bool being typed as final
Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks

@github-actions

This comment has been minimized.

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

On the second thought, we might add a new test to https://github.com/python/mypy/blob/master/test-data/unit/pythoneval.test to check that bool still cannot be subclasses.

But, this is totally optional (because it is related to typeshed, not mypy).

@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 馃馃帀

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this!

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.

"'bool' is not a valid base class" should be possible to ignore.
3 participants