Skip to content

Inline comments in the ignore section are being validated in setup.cfg #1750

Closed
@thomasjpfan

Description

how did you install flake8?

pip install flake8==6.0.0

unmodified output of flake8 --bug-report

{
  "platform": {
    "python_implementation": "CPython",
    "python_version": "3.10.8",
    "system": "Darwin"
  },
  "plugins": [
    {
      "plugin": "mccabe",
      "version": "0.7.0"
    },
    {
      "plugin": "pycodestyle",
      "version": "2.10.0"
    },
    {
      "plugin": "pyflakes",
      "version": "3.0.0"
    }
  ],
  "version": "6.0.0"
}

Note I needed to remove the inline comment for flake8 --bug-report to not raise an error.

describe the problem

what I expected to happen

I expect no error when there are inline comments in the ignore section from setup.cfg

...

sample code

Given the following setup.cfg

# setup.cfg
[flake8]
max-line-length = 88
target-version = ['py38']
ignore=
    E24,   # check ignored by default in flake8. Meaning unclear.

commands ran

$ flake8 --version

With trackback:

Traceback (most recent call last):
  File "_/bin/flake8", line 8, in <module>
    sys.exit(main())
  File "_/lib/python3.10/site-packages/flake8/main/cli.py", line 23, in main
    app.run(argv)
  File "_/lib/python3.10/site-packages/flake8/main/application.py", line 198, in run
    self._run(argv)
  File "_/lib/python3.10/site-packages/flake8/main/application.py", line 186, in _run
    self.initialize(argv)
  File "_/lib/python3.10/site-packages/flake8/main/application.py", line 165, in initialize
    self.plugins, self.options = parse_args(argv)
  File "_/lib/python3.10/site-packages/flake8/options/parse_args.py", line 53, in parse_args
    opts = aggregator.aggregate_options(option_manager, cfg, cfg_dir, rest)
  File "_/lib/python3.10/site-packages/flake8/options/aggregator.py", line 30, in aggregate_options
    parsed_config = config.parse_config(manager, cfg, cfg_dir)
  File "_/lib/python3.10/site-packages/flake8/options/config.py", line 131, in parse_config
    raise ValueError(
ValueError: Error code '#' supplied to 'ignore' option does not match '^[A-Z]{1,3}[0-9]{0,3}$'

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions