diff --git a/.github/workflows/conda_ci.yml b/.github/workflows/conda_ci.yml index 31bd0bf..31856fa 100644 --- a/.github/workflows/conda_ci.yml +++ b/.github/workflows/conda_ci.yml @@ -6,12 +6,11 @@ on: push: branches: ["master"] -permissions: - contents: read - jobs: tests: name: "Conda" + permissions: + contents: read runs-on: ubuntu-22.04 defaults: run: diff --git a/.github/workflows/docs_test_action.yml b/.github/workflows/docs_test_action.yml index 761b41f..39ae450 100644 --- a/.github/workflows/docs_test_action.yml +++ b/.github/workflows/docs_test_action.yml @@ -9,11 +9,10 @@ on: - 'imgbot' pull_request: -permissions: - contents: read - jobs: docs: + permissions: + contents: read runs-on: ubuntu-latest steps: - name: Checkout 🛎️ diff --git a/.github/workflows/flake8.yml b/.github/workflows/flake8.yml index 5e67c5c..1ecb7b9 100644 --- a/.github/workflows/flake8.yml +++ b/.github/workflows/flake8.yml @@ -10,12 +10,11 @@ on: - 'imgbot' pull_request: -permissions: - contents: read - jobs: Run: name: "Flake8" + permissions: + contents: read runs-on: "ubuntu-22.04" steps: diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml index 4c22a52..b889816 100644 --- a/.github/workflows/mypy.yml +++ b/.github/workflows/mypy.yml @@ -10,11 +10,10 @@ on: - 'imgbot' pull_request: -permissions: - contents: read - jobs: Run: + permissions: + contents: read name: "mypy / ${{ matrix.os }}" runs-on: ${{ matrix.os }} diff --git a/.github/workflows/octocheese.yml b/.github/workflows/octocheese.yml index c315b0a..85397d6 100644 --- a/.github/workflows/octocheese.yml +++ b/.github/workflows/octocheese.yml @@ -6,11 +6,10 @@ on: schedule: - cron: 0 12 * * * -permissions: - contents: write - jobs: Run: + permissions: + contents: write runs-on: ubuntu-latest steps: - uses: domdfcoding/octocheese@master diff --git a/.github/workflows/python_ci.yml b/.github/workflows/python_ci.yml index 29a6a95..fdfe27c 100644 --- a/.github/workflows/python_ci.yml +++ b/.github/workflows/python_ci.yml @@ -11,13 +11,11 @@ on: pull_request: -permissions: - actions: write - issues: write - contents: read - jobs: tests: + permissions: + actions: write + contents: read name: "windows-2022 / Python ${{ matrix.config.python-version }}" runs-on: "windows-2022" continue-on-error: ${{ matrix.config.experimental }} diff --git a/.github/workflows/python_ci_linux.yml b/.github/workflows/python_ci_linux.yml index 39fdaee..0f17dbe 100644 --- a/.github/workflows/python_ci_linux.yml +++ b/.github/workflows/python_ci_linux.yml @@ -12,13 +12,11 @@ on: - '*' pull_request: -permissions: - actions: write - issues: write - contents: read - jobs: tests: + permissions: + actions: write + contents: read name: "ubuntu-22.04 / Python ${{ matrix.config.python-version }}" runs-on: "ubuntu-22.04" continue-on-error: ${{ matrix.config.experimental }} @@ -85,6 +83,9 @@ jobs: Coverage: needs: tests + permissions: + actions: write + contents: read runs-on: "ubuntu-22.04" steps: - name: Checkout 🛎️ @@ -134,7 +135,10 @@ jobs: Deploy: needs: tests - + permissions: + actions: write + issues: write + contents: read runs-on: "ubuntu-22.04" steps: - name: Checkout 🛎️ @@ -179,6 +183,8 @@ jobs: Conda: needs: deploy + permissions: + contents: read runs-on: ubuntu-22.04 if: startsWith(github.ref, 'refs/tags/') || (startsWith(github.event.head_commit.message, 'Bump version') != true) steps: diff --git a/.github/workflows/python_ci_macos.yml b/.github/workflows/python_ci_macos.yml index 7e9fc21..f7a6f5d 100644 --- a/.github/workflows/python_ci_macos.yml +++ b/.github/workflows/python_ci_macos.yml @@ -11,13 +11,11 @@ on: pull_request: -permissions: - actions: write - issues: write - contents: read - jobs: tests: + permissions: + actions: write + contents: read name: "macos-${{ matrix.config.os-ver }} / Python ${{ matrix.config.python-version }}" runs-on: "macos-${{ matrix.config.os-ver }}" continue-on-error: ${{ matrix.config.experimental }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f073fdb..9557a63 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -18,7 +18,6 @@ repos: - id: check-added-large-files - id: check-ast - id: fix-byte-order-marker - - id: check-byte-order-marker - id: check-case-conflict - id: check-executables-have-shebangs - id: check-json @@ -81,13 +80,15 @@ repos: - id: snippet-fmt - repo: https://github.com/python-formate/formate - rev: v0.8.0 + rev: v0.9.0 hooks: - id: formate exclude: ^(doc-source/conf|__pkginfo__|setup)\.(_)?py$ + additional_dependencies: + - formate-trailing-commas>=0.1.1 - repo: https://github.com/python-coincidence/dep_checker - rev: v0.8.0 + rev: v0.9.0 hooks: - id: dep_checker args: diff --git a/.style.yapf b/.style.yapf index e64be7c..9378f04 100644 --- a/.style.yapf +++ b/.style.yapf @@ -312,7 +312,7 @@ split_before_dict_set_generator=True # # foo = ('This is a really long string: {}, {}, {}, {}' # .format(a, b, c, d)) -split_before_dot=False +split_before_dot=True # Split after the opening paren which surrounds an expression if it doesn't # fit on a single line. diff --git a/README.rst b/README.rst index fa08ff3..2d7563d 100644 --- a/README.rst +++ b/README.rst @@ -113,7 +113,7 @@ Enum Tools :alt: Maintenance .. |pypi-downloads| image:: https://img.shields.io/pypi/dm/enum_tools - :target: https://pypi.org/project/enum_tools/ + :target: https://pypistats.org/packages/enum_tools :alt: PyPI - Downloads .. end shields diff --git a/enum_tools/autoenum.py b/enum_tools/autoenum.py index 63cbb84..24de90e 100644 --- a/enum_tools/autoenum.py +++ b/enum_tools/autoenum.py @@ -448,7 +448,7 @@ def generate( more_content: Optional[Any] = None, real_modname: Optional[str] = None, check_module: bool = False, - all_members: bool = False + all_members: bool = False, ) -> None: """ Generate reST for the object given by ``self.name``, and possibly for its members. diff --git a/formate.toml b/formate.toml index 11ffd4f..1500be4 100644 --- a/formate.toml +++ b/formate.toml @@ -12,6 +12,12 @@ priority = 30 [hooks.yapf.kwargs] yapf_style = ".style.yapf" +[hooks.trailing_commas] +priority = 21 + +[hooks.trailing_commas.kwargs] +format_ImportFrom = false + [hooks.isort] priority = 50 @@ -27,28 +33,6 @@ lines_between_types = 0 use_parentheses = true remove_redundant_aliases = true default_section = "THIRDPARTY" -known_third_party = [ - "beautifulsoup4", - "coincidence", - "coverage", - "coverage_pyver_pragma", - "defusedxml", - "domdf_python_tools", - "html5lib", - "importlib_metadata", - "msgpack", - "pygments", - "pytest", - "pytest_cov", - "pytest_randomly", - "pytest_regressions", - "pytest_rerunfailures", - "pytest_timeout", - "sphinx", - "sphinx_prompt", - "sphinx_toolbox", - "typing_extensions", -] known_first_party = [ "enum_tools",] [config] diff --git a/justfile b/justfile index 6a4d335..9cd8b78 100644 --- a/justfile +++ b/justfile @@ -13,7 +13,7 @@ incomplete-defs: tox -e lint -- --select MAN commas: - tox -e lint -- --select C812,C813,C814,C815,C816 + tox -e lint -- --select C810,C812,C813,C814,C815,C816 vdiff: git diff $(repo-helper show version -q)..HEAD diff --git a/tests/test_autoenum.py b/tests/test_autoenum.py index 5f9c012..7c69465 100644 --- a/tests/test_autoenum.py +++ b/tests/test_autoenum.py @@ -22,19 +22,22 @@ xfail_312 = pytest.mark.xfail( reason="Python 3.14 behaviour has not been finalised yet.", - condition=sys.version_info[:2] == (3, 14) and sys.version_info.releaselevel == "alpha" + condition=sys.version_info[:2] == (3, 14) and sys.version_info.releaselevel == "alpha", ) -@pytest.mark.parametrize("obj", [ - "abcdefg", - b"abcdefg", - b"\x00\x01", - 12345, - 123.45, - Decimal(123.45), - Path('.'), - ]) +@pytest.mark.parametrize( + "obj", + [ + "abcdefg", + b"abcdefg", + b"\x00\x01", + 12345, + 123.45, + Decimal(123.45), + Path('.'), + ], + ) def test_cannot_document_member(obj: object): assert not EnumDocumenter.can_document_member(obj, '', True, '') @@ -112,9 +115,11 @@ def get_page_h1(page: BeautifulSoup) -> str: @xfail_312 @pytest.mark.parametrize( - "page", [ + "page", + [ "index.html", - ], indirect=True + ], + indirect=True, ) def test_index(page: BeautifulSoup, html_regression: HTMLRegressionFixture): # Make sure the page title is what you expect diff --git a/tests/test_documented_enum.py b/tests/test_documented_enum.py index cc16ba9..a307eef 100644 --- a/tests/test_documented_enum.py +++ b/tests/test_documented_enum.py @@ -18,7 +18,7 @@ xfail_314 = pytest.mark.xfail( reason="Python 3.14 behaviour has not been finalised yet.", - condition=sys.version_info[:2] == (3, 14) and sys.version_info.releaselevel == "alpha" + condition=sys.version_info[:2] == (3, 14) and sys.version_info.releaselevel == "alpha", ) @@ -115,7 +115,7 @@ def test_documented_enum(): Decimal, str, float, - ] + ], ) def test_document_enum_wrong_types(obj: object): with pytest.raises(TypeError, match="'an_enum' must be an 'Enum', not .*!"): @@ -138,7 +138,7 @@ def test_document_enum_wrong_types(obj: object): Decimal, str, float, - ] + ], ) def test_document_member_wrong_types(obj: object): with pytest.raises(TypeError, match="'an_enum' must be an 'Enum', not .*!"): diff --git a/tests/test_enums.py b/tests/test_enums.py index 56731c7..89158a9 100644 --- a/tests/test_enums.py +++ b/tests/test_enums.py @@ -18,7 +18,7 @@ xfail_314 = pytest.mark.xfail( reason="Python 3.14 behaviour has not been finalised yet.", - condition=sys.version_info[:2] == (3, 14) and sys.version_info.releaselevel == "alpha" + condition=sys.version_info[:2] == (3, 14) and sys.version_info.releaselevel == "alpha", ) diff --git a/tests/test_utils.py b/tests/test_utils.py index f45a593..f2a8dee 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -18,7 +18,7 @@ (http.HTTPStatus.NOT_ACCEPTABLE, False), (123, False), ("abc", False), - ] + ], ) def test_is_enum(obj: object, result: bool): assert is_enum(obj) == result # type: ignore[arg-type] @@ -32,7 +32,7 @@ def test_is_enum(obj: object, result: bool): (http.HTTPStatus.NOT_ACCEPTABLE, True), (123, False), ("abc", False), - ] + ], ) def test_is_enum_member(obj: object, result: bool): assert is_enum_member(obj) == result # type: ignore[arg-type] @@ -57,7 +57,7 @@ class Colours(enum.Flag): (Colours, True), (Colours.RED, False), (PURPLE, False), - ] + ], ) def test_is_flag(obj: object, result: bool): assert is_flag(obj) == result # type: ignore[arg-type]