Skip to content

Commit

Permalink
Merge pull request #439 from gauge-sh/fix-wildcard-import-project-sco…
Browse files Browse the repository at this point in the history
…pe-detection

Fix wildcard import always treated as external
  • Loading branch information
emdoyle authored Nov 26, 2024
2 parents 0cc7330 + d743c22 commit c3997d5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,14 @@ pub struct ResolvedModule {
pub member_name: Option<String>,
}

fn is_potential_python_module(s: &str) -> bool {
fn is_potential_python_module_path(s: &str) -> bool {
!s.is_empty()
&& s.split('.')
.all(|part| !part.is_empty() && part.chars().all(|c| c.is_alphanumeric() || c == '_'))
&& s.split('.').all(|part| {
!part.is_empty()
&& part
.chars()
.all(|c| c.is_alphanumeric() || c == '_' || c == '*')
})
}

pub fn module_to_file_path<P: AsRef<Path>>(
Expand All @@ -108,7 +112,7 @@ pub fn module_to_file_path<P: AsRef<Path>>(
check_members: bool,
) -> Option<ResolvedModule> {
// Fast check because this may run on every string literal in every source file
if !is_potential_python_module(mod_path) {
if !is_potential_python_module_path(mod_path) {
return None;
}

Expand Down

0 comments on commit c3997d5

Please sign in to comment.