Import names from typing directly rather than importing module - #13761
Merged
srittau merged 3 commits intoApr 12, 2025
Merged
Conversation
Avasam
commented
Apr 2, 2025
| import mmap | ||
| import re | ||
| import typing as t | ||
| from typing import AnyStr, Match |
Collaborator
Author
There was a problem hiding this comment.
I'm assuming that importing Match from typing rather than re here is intended for the test.
Avasam
commented
Apr 2, 2025
Comment on lines
+219
to
+223
| [tool.ruff.lint.flake8-import-conventions.aliases] | ||
| # Prevent aliasing these, as it causes false-negatives for certain rules | ||
| typing_extensions = "typing_extensions" | ||
| typing = "typing" | ||
|
|
Collaborator
Author
There was a problem hiding this comment.
This prevents import typing as t
Avasam
commented
Apr 2, 2025
Comment on lines
+8
to
+16
| def convert(self, value: t.Any, param: click.Parameter | None, ctx: click.Context | None) -> t.Any: ... | ||
| def convert(self, value: str, param: click.Parameter | None, ctx: click.Context | None) -> str: ... | ||
|
|
||
| class PasswordParamType(click.ParamType): | ||
| def convert(self, value: t.Any, param: click.Parameter | None, ctx: click.Context | None) -> t.Any: ... | ||
| def convert(self, value: _T, param: click.Parameter | None, ctx: click.Context | None) -> _T: ... | ||
|
|
||
| class TextAreaParamType(click.ParamType): | ||
| def convert(self, value: t.Any, param: click.Parameter | None, ctx: click.Context | None) -> t.Any: ... | ||
| def convert(self, value: _T, param: click.Parameter | None, ctx: click.Context | None) -> _T: ... |
Collaborator
Author
There was a problem hiding this comment.
@pyhedgehog since you added this stub in #13208
Was there a specific reason to have these as Any?
This comment has been minimized.
This comment has been minimized.
srittau
approved these changes
Apr 2, 2025
…n-importing-module
Contributor
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
mmingyu
pushed a commit
to mmingyu/typeshed
that referenced
this pull request
May 16, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Import names from
typingandtyping_extensionsdirectly rather than importing module. (except where aliasingSelf as _SelforTypeAlias as _TypeAliaswould cause issues for flake8-pyi's Y015 and Y034)And avoid aliasing said modules.
This was prompted by this comment: #11204 (comment) where I realized we had some inconsistencies.