Skip to content

New option: --per-file-ignores #3675

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

un-pogaz
Copy link

Close #3673

This implementation use nargs=2 to pass the file glob and the words list with a pair of arguments, rather than try to extract the data from a single complexe string. Also use action="append" so that several --per-file-ignores can be provided in one comand. This need to be a bit tricky to rebuild the resulting dict throught the config file.
Done a larger edit than targeted because of various Ruff warning about too many statements and complexity.

@Kristinita
Copy link

Type: Question

@un-pogaz, have you considered implementing the option --per-context-ignore instead of --per-file-ignore? In this case, ignoring could be more accurate, see the issue #3673 for details.

Thanks.

@un-pogaz
Copy link
Author

@Kristinita I suggest you to take a look at the already existing feature --exclude-file: each line into the given file will be ignore by codespell.
Since codespell ignore only the exact lines provided into the exclude file, and since the probability that your code will contain exactly the same line several times in different files, you can exclude some error with even greater precision than --per-file-ignore.

--per-file-ignore is an intermediate solution that target when --exclude-file will be too tedious to use (to many lines) and too risky to completely ignore the word globally with --ignore-words-list.

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

Successfully merging this pull request may close these issues.

New setting: per-file-ignores to ignores specific words into specific files
3 participants