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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ jobs:
- name: Install
run: python -m pip install .
- name: Test
working-directory: .github/workflows/test
run: pflake8
run: python -m unittest discover -v -s test
2 changes: 0 additions & 2 deletions .github/workflows/test/pyproject.toml

This file was deleted.

1 change: 0 additions & 1 deletion .github/workflows/test/testfile.py

This file was deleted.

7 changes: 5 additions & 2 deletions pflake8/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ def _read(self, fp, filename):
)

for section, config in section_to_copy.items():
self.add_section(section)
self._sections[section] = self._dict(config)
try:
self.add_section(section)
except (configparser.DuplicateSectionError):
pass
self._sections.setdefault(section, self._dict()).update(self._dict(config))
else:
super(ConfigParserTomlMixin, self)._read(fp, filename)

Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ name = "pflake8"

[tool.black]
skip-string-normalization = 1
force-exclude = [
"test/data/dummy.py",
]

[tool.isort]
profile = "black"
Expand All @@ -35,4 +38,4 @@ multi_line_output = 3
max-line-length = 88
extend-ignore = ["E203"]
max-complexity = 10
exclude = "venv"
exclude = ["venv", "test/data/"]
5 changes: 5 additions & 0 deletions test/data/dummy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
d = {"a" : 1} # E203


def a_long_name_function_definition(x="this is a test for", y="--max-line-length setting."): # E501
pass
2 changes: 2 additions & 0 deletions test/data/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tool.flake8]
extend-ignore = ["E203"]
2 changes: 2 additions & 0 deletions test/data/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
max-line-length = 120
2 changes: 2 additions & 0 deletions test/data/setup_custom.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
extend-ignore = E203
33 changes: 33 additions & 0 deletions test/test_append_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import sys
import unittest
import pflake8


class TestAppendConfig(unittest.TestCase):
def test_append_config_toml(self):
sys.argv = [
"pflake8",
"--config",
"./test/data/setup.cfg",
"--append-config",
"./test/data/pyproject.toml",
"./test/data/dummy.py",
]

pflake8.main() # OK if this raises no exception.

def test_append_config_normal(self):
sys.argv = [
"pflake8",
"--config",
"./test/data/setup.cfg",
"--append-config",
"./test/data/setup_custom.cfg",
"./test/data/dummy.py",
]

pflake8.main() # OK if this raises no exception.


if __name__ == '__main__':
unittest.main()
Loading