Skip to content

Commit

Permalink
Merge pull request #29 from i-aki-y/support-append-config
Browse files Browse the repository at this point in the history
Add a support of `--append-config`
  • Loading branch information
csachs committed Apr 9, 2024
2 parents fbb9d72 + a9bb2c4 commit d7cd9b8
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 8 deletions.
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()

0 comments on commit d7cd9b8

Please sign in to comment.