-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Import names from typing directly rather than importing module #13761
base: main
Are you sure you want to change the base?
Import names from typing directly rather than importing module #13761
Conversation
stdlib/@tests/test_cases/check_re.py
Outdated
@@ -2,18 +2,18 @@ | |||
|
|||
import mmap | |||
import re | |||
import typing as t | |||
from typing import AnyStr, Match |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming that importing Match
from typing
rather than re
here is intended for the test.
[tool.ruff.lint.flake8-import-conventions.aliases] | ||
# Prevent aliasing these, as it causes false-negatives for certain rules | ||
typing_extensions = "typing_extensions" | ||
typing = "typing" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This prevents import typing as t
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: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pyhedgehog since you added this stub in #13208
Was there a specific reason to have these as Any
?
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Import names from
typing
andtyping_extensions
directly rather than importing module. (except where aliasingSelf as _Self
orTypeAlias as _TypeAlias
would 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.