Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exclude option to format and lint sections #7645

Closed
Tracked by #7642
MichaReiser opened this issue Sep 25, 2023 · 4 comments · Fixed by #8000
Closed
Tracked by #7642

Add exclude option to format and lint sections #7645

MichaReiser opened this issue Sep 25, 2023 · 4 comments · Fixed by #8000
Assignees
Labels
configuration Related to settings and configuration

Comments

@MichaReiser
Copy link
Member

Add the new exclude option to the format and lint section to exclude a set of files for a specific tool only. Respect the new option in the check, fix, and format commands.

@MichaReiser MichaReiser added the configuration Related to settings and configuration label Sep 25, 2023
@MichaReiser MichaReiser added this to the Formatter: Beta milestone Sep 25, 2023
@MichaReiser
Copy link
Member Author

@charliermarsh any advice on how to implement this? It seems that python_files_in_path is doing all the exclusions now. Should we just add an early check in one of the lint commands that returns immediately if the file is excluded?

@charliermarsh
Copy link
Member

@MichaReiser - Yeah, that would be my suggestion: python_files_in_path applies the top-level filters, then we apply any further filters in lint. It's kind of similar to per-file-ignores: we filter down the global rule set based on the ignore setting, but we then apply any per-file-ignores after collecting diagnostics, on a per-file basis.

@MichaReiser
Copy link
Member Author

MichaReiser commented Sep 29, 2023

We may also want to make sure that these files don't get formatted on save in the IDE. @charliermarsh does ruff lint files in the IDE that are not part of include or exclude?

@MichaReiser
Copy link
Member Author

Adding exclude to lint will be somewhat challenging because we use serde's flatten to expose the same options top-level and under the lint keyword. This works perfectly but imposes a challenge now because exclude (and, in the future, the preview flag) conflicts with the top-level exclude setting.

I think what we can try is to have a few more structs 😆

  • CommonLintOptions: The lint options without exclude (and eventually preview).
  • LintOptions: Defines the preview option and flattens the CommonLintOptions
  • Options flattens the CommonLintOptions (instead of LintOptions as of today)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
configuration Related to settings and configuration
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants