Add support for specifying minimum dots in detected string imports (#19538)

## Summary

Defaults to requiring two dots, which matches the Pants default.
This commit is contained in:
Charlie Marsh 2025-07-24 15:48:23 -04:00 committed by GitHub
parent d77b7312b0
commit d9cab4d242
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 129 additions and 42 deletions

View file

@ -3843,6 +3843,12 @@ pub struct AnalyzeOptions {
"#
)]
pub detect_string_imports: Option<bool>,
/// The minimum number of dots in a string to consider it a valid import.
///
/// This setting is only relevant when [`detect-string-imports`](#detect-string-imports) is enabled.
/// For example, if this is set to `2`, then only strings with at least two dots (e.g., `"path.to.module"`)
/// would be considered valid imports.
pub string_imports_min_dots: Option<usize>,
/// A map from file path to the list of Python or non-Python file paths or globs that should be
/// considered dependencies of that file, regardless of whether relevant imports are detected.
#[option(