pythonpre-commitflake8

How to make Flake8 ignore syntax within strings?


I'm suddenly getting flake8 errors for syntax within strings.

For example, for the following line of code:

    tags.append(f'error_type:{error.get("name")}')

I'm getting this error: E231 missing whitespace after ':'.

I don't want to ignore all E231 errors, because I care about them when they don't refer to text within strings.

I also don't want to have to go and add # noqa comments to each of my strings.

I've tried to pin my flake8 version to 6.0.0 (which is the version that previously didn't raise these errors before).

I'm running flake8 with pre-commit (if that is relevant).

Why am I suddenly getting these errors for strings and how can I turn them off?

I should also mention that this is happening in Github Actions, specifically.


Solution

  • This issue seems limited to Python 3.12+ and it was fixed by flake8 version 6.1.0.

    The errors stopped appearing when I upgrade to flake8 6.1.0.