mirror of https://github.com/astral-sh/ruff
Ignore relative imports in `banned-api` rules (#4024)
This commit is contained in:
parent
13fda30051
commit
c4cda301aa
|
|
@ -31,3 +31,6 @@ typing.TypedDict.anything()
|
||||||
# import aliases are resolved
|
# import aliases are resolved
|
||||||
import typing as totally_not_typing
|
import typing as totally_not_typing
|
||||||
totally_not_typing.TypedDict
|
totally_not_typing.TypedDict
|
||||||
|
|
||||||
|
# relative imports are respected
|
||||||
|
from .typing import TypedDict
|
||||||
|
|
|
||||||
|
|
@ -1155,13 +1155,15 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.settings.rules.enabled(Rule::BannedApi) {
|
if self.settings.rules.enabled(Rule::BannedApi) {
|
||||||
if let Some(module) = module {
|
if level.map_or(true, |level| level == 0) {
|
||||||
for name in names {
|
if let Some(module) = module {
|
||||||
flake8_tidy_imports::banned_api::name_is_banned(self, module, name);
|
for name in names {
|
||||||
|
flake8_tidy_imports::banned_api::name_is_banned(self, module, name);
|
||||||
|
}
|
||||||
|
flake8_tidy_imports::banned_api::name_or_parent_is_banned(
|
||||||
|
self, module, stmt,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
flake8_tidy_imports::banned_api::name_or_parent_is_banned(
|
|
||||||
self, module, stmt,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,8 @@ TID251.py:33:1: TID251 `typing.TypedDict` is banned: Use typing_extensions.Typed
|
||||||
34 | import typing as totally_not_typing
|
34 | import typing as totally_not_typing
|
||||||
35 | totally_not_typing.TypedDict
|
35 | totally_not_typing.TypedDict
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID251
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TID251
|
||||||
|
36 |
|
||||||
|
37 | # relative imports are respected
|
||||||
|
|
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue