Skip to content

Commit

Permalink
Ignore relative imports in banned-api rules
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Apr 19, 2023
1 parent 13fda30 commit 53431e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@
# import aliases are resolved
import typing as totally_not_typing
totally_not_typing.TypedDict

# relative imports are respected
from .typing import TypedDict
14 changes: 8 additions & 6 deletions crates/ruff/src/checkers/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1155,13 +1155,15 @@ where
}

if self.settings.rules.enabled(Rule::BannedApi) {
if let Some(module) = module {
for name in names {
flake8_tidy_imports::banned_api::name_is_banned(self, module, name);
if level.map_or(true, |level| level == 0) {
if let Some(module) = module {
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,
);
}
}

Expand Down

0 comments on commit 53431e9

Please sign in to comment.