ValueError: Error code 'I2041' supplied to 'ignore' option does not match '^[A-Z]{1,3}[0-9]{0,3}$'


Upon importing this flake8 plugin flake8-import-restrictions==1.1.1, I’ve notice this error appeared. I tried ignoring it by adding it to my setup.cfg file ignore option as shown below.

ensure_newline_before_comments = True
line_length = 100
src_paths = myproject,tests
skip= .gitignore, .env
skip_glob=env/*, spec/*

ignore = D413, E203, E266, E501, E711, F401, F403, I2041, W503
max-line-length = 100
max-complexity = 18
application-import-names = myproject,tests
import-order-style = google
exclude = tests/integration/.env.shadow, env

max-line-length = 100

disable = C0330, C0326

However, flake8 appears to not like this ignore option:

  File "/Users/gree030/Workspace/myproject/env/lib/python3.8/site-packages/flake8/options/", line 131, in parse_config
    raise ValueError(
ValueError: Error code 'I2041' supplied to 'ignore' option does not match '^[A-Z]{1,3}[0-9]{0,3}$'

What I have Tried

  • uninstalling the plugin to verify it’s that particular plugin

Of course to not see this error would mean I would have to uninstall the plugin. However, I would really like to use this flake8 plugin. How can this be resolved?

Asked By: Khalil



flake8 does not support 4 digit codes — before this used to silently "work" but would fail in many situations surprisingly.

in flake8 6.0 the silent failure was upgraded to a noisy failure. the plugin in question should adapt its error code structure to match the expected code structure (usually 1-3 letters followed by 3 numbers)

this is a problem with that particular plugin and not with flake8 itself

disclaimer: I’m the flake8 maintainer

Answered By: anthony sottile
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.