Skip to content

Improve flake8-bugbear #13829

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

Merged
merged 2 commits into from
Apr 15, 2025
Merged

Improve flake8-bugbear #13829

merged 2 commits into from
Apr 15, 2025

Conversation

donBarbos
Copy link
Contributor

@donBarbos donBarbos commented Apr 14, 2025

While working on this PR I noticed that the return type for ast.NodeVisitor.generic_visit is defined as Any, although it always seems to be None. Maybe I'm missing something?

Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau srittau merged commit b0238c5 into python:main Apr 15, 2025
43 checks passed
@srittau
Copy link
Collaborator

srittau commented Apr 15, 2025

While working on this PR I noticed that the return type for ast.NodeVisitor.generic_visit is defined as Any, although it always seems to be None.

I think this is because – like visitgeneric_visit can be overwritten by subclasses (even if that's not explicitly documented). And in that case – like visit et al. – it could return an arbitrary value, which is in return returned by visit.

This example also shows why we now require all instances of Any to be documented, so a PR adding a comment would definitely be welcome.

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.

2 participants