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

Fix return type of logging.config.BaseConfigurator.as_tuple #12817

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

brianschubert
Copy link
Contributor

Fix typo: tuple[Any] -> tuple[Any, ...]

Based on the source, a length-1 tuple isn't intended; the tuple can have any length.

Copy link
Contributor

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

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.

Nice catch! If you install flake8 and flake8-pyi, and apply this diff, then run flake8 stubs stdlib --select=Y090, you might be able to find a few more of these. I haven't done so in a while.

--- a/.flake8
+++ b/.flake8
@@ -3,8 +3,6 @@
 # Y: Flake8 is only used to run flake8-pyi, everything else is in Ruff
 # F821: Typeshed is a testing ground for flake8-pyi, which monkeypatches F821
 select = NQA, Y, F821
-# Ignore rules normally excluded by default
-extend-ignore = Y090
 per-file-ignores =
   # We should only need to noqa Y and F821 codes in .pyi files
   *.py: NQA

(the flake8 rule is off by default because it has false positives)

@AlexWaygood AlexWaygood changed the title Fix typo in logging.config.BaseConfigurator.as_tuple Fix return type of logging.config.BaseConfigurator.as_tuple Oct 15, 2024
@AlexWaygood AlexWaygood merged commit ab8e0e1 into python:main Oct 15, 2024
63 checks passed
@JelleZijlstra
Copy link
Member

It might be worth turning it on by default (I know I argued the other way in the past). A single-element tuple is a weird enough type that it seems worth it to force you to write a noqa if it's really what you want.

@AlexWaygood
Copy link
Member

there's still lots of hits on typeshed...

What I'd really love is a flake8_pyi_primer that leaves a comment on your PR with all the new Y090 hits that your PR caused relative to the baseline of main. That would not only let us get more signal from Y090, but also allow us to add more rules to flake8-pyi that are usually correct, but have too many false positives to be on by default.

Unfortunately I do not have the time to work on such a tool right now (brb, building a type checker, etc.)

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.

3 participants