add inline ignore comment
See original GitHub issueI have a py3.10 code base and run pyupgrade via pre-commit.
In this code base I use pydantic models which use
standard library typing types as defined in PEP 484 to define complex objects.
So I have to define a model like this (example from docs):
from typing import List
from pydantic import BaseModel
class Model(BaseModel):
simple_list: list = None
list_of_ints: List[int] = None
Which in turn gets modified by pyupgrade:
class Model(BaseModel):
simple_list: list = None
- list_of_ints: List[int] = None
+ list_of_ints: list[int] = None
And this results in a RuntimeError
from pydantic.
To prevent this I currently use the workaround of skiping the model files whole which I luckily have in their own subpackage by ignoring them via the pre-commit config. But skiping them whole is a strong solution and I would rather skip single lines with something like a # noqa
comment of some sort.
Issue Analytics
- State:
- Created a year ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Turning off eslint rule for a specific line - Stack Overflow
Answer. You can use an inline comment: // eslint-disable-next-line rule-name ...
Read more >How to disable ESLint for some lines, files or folders
To temporarily turn off ESLint, you should add a block comment /* eslint-disable */ before the lines that you're interested in:.
Read more >no-inline-comments - ESLint - Pluggable JavaScript Linter
To make this rule ignore specific comments, set the ignorePattern option to a string pattern that will be passed to the RegExp constructor....
Read more >Allow config to ignore comments that disable rules inline #8824
I want to ignore the comments that disable rules inline and I want to get errors for files that disable rules inline. What...
Read more >Ignore Lines and Files In ESLint - Mastering JS
Disabling ESLint With a Comment ... The // eslint-disable-line comment disables the no-eval rule for just that line. You can also disable the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
ok so as I suspected, not a pyupgrade bug but a bug in a third party tool – if you would have led with the actual stacktrace you saw this would have been very obvious and would have saved us all time
in the future, please describe your actual problem rather than jumping to prescribing a solution – I’ve put together a quick tutorial which outlines a strategy for making bug reports: https://youtu.be/ritp4gAqNMI
in the future please search the issue tracker – #574