Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a support of --append-config #29

Merged
merged 2 commits into from
Apr 9, 2024

Conversation

i-aki-y
Copy link
Contributor

@i-aki-y i-aki-y commented Nov 21, 2023

The flake8 supports --append-config option that overwrites a default config that is automatically loaded (or specified in --config).
But the current pflake8 raises error when pyproject.toml set in --append-config:

# pflake8 --append-config pyproject.toml
Traceback (most recent call last):
  File "/opt/conda/bin/pflake8", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/conda/lib/python3.11/site-packages/flake8/main/cli.py", line 23, in main
    app.run(argv)
  File "/opt/conda/lib/python3.11/site-packages/flake8/main/application.py", line 198, in run
    self._run(argv)
  File "/opt/conda/lib/python3.11/site-packages/flake8/main/application.py", line 186, in _run
    self.initialize(argv)
  File "/opt/conda/lib/python3.11/site-packages/flake8/main/application.py", line 165, in initialize
    self.plugins, self.options = parse_args(argv)
                                 ^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/site-packages/flake8/options/parse_args.py", line 29, in parse_args
    cfg, cfg_dir = config.load_config(
                   ^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/site-packages/flake8/options/config.py", line 90, in load_config
    if not cfg.read(filename, encoding="UTF-8"):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/conda/lib/python3.11/configparser.py", line 713, in read
    self._read(fp, filename)
  File "/opt/conda/lib/python3.11/site-packages/pflake8/__init__.py", line 35, in _read
    self.add_section(section)
  File "/opt/conda/lib/python3.11/configparser.py", line 674, in add_section
    raise DuplicateSectionError(section)
configparser.DuplicateSectionError: Section 'flake8' already exists

This PR allows to use pyproject.toml in --append-config.
I also added simple test cases.

i-aki-y and others added 2 commits November 21, 2023 22:10

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@csachs csachs force-pushed the support-append-config branch from b002384 to a9bb2c4 Compare April 9, 2024 21:39
@csachs
Copy link
Owner

csachs commented Apr 9, 2024

Thanks for the PR.

@csachs csachs merged commit d7cd9b8 into csachs:main Apr 9, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants