Skip to content

Commit

Permalink
Merge branch 'main' into support_flake8_700
Browse files Browse the repository at this point in the history
  • Loading branch information
csachs committed Apr 9, 2024
2 parents 94f0789 + 992fb28 commit 0596fc9
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 27 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: psf/black@stable
with:
version: "22.10.0"
version: "24.3.0"
17 changes: 9 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,26 @@ on: [push]
jobs:
build:
runs-on: ubuntu-latest
environment: release
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
strategy:
matrix:
python-version: ["3.11"]
python-version: ["3.12"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: python -m pip install --upgrade pip wheel build
- name: Building packages
run: python -m build
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: package
path: dist/*
- name: Publish distribution to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@v1.5.1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
uses: pypa/gh-action-pypi-publish@v1.8.14
6 changes: 3 additions & 3 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
python-version: ["3.12"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
name: Python ${{ matrix.python-version }} testing
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- 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.

20 changes: 15 additions & 5 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 All @@ -52,13 +55,20 @@ class DivertingConfigParser(ConfigParserTomlMixin, configparser.ConfigParser):
pass


class DivertingSafeConfigParser(ConfigParserTomlMixin, configparser.SafeConfigParser):
pass
try:

class DivertingSafeConfigParser(
ConfigParserTomlMixin, configparser.SafeConfigParser
):
pass

configparser.SafeConfigParser = DivertingSafeConfigParser
except AttributeError:
pass # does not exist on Python 3.12 (https://github.com/python/cpython/issues/89336#issuecomment-1094366625)


configparser.RawConfigParser = DivertingRawConfigParser
configparser.ConfigParser = DivertingConfigParser
configparser.SafeConfigParser = DivertingSafeConfigParser


class FixFilenames(ast.NodeTransformer):
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 0596fc9

Please sign in to comment.