Conversation
…x justfile docs bug
There was a problem hiding this comment.
Pull request overview
This PR addresses #144 by improving the library’s static typing story so enums derived from enum-properties expose the same type-hint interface as standard library Enum classes. It does this primarily by introducing a shipped .pyi stub for enum_properties and adding dedicated type-hint probe tests, while also bumping the package to v2.5.0 and dropping Python 3.9 support.
Changes:
- Add
src/enum_properties/__init__.pyito provide a typed public API aligned with stdlibEnum/Flagbehaviors. - Add a new
tests/type_hints/suite to probe typing behavior (mypy/pyright) and expand typing tool configs to include these tests. - Raise minimum supported Python to 3.10 (update
pyproject.toml, CI matrices, and lockfile), plus doc/changelog/version updates.
Reviewed changes
Copilot reviewed 14 out of 16 changed files in this pull request and generated 17 comments.
Show a summary per file
| File | Description |
|---|---|
src/enum_properties/__init__.pyi |
New public type stub defining metaclass + enum bases to match stdlib typing expectations. |
tests/type_hints/test.py |
New typing probe test module validating Enum/Flag behaviors and member typing. |
pyproject.toml |
Bumps version/min Python and updates mypy/pyright scope to include typing tests. |
.github/workflows/test.yml |
Drops Python 3.9 from test matrix to match new min version. |
.github/workflows/lint.yml |
Drops Python 3.9 from lint matrix; still runs typing checks. |
uv.lock |
Lockfile updated for new Python constraint and dependency set. |
tests/annotations/test.py |
Typing-related tweaks (overloads/ignores) to satisfy checkers. |
tests/annotations/test_flags.py |
Renames nested test enums to avoid collisions/shadowing. |
doc/source/changelog.rst |
Adds v2.5.0 entry referencing #144 and stub shipping. |
justfile |
Updates docs-live paths. |
LICENSE |
Updates copyright year. |
CONTRIBUTING.md |
Updates docs/test instructions. |
.pre-commit-config.yaml |
Removes typing pre-commit hook. |
tests/type_hints/pyright.json |
Adds a local pyright config for typing tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/enum_properties/__init__.pyi
Outdated
| @overload | ||
| def __call__( | ||
| cls, | ||
| value: str, | ||
| names: str | Iterable[str] | Iterable[Iterable[str | Any]] | Mapping[str, Any], | ||
| *, | ||
| module: str | None = None, | ||
| qualname: str | None = None, | ||
| type: type | None = None, | ||
| start: int = 1, | ||
| boundary: enum.FlagBoundary | None = None, | ||
| ) -> type[enum.Enum]: ... | ||
| @overload |
There was a problem hiding this comment.
The stub references enum.FlagBoundary, which is not available on Python 3.10. Because the package supports 3.10, this can cause type-checking failures when running mypy/pyright under 3.10. Consider guarding this type with a sys.version_info check in the stub or using a looser type (e.g., Any) for the boundary parameter on <3.11.
| @overload | |
| def __call__( | |
| cls, | |
| value: str, | |
| names: str | Iterable[str] | Iterable[Iterable[str | Any]] | Mapping[str, Any], | |
| *, | |
| module: str | None = None, | |
| qualname: str | None = None, | |
| type: type | None = None, | |
| start: int = 1, | |
| boundary: enum.FlagBoundary | None = None, | |
| ) -> type[enum.Enum]: ... | |
| @overload | |
| if sys.version_info >= (3, 11): | |
| @overload | |
| def __call__( | |
| cls, | |
| value: str, | |
| names: str | Iterable[str] | Iterable[Iterable[str | Any]] | Mapping[str, Any], | |
| *, | |
| module: str | None = None, | |
| qualname: str | None = None, | |
| type: type | None = None, | |
| start: int = 1, | |
| boundary: enum.FlagBoundary | None = None, | |
| ) -> type[enum.Enum]: ... | |
| else: | |
| @overload | |
| def __call__( | |
| cls, | |
| value: str, | |
| names: str | Iterable[str] | Iterable[Iterable[str | Any]] | Mapping[str, Any], | |
| *, | |
| module: str | None = None, | |
| qualname: str | None = None, | |
| type: type | None = None, | |
| start: int = 1, | |
| boundary: Any = None, | |
| ) -> type[enum.Enum]: ... | |
| @overload |
| self.assertTrue((0, 1, 0) != Color.RED) | ||
| self.assertTrue(Color.RED == "0xFF0000") | ||
| self.assertTrue("0xFF0000" == Color.RED) | ||
| self.assertTrue(Color2.RED == (1, 0, 0)) |
There was a problem hiding this comment.
assertTrue(a == b) cannot provide an informative message. Using assertEqual(a, b) instead will give more informative messages.
| self.assertTrue(Color2.RED == (1, 0, 0)) | |
| self.assertEqual(Color2.RED, (1, 0, 0)) |
| from __future__ import annotations | ||
|
|
||
| from enum import Enum, Flag, IntEnum, IntFlag, StrEnum | ||
| from typing import TYPE_CHECKING, Any, Literal |
There was a problem hiding this comment.
Import of 'TYPE_CHECKING' is not used.
| from typing import TYPE_CHECKING, Any, Literal | |
| from typing import Any, Literal |
| class FlagProperties( # pyright: ignore[reportIncompatibleMethodOverride,reportIncompatibleVariableOverride] | ||
| DecomposeMixin, SymmetricMixin, enum.Flag, metaclass=EnumPropertiesMeta | ||
| ): |
There was a problem hiding this comment.
Base classes have conflicting values for attribute 'missing': classmethod() and classmethod().
| class IntFlagProperties( # pyright: ignore[reportIncompatibleMethodOverride,reportIncompatibleVariableOverride] | ||
| DecomposeMixin, SymmetricMixin, enum.IntFlag, metaclass=EnumPropertiesMeta | ||
| ): |
There was a problem hiding this comment.
Base classes have conflicting values for attribute 'missing': classmethod() and classmethod().
| class FlagProperties( # pyright: ignore[reportIncompatibleMethodOverride,reportIncompatibleVariableOverride] | ||
| DecomposeMixin, SymmetricMixin, enum.Flag, metaclass=EnumPropertiesMeta | ||
| ): |
| class IntFlagProperties( # pyright: ignore[reportIncompatibleMethodOverride,reportIncompatibleVariableOverride] | ||
| DecomposeMixin, SymmetricMixin, enum.IntFlag, metaclass=EnumPropertiesMeta | ||
| ): |
fixes #144
We had to add a stub file to do this.