question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

add inline ignore comment

See original GitHub issue

I 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.

link to docs

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:closed
  • Created a year ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
asottilecommented, Apr 6, 2022

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

1reaction
asottilecommented, Apr 5, 2022

in the future please search the issue tracker – #574

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found