Skip to content
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
5 changes: 2 additions & 3 deletions .github/workflows/conda_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/docs_test_action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ on:
- 'imgbot'
pull_request:

permissions:
contents: read

jobs:
docs:
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ on:
- 'imgbot'
pull_request:

permissions:
contents: read

jobs:
Run:
name: "Flake8"
permissions:
contents: read
runs-on: "ubuntu-22.04"

steps:
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ on:
- 'imgbot'
pull_request:

permissions:
contents: read

jobs:
Run:
permissions:
contents: read
name: "mypy / ${{ matrix.os }}"
runs-on: ${{ matrix.os }}

Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/octocheese.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/python_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
18 changes: 12 additions & 6 deletions .github/workflows/python_ci_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -85,6 +83,9 @@ jobs:

Coverage:
needs: tests
permissions:
actions: write
contents: read
runs-on: "ubuntu-22.04"
steps:
- name: Checkout 🛎️
Expand Down Expand Up @@ -134,7 +135,10 @@ jobs:

Deploy:
needs: tests

permissions:
actions: write
issues: write
contents: read
runs-on: "ubuntu-22.04"
steps:
- name: Checkout 🛎️
Expand Down Expand Up @@ -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:
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/python_ci_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
7 changes: 4 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .style.yapf
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion enum_tools/autoenum.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
28 changes: 6 additions & 22 deletions formate.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 17 additions & 12 deletions tests/test_autoenum.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, '')

Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/test_documented_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)


Expand Down Expand Up @@ -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 .*!"):
Expand All @@ -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 .*!"):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)


Expand Down Expand Up @@ -112,7 +112,7 @@

class SecondFailedStrEnum(StrEnum):
one = '1'
two = 2,

Check notice on line 115 in tests/test_enums.py

View check run for this annotation

codefactor.io / CodeFactor

tests/test_enums.py#L115

Disallow trailing comma tuple (trailing-comma-tuple)
three = '3'

with pytest.raises(TypeError, match="2 is not a string"):
Expand Down
6 changes: 3 additions & 3 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand Down
Loading