enum-properties 2.2.3__tar.gz → 2.2.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {enum_properties-2.2.3 → enum_properties-2.2.5}/.github/workflows/lint.yml +1 -1
- {enum_properties-2.2.3 → enum_properties-2.2.5}/.github/workflows/release.yml +1 -1
- {enum_properties-2.2.3 → enum_properties-2.2.5}/.github/workflows/test.yml +4 -4
- {enum_properties-2.2.3 → enum_properties-2.2.5}/PKG-INFO +3 -3
- {enum_properties-2.2.3 → enum_properties-2.2.5}/README.md +2 -2
- {enum_properties-2.2.3 → enum_properties-2.2.5}/doc/source/changelog.rst +12 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/doc/source/howto.rst +20 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/doc/source/tutorial.rst +4 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/pyproject.toml +1 -1
- {enum_properties-2.2.3 → enum_properties-2.2.5}/src/enum_properties/__init__.py +1 -1
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/annotations/test_symmetric.py +25 -2
- {enum_properties-2.2.3 → enum_properties-2.2.5}/uv.lock +1 -1
- {enum_properties-2.2.3 → enum_properties-2.2.5}/.codecov.yml +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/.github/dependabot.yml +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/.github/workflows/scorecard.yml +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/.gitignore +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/.pre-commit-config.yaml +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/CODE_OF_CONDUCT.md +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/CONTRIBUTING.md +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/LICENSE +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/SECURITY.md +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/doc/.readthedocs.yaml +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/doc/source/conf.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/doc/source/index.rst +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/doc/source/reference.rst +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/justfile +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/src/enum_properties/py.typed +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/__init__.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/annotations/test.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/annotations/test_flags.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/annotations/test_interface_eq.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/annotations/test_nestedclass.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/annotations/test_none_coercion.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/annotations/test_perf.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/annotations/test_pickle.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/annotations/test_specialize.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/annotations/test_type_hints.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/big_enum.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/big_enum_annotations.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/__init__.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/address.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/color_example.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/hash_equiv_def.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/howto_add_props.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/howto_dataclass.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/howto_dataclass_integration.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/howto_flag.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/howto_flag_boundaries.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/howto_flags_no_iterable.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/howto_hash_equiv.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/howto_hash_equiv_def.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/howto_legacy.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/howto_metaclass.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/howto_nested_classes.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/howto_nested_classes_313.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/howto_specialized.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/howto_specialized_default.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/howto_specialized_list.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/howto_specialized_missing.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/howto_symmetric_builtins.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/howto_symmetric_decorator.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/howto_symmetric_metaclass.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/howto_symmetric_overload.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/howto_symmetry.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/howto_verify_unique.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/mapbox.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/specialization_example.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/symmetric_example.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/test_examples.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/legacy/__init__.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/legacy/test.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/legacy/test_flags.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/legacy/test_interface_eq.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/legacy/test_multi_primitives.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/legacy/test_nestedclass.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/legacy/test_none_coercion.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/legacy/test_perf.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/legacy/test_pickle.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/legacy/test_specialize.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/legacy/test_type_hints.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/pickle_enums.py +0 -0
- {enum_properties-2.2.3 → enum_properties-2.2.5}/tests/pickle_enums_annotations.py +0 -0
|
@@ -43,7 +43,7 @@ jobs:
|
|
|
43
43
|
with:
|
|
44
44
|
python-version: ${{ matrix.python-version }}
|
|
45
45
|
- name: Install Just
|
|
46
|
-
uses: extractions/setup-just@
|
|
46
|
+
uses: extractions/setup-just@v3
|
|
47
47
|
- name: Install uv
|
|
48
48
|
uses: astral-sh/setup-uv@v5
|
|
49
49
|
with:
|
|
@@ -98,7 +98,7 @@ jobs:
|
|
|
98
98
|
with:
|
|
99
99
|
python-version: ${{ matrix.python-version }}
|
|
100
100
|
- name: Install Just
|
|
101
|
-
uses: extractions/setup-just@
|
|
101
|
+
uses: extractions/setup-just@v3
|
|
102
102
|
- name: Install uv
|
|
103
103
|
uses: astral-sh/setup-uv@v5
|
|
104
104
|
with:
|
|
@@ -152,7 +152,7 @@ jobs:
|
|
|
152
152
|
with:
|
|
153
153
|
python-version: ${{ matrix.python-version }}
|
|
154
154
|
- name: Install Just
|
|
155
|
-
uses: extractions/setup-just@
|
|
155
|
+
uses: extractions/setup-just@v3
|
|
156
156
|
- name: Install uv
|
|
157
157
|
uses: astral-sh/setup-uv@v5
|
|
158
158
|
with:
|
|
@@ -199,7 +199,7 @@ jobs:
|
|
|
199
199
|
with:
|
|
200
200
|
enable-cache: true
|
|
201
201
|
- name: Setup Just
|
|
202
|
-
uses: extractions/setup-just@
|
|
202
|
+
uses: extractions/setup-just@v3
|
|
203
203
|
- name: Install Release Dependencies
|
|
204
204
|
run: |
|
|
205
205
|
just setup ${{ steps.sp.outputs.python-path }}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: enum-properties
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.5
|
|
4
4
|
Summary: Add properties and method specializations to Python enumeration values with a simple declarative syntax.
|
|
5
5
|
Project-URL: Homepage, https://github.com/bckohan/enum-properties
|
|
6
6
|
Project-URL: Documentation, https://enum-properties.readthedocs.io
|
|
@@ -39,8 +39,8 @@ Description-Content-Type: text/markdown
|
|
|
39
39
|
[](https://pypi.python.org/pypi/enum-properties)
|
|
40
40
|
[](http://enum-properties.readthedocs.io/?badge=latest/)
|
|
41
41
|
[](https://codecov.io/gh/bckohan/enum-properties)
|
|
42
|
-
[](https://github.com/bckohan/enum-properties/actions/workflows/test.yml?query=branch:main)
|
|
43
|
+
[](https://github.com/bckohan/enum-properties/actions/workflows/lint.yml?query=branch:main)
|
|
44
44
|
|
|
45
45
|
Add properties to Python enumeration values with a simple declarative syntax. [Enum Properties](https://enum-properties.readthedocs.io/en/latest) is a lightweight extension to [Python's Enum class](https://docs.python.org/3/library/enum.html). Example:
|
|
46
46
|
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
[](https://pypi.python.org/pypi/enum-properties)
|
|
8
8
|
[](http://enum-properties.readthedocs.io/?badge=latest/)
|
|
9
9
|
[](https://codecov.io/gh/bckohan/enum-properties)
|
|
10
|
-
[](https://github.com/bckohan/enum-properties/actions/workflows/test.yml?query=branch:main)
|
|
11
|
+
[](https://github.com/bckohan/enum-properties/actions/workflows/lint.yml?query=branch:main)
|
|
12
12
|
|
|
13
13
|
Add properties to Python enumeration values with a simple declarative syntax. [Enum Properties](https://enum-properties.readthedocs.io/en/latest) is a lightweight extension to [Python's Enum class](https://docs.python.org/3/library/enum.html). Example:
|
|
14
14
|
|
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
Change Log
|
|
3
3
|
==========
|
|
4
4
|
|
|
5
|
+
v2.2.5 (2025-03-22)
|
|
6
|
+
===================
|
|
7
|
+
|
|
8
|
+
* Fix readme badges.
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
v2.2.4 (2025-03-17)
|
|
12
|
+
===================
|
|
13
|
+
|
|
14
|
+
* Add intersphinx reference points to howto and tutorial doc sections.
|
|
15
|
+
|
|
16
|
+
|
|
5
17
|
v2.2.3 (2025-03-14)
|
|
6
18
|
===================
|
|
7
19
|
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
How To
|
|
5
5
|
======
|
|
6
6
|
|
|
7
|
+
.. _howto_add_properties:
|
|
8
|
+
|
|
7
9
|
Add Properties to an Enum
|
|
8
10
|
-------------------------
|
|
9
11
|
|
|
@@ -41,6 +43,7 @@ equivalent to:
|
|
|
41
43
|
.. literalinclude:: ../../tests/examples/howto_metaclass.py
|
|
42
44
|
:lines: 2-7
|
|
43
45
|
|
|
46
|
+
.. _howto_symmetric_properties:
|
|
44
47
|
|
|
45
48
|
Get Enums from their properties
|
|
46
49
|
-------------------------------
|
|
@@ -107,6 +110,9 @@ the metaclass you must also inherit from :py:class:`~enum_properties.SymmetricMi
|
|
|
107
110
|
.. literalinclude:: ../../tests/examples/howto_symmetric_metaclass.py
|
|
108
111
|
:lines: 2-7
|
|
109
112
|
|
|
113
|
+
|
|
114
|
+
.. _howto_symmetric_precedence:
|
|
115
|
+
|
|
110
116
|
Handle Symmetric Overloads
|
|
111
117
|
--------------------------
|
|
112
118
|
|
|
@@ -137,6 +143,8 @@ example to make name case insensitive we might:
|
|
|
137
143
|
.. literalinclude:: ../../tests/examples/howto_symmetric_builtins.py
|
|
138
144
|
|
|
139
145
|
|
|
146
|
+
.. _howto_symmetric_decorator:
|
|
147
|
+
|
|
140
148
|
Mark @properties as Symmetric
|
|
141
149
|
-----------------------------
|
|
142
150
|
|
|
@@ -146,6 +154,8 @@ in the Enum value tuple as symmetric. For example:
|
|
|
146
154
|
.. literalinclude:: ../../tests/examples/howto_symmetric_decorator.py
|
|
147
155
|
|
|
148
156
|
|
|
157
|
+
.. _howto_specialize_members:
|
|
158
|
+
|
|
149
159
|
Specializing Member Functions
|
|
150
160
|
-----------------------------
|
|
151
161
|
|
|
@@ -172,6 +182,8 @@ can share the same specialization.
|
|
|
172
182
|
.. literalinclude:: ../../tests/examples/howto_specialized_list.py
|
|
173
183
|
|
|
174
184
|
|
|
185
|
+
.. _howto_flags:
|
|
186
|
+
|
|
175
187
|
Flags
|
|
176
188
|
-----
|
|
177
189
|
|
|
@@ -204,6 +216,8 @@ are supported on flags. Boundary specifiers must be supplied as named arguments:
|
|
|
204
216
|
.. literalinclude:: ../../tests/examples/howto_flag_boundaries.py
|
|
205
217
|
|
|
206
218
|
|
|
219
|
+
.. _howto_nested_class_values:
|
|
220
|
+
|
|
207
221
|
Use Nested Classes as Enums
|
|
208
222
|
---------------------------
|
|
209
223
|
|
|
@@ -230,6 +244,8 @@ the position of ``label`` is important.
|
|
|
230
244
|
.. literalinclude:: ../../tests/examples/howto_nested_classes_313.py
|
|
231
245
|
|
|
232
246
|
|
|
247
|
+
.. _howto_dataclass_enums:
|
|
248
|
+
|
|
233
249
|
What about dataclass Enums?
|
|
234
250
|
---------------------------
|
|
235
251
|
|
|
@@ -266,6 +282,8 @@ enumeration for the following reasons:**
|
|
|
266
282
|
.. literalinclude:: ../../tests/examples/howto_dataclass_integration.py
|
|
267
283
|
|
|
268
284
|
|
|
285
|
+
.. _howto_hash_equivalency:
|
|
286
|
+
|
|
269
287
|
Define hash equivalent enums
|
|
270
288
|
----------------------------
|
|
271
289
|
|
|
@@ -283,6 +301,8 @@ be an rgb tuple:
|
|
|
283
301
|
|
|
284
302
|
.. literalinclude:: ../../tests/examples/howto_hash_equiv_def.py
|
|
285
303
|
|
|
304
|
+
.. _howto_legacy_api:
|
|
305
|
+
|
|
286
306
|
Use the legacy (1.x) API
|
|
287
307
|
------------------------
|
|
288
308
|
|
|
@@ -8,6 +8,8 @@ Enumerations in Python can provide rich class based interfaces, well suited to m
|
|
|
8
8
|
real world examples are presented here that leverage enum properties to encapsulate more
|
|
9
9
|
information and get our enums to do more work.
|
|
10
10
|
|
|
11
|
+
.. _tutorial_address_route:
|
|
12
|
+
|
|
11
13
|
Address Route Type
|
|
12
14
|
__________________
|
|
13
15
|
|
|
@@ -35,6 +37,8 @@ persisted in a datastore by value. By specifying them directly instead of using
|
|
|
35
37
|
reserve the ability to add additional route types in alphabetical order without accidentally
|
|
36
38
|
invalidating any persisted data.
|
|
37
39
|
|
|
40
|
+
.. _tutorial_mapbox_style:
|
|
41
|
+
|
|
38
42
|
MapBox Style
|
|
39
43
|
____________
|
|
40
44
|
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "enum-properties"
|
|
7
|
-
version = "2.2.
|
|
7
|
+
version = "2.2.5"
|
|
8
8
|
description = "Add properties and method specializations to Python enumeration values with a simple declarative syntax."
|
|
9
9
|
requires-python = ">=3.8,<4.0"
|
|
10
10
|
authors = [
|
|
@@ -19,7 +19,7 @@ from collections.abc import Generator, Hashable, Iterable
|
|
|
19
19
|
from dataclasses import dataclass
|
|
20
20
|
from functools import cached_property
|
|
21
21
|
|
|
22
|
-
VERSION = (2, 2,
|
|
22
|
+
VERSION = (2, 2, 5)
|
|
23
23
|
|
|
24
24
|
__title__ = "Enum Properties"
|
|
25
25
|
__version__ = ".".join(str(i) for i in VERSION)
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
from unittest import TestCase
|
|
2
|
-
from typing_extensions import Annotated
|
|
3
|
-
|
|
4
2
|
from enum_properties import EnumProperties, symmetric
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
if sys.version_info[0:2] >= (3, 11):
|
|
6
|
+
from enum import property as enum_property
|
|
7
|
+
else:
|
|
8
|
+
from types import DynamicClassAttribute as enum_property
|
|
5
9
|
|
|
6
10
|
|
|
7
11
|
class TestSymmetricDecorator(TestCase):
|
|
@@ -82,3 +86,22 @@ class TestSymmetricDecorator(TestCase):
|
|
|
82
86
|
self.assertTrue(SymEnum(SymEnum.ONE.label) is SymEnum.ONE)
|
|
83
87
|
self.assertTrue(SymEnum(SymEnum.TWO.label) is SymEnum.TWO)
|
|
84
88
|
self.assertTrue(SymEnum(SymEnum.THREE.label) is SymEnum.THREE)
|
|
89
|
+
|
|
90
|
+
def test_make_enum_properties_symmetric(self):
|
|
91
|
+
class SymEnum(EnumProperties):
|
|
92
|
+
ONE = 1
|
|
93
|
+
TWO = 2
|
|
94
|
+
THREE = 3
|
|
95
|
+
|
|
96
|
+
@symmetric(case_fold=True)
|
|
97
|
+
@enum_property
|
|
98
|
+
def label(self):
|
|
99
|
+
return self.name
|
|
100
|
+
|
|
101
|
+
self.assertEqual(SymEnum.ONE.label, "ONE")
|
|
102
|
+
self.assertEqual(SymEnum.TWO.label, "TWO")
|
|
103
|
+
self.assertEqual(SymEnum.THREE.label, "THREE")
|
|
104
|
+
|
|
105
|
+
self.assertTrue(SymEnum("one") is SymEnum.ONE)
|
|
106
|
+
self.assertTrue(SymEnum("tWo") is SymEnum.TWO)
|
|
107
|
+
self.assertTrue(SymEnum("THRee") is SymEnum.THREE)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{enum_properties-2.2.3 → enum_properties-2.2.5}/tests/examples/howto_dataclass_integration.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|