mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-14 07:38:47 +00:00
Support relative imports in banned-api
enforcement (#4025)
This commit is contained in:
parent
f13a161ead
commit
7fa1da20fb
5 changed files with 157 additions and 19 deletions
|
@ -174,8 +174,12 @@ impl<'a> Context<'a> {
|
|||
if name.starts_with('.') {
|
||||
if let Some(module) = &self.module_path {
|
||||
let mut source_path = from_relative_import(module, name);
|
||||
source_path.extend(call_path.into_iter().skip(1));
|
||||
Some(source_path)
|
||||
if source_path.is_empty() {
|
||||
None
|
||||
} else {
|
||||
source_path.extend(call_path.into_iter().skip(1));
|
||||
Some(source_path)
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -191,8 +195,12 @@ impl<'a> Context<'a> {
|
|||
if name.starts_with('.') {
|
||||
if let Some(module) = &self.module_path {
|
||||
let mut source_path = from_relative_import(module, name);
|
||||
source_path.extend(call_path.into_iter().skip(1));
|
||||
Some(source_path)
|
||||
if source_path.is_empty() {
|
||||
None
|
||||
} else {
|
||||
source_path.extend(call_path.into_iter().skip(1));
|
||||
Some(source_path)
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue