Skip to content

Conversation

TaKO8Ki
Copy link
Contributor

@TaKO8Ki TaKO8Ki commented Sep 13, 2025

Summary

Fixes #20110

string_imports_min_dots was introduced in #19538, so the option has been available since then; this PR adds documentation and a config test.

Test Plan

Add integration test string_detection_from_config to verify the config setting works.

Copy link
Contributor

github-actions bot commented Sep 13, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@MichaReiser MichaReiser added the configuration Related to settings and configuration label Sep 16, 2025
Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good but I think we should rename the option to match the CLI

root.child("ruff.toml").write_str(indoc::indoc! {r#"
[analyze]
detect-string-imports = true
string-imports-min-dots = 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be min-dots for consistency with the CLI

Options:
      --direction <DIRECTION>            The direction of the import map. By default, generates a dependency map, i.e., a map from file to files that it depends on. Use `--direction
                                         dependents` to generate a map from file to files that depend on it [default: dependencies] [possible values: dependencies, dependents]
      --detect-string-imports            Attempt to detect imports from string literals
      --min-dots <MIN_DOTS>              The minimum number of dots in a string import to consider it a valid import
      --preview                          Enable preview mode. Use `--no-preview` to disable
      --target-version <TARGET_VERSION>  The minimum Python version that should be supported [possible values: py37, py38, py39, py310, py311, py312, py313, py314]
      --python <PYTHON>                  Path to a virtual environment to use for resolving additional dependencies
  -h, --help

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I have renamed it to min-dots!

@TaKO8Ki TaKO8Ki requested a review from MichaReiser September 16, 2025 10:50
@MichaReiser MichaReiser changed the title [ruff] Add analyze.string-imports-min-dots to settings docs [ruff] Add analyze.min-dots to settings docs Sep 16, 2025
@MichaReiser MichaReiser changed the title [ruff] Add analyze.min-dots to settings docs [ruff] Add analyze.min-dots to settings Sep 16, 2025
@MichaReiser
Copy link
Member

Oh wait, I made a mistake. I assumed you added the new option but that isn't the case. This is a pre-existing option (if I understand your summary correctly) and this PR only adds documentation.

If that's the case, then we shouldn't rename the option because that would break existing users

@MichaReiser MichaReiser changed the title [ruff] Add analyze.min-dots to settings [ruff] Add analyze.string-imports-min-dots to settings Sep 16, 2025
@TaKO8Ki TaKO8Ki force-pushed the analyze-string-imports-min-dots branch from 18e61e6 to 9e0ad2d Compare September 16, 2025 11:08
@TaKO8Ki
Copy link
Contributor Author

TaKO8Ki commented Sep 16, 2025

@MichaReiser Thanks for the clarification. I had the same concern, so I didn’t rename the option; I’ll keep the existing name as is.

@MichaReiser MichaReiser added documentation Improvements or additions to documentation and removed configuration Related to settings and configuration labels Sep 16, 2025
@MichaReiser MichaReiser merged commit 0d424d8 into astral-sh:main Sep 16, 2025
71 checks passed
@TaKO8Ki TaKO8Ki deleted the analyze-string-imports-min-dots branch September 16, 2025 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow configuring --min-dots using configuration file
2 participants