-
Notifications
You must be signed in to change notification settings - Fork 468
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
Support inline ignores #1212
Comments
Or something like pylint does where you say |
This is a must when using codespell with a large multi-dev project, because you don't want to then alter the whitelist for every individual thing and what is correct in some contexts is not correct in others, so similar to pylint, flake8, etc adding a inline comment that tells codespell to ignore that particular line would be very welcome! |
What about extending the ignore file format to have a second column restricting the entry to being used for the given file or, better, giving line or range of lines in the given file? Sometimes you can't modify the sources themselves, but you can always add a file with codespell exceptions. |
In my case I don't want to change some project level thing for my one file that needs an exclusion and where in some contexts I need the exception, while in other contexts it doesn's and should be flagged, so just the single line to be ignored would be far the easiest then, my case is with Home Assistant, where all the integrations are created independently of the main but there is a pre-commit hook with codespell, that shouldn't be updated by individual developers working on single things, but mine failed because I had a field coming from a external service that I had to check against which was flagged by codespell, I ended up having to move the checking list to a seperate json file (which were excluded by the project level codespell config) but it made my code more complex (reading a external file, instead of just a constant in a dict). |
The For example: |
Thanks for the |
Any updates on this? |
If Then someone (not necessarily the same person) will need to implement it. Suggestions and pull requests welcome. |
Maybe someone can tell me how to avoid codespell yelling about that python line |
I have a test with following chunked encoded packet. It thinks
|
Quickest hack is to add following at top of the file: .. spelling::
nd |
So @ssbarnea and @abhinavsingh (and others on this thread), you've currently got a few options, in rough order from simplest, but biggest impact on finding other typos through the most complicated but restricted.
I'm not aware of that syntax, is it specific to Jupyter notebooks? |
@peternewman No I should have came back to fix that. I mixed it with |
This will be much better. Will likely fix it in coming days. |
Ah that makes sense.
I'm glad that's an improvement for you. |
I'd still like to have inline waivers. I have one single place in one single file where I legitimately want to use the string "ERRO". I don't want to skip the file, because it might have other problems in it later. I don't want to allowlist that word, because if it appears anywhere else it's probably a mistake. I just want codespell to trust me that I know what I'm doing in this one particular case. |
I think I need inline waivers because I have contributed code to a large open source project, and am blocked from committing documentation for it because codespell thinks my attribute How about
That is, a line possibly containing other text (e.g. comment characters for whatever language), followed by at least one whitespace, followed by the string Additionally one could envision
As a way to specify strings to ignore in the current file from this line on. |
very needed feature |
Fixes codespell-project#1212 Following @rob-miller's suggestion implement inline ignore hints. E.g. ``` crate // codespell:ignore crate abandonned abondon abilty # codespell:ignore abondon,abilty abandonned abondon abilty # codespell:ignore # to ignore all ```
Fixes codespell-project#1212 Following @rob-miller's suggestion implement inline ignore hints. E.g. ``` crate // codespell:ignore crate abandonned abondon abilty # codespell:ignore abondon,abilty abandonned abondon abilty # codespell:ignore # to ignore all ```
Why not give @rob-miller's idea an implementation #2400? Look at the tests https://github.com/codespell-project/codespell/pull/2400/files#diff-02a558d6c6bc59b5b9e5c7fc4d54893d875b4d7cceecfc151b9d729688bef061 Is this safe enough, too naive, too strict? Supports |
Please make it compatible with cspell and we will all be happy, no need to implement all features supported by cspell. Check https://cspell.org/configuration/document-settings/ for ignore syntax, so we would not have to write two different sets of inline-ignores if we use both tools. |
@ssbarnea Honestly, erm probably no. Using |
True that it makes little sense to use a namespace of another project but if i remember well cspell can also use a generic namespace, like spell, spelling, -- need to dig as I do not remember exactly. At this moment I reuse the whitelist between the two projects. |
One problem that I am hitting with In Toolbx, I have this string
Driven by paranoia, OCD and this absurd desire to avoid maintaining another auxiliary file for
I put in my |
Fixes codespell-project#1212 Following @rob-miller's suggestion implement inline ignore hints. E.g. ``` crate // codespell:ignore crate abandonned abondon abilty # codespell:ignore abondon,abilty abandonned abondon abilty # codespell:ignore # to ignore all ```
Fixes codespell-project#1212 Following @rob-miller's suggestion implement inline ignore hints. E.g. ``` crate // codespell:ignore crate abandonned abondon abilty # codespell:ignore abondon,abilty abandonned abondon abilty # codespell:ignore # to ignore all ```
@kaste looking at the link @ssbarnea gave
Supported namespaces:
" I'm the maintainer of cspell's in doc settings parser is using regex unfortunately. I think it'd be nice to formalize what is supported / how. Personally, the part that doesn't thrill me is having to track the comment rules per language as that is a large can of worms (which syntax, whether nesting is supported, being exhaustive enough, etc).. |
I was reading this thread and it seems that not all people are convinced of the interest of such a feature so let me give a real life example: in my lib I need to gather some data from USDA wich associate a US state to a 2 letter code. I thus store a boring dictionnary at the start of my module: ASSET_CODES = {
"Alabama": "AL", "Arkansas": "AR", "Arizona": "AZ", "California": "CA", "Colorado": "CO",
"Connecticut": "CT", "Delaware": "DE", "Georgia": "GA", "Florida": "FL", "Iowa": "IA", "Idaho": "ID",
"Illinois": "IL", "Indiana": "IN", "Kansas": "KS", "Kentucky": "KY", "Louisiana": "LA", "Massachusetts": "MA",
"Maryland": "MD", "Maine": "ME", "Michigan": "MI", "Minnesota": "MN", "Missouri": "MO", "Mississippi": "MS",
"Montana": "MT", "Nebraska": "NE", "New Hampshire": "NH", "New Jersey": "NJ", "New Mexico": "NM",
"Nevada": "NV", "New York": "NY", "North Carolina": "NC", "North Dakota": "ND", "Ohio": "OH", "Oklahoma": "OK",
"Oregon": "OR", "Pennsylvania": "PA", "Rhode Island": "RI", "South Carolina": "SC", "South Dakota": "SD",
"Tennessee": "TN", "Texas": "TX", "Utah": "UT", "Vermont": "VT", "Virginia": "VA", "Washington": "WA",
"West Virginia": "WV", "Wisconsin": "WI", "Wyoming": "WY",
} When I run the code spell pre-commit, it falls on "ND" which is the code for Nevada and offers me to replace it with "AND" or "2ND". I have 0 guarantee that this dict will remain where it is so skipping a specific line number in the file is out of question. I don't want to add "ND" to the ignore dictionary because I still want this to be corrected elsewhere. I don't want to skip the whole file because there are many other things here. In this situation it would make perfect sense to add Note that for black I use |
I came up with a simple idea to "emulate" inline code ignores: codespell --ignore-regex=".*codespell-ignore$" This will ignore any line that contains |
Neat! Though, in case anyone else tries it, it took several minutes to run for me. |
... following on from that, I've tweaked the regex to |
For our project, I think we are going to write a driver script for codespell that runs codespell file-by-file and allows you to specify additional works to ignore on a file-by-file basis. Anyone else already do this? See: I would hate to have to create and maintain a simple driver tool but it may be worth it to allow for file-by-file specific ignores. |
Fixes codespell-project#1212 Following @rob-miller's suggestion implement inline ignore hints. E.g. ``` crate // codespell:ignore crate abandonned abondon abilty # codespell:ignore abondon,abilty abandonned abondon abilty # codespell:ignore # to ignore all ```
FYI: On reddit I opened a question if it might be possible to ignore the next line.
|
I'd like to use codespell as part of an automated check workflow. For that I need to be able to ignore certain cases on a per instance bases.
Here's an example. In the code base there is a command called 'Trim All'. The comment contains a statement like:
// Track how many Trim Alls have been issued.
codespell finds Alls as a possible error.
I don't want to add 'Alls' to the ignore words list as it could be a real error in other cases. But I don't want this message generated on every run either.
The ignore word list only supports single words So I can't do 'Trim Alls' as an ignore.
Some sort of in line keystring that allows the next occurrence of a specific word error would be useful. Most code formatters, pretty-printers, and static analysis tools have some sort of inline // disable-whatever option that allows you to skip the trigger on a per instance basis.
The text was updated successfully, but these errors were encountered: