ikamensh / flynt

A tool to automatically convert old string literal formatting to f-strings
MIT License
689 stars 33 forks source link

using # noqa: flynt results in ruff warnings #197

Open pschwaller opened 6 months ago

pschwaller commented 6 months ago

I found a reference in the github issues to using "# noqa: flynt" to tell flynt not to process a particular line.

When I use that with the latest ruff, I get: warning: Invalid # noqa directive

Is there an alternative that doesn't generate warnings?

ikamensh commented 3 months ago

I can't reproduce the issue, what is the version of ruff you are using?

Furthermore, you could consider moving this issue to ruff repo. If this is reproducible on latest ruff, I'd say its ambitious of ruff to expect to know every other tool that might work with noqa directive.

pschwaller commented 3 months ago

Reproduction steps:

    bar = "bar"
    foo = "asdf" + bar 

Flynt correctly complains. For whatever reason, I want flynt to ignore this, so I change it to:

    bar = "bar"
    foo = "asdf" + bar  # noqa: flynt

That quiets flynt.

ruff 0.4.8 complains with: warning: Invalid# noqadirective on engine\pjs_sandbox.py:175: expected a comma-separated list of codes (e.g.,# noqa: F401, F841).

I'm not expecting ruff to know about the way flynt has chosen to overload the noqa directive. What I'm asking is whether there is an alternative method for flynt to turn itself off on a particular line -- one that doesn't overlap with the conventions used by other tools.

For example, for some messages mypy uses the standard noqa. But for others, I have to use # mypy: disable-error-code="xyz"