enumerific 1.0.0__tar.gz → 1.0.1__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.
Files changed (24) hide show
  1. {enumerific-1.0.0/source/enumerific.egg-info → enumerific-1.0.1}/PKG-INFO +74 -44
  2. {enumerific-1.0.0 → enumerific-1.0.1}/README.md +56 -14
  3. {enumerific-1.0.0 → enumerific-1.0.1}/pyproject.toml +17 -9
  4. enumerific-1.0.1/requirements.development.txt +4 -0
  5. enumerific-1.0.1/requirements.distribution.txt +4 -0
  6. enumerific-1.0.1/requirements.txt +1 -0
  7. enumerific-1.0.1/source/enumerific/__init__.py +23 -0
  8. enumerific-1.0.1/source/enumerific/exceptions.py +18 -0
  9. enumerific-1.0.1/source/enumerific/extensible.py +1912 -0
  10. enumerific-1.0.1/source/enumerific/logging.py +5 -0
  11. enumerific-1.0.0/source/enumerific/__init__.py → enumerific-1.0.1/source/enumerific/standard.py +5 -7
  12. enumerific-1.0.1/source/enumerific/version.txt +1 -0
  13. {enumerific-1.0.0 → enumerific-1.0.1/source/enumerific.egg-info}/PKG-INFO +74 -44
  14. enumerific-1.0.1/source/enumerific.egg-info/SOURCES.txt +20 -0
  15. enumerific-1.0.1/source/enumerific.egg-info/requires.txt +10 -0
  16. enumerific-1.0.1/tests/test_extensible_enums.py +1059 -0
  17. enumerific-1.0.0/source/enumerific/version.txt +0 -1
  18. enumerific-1.0.0/source/enumerific.egg-info/SOURCES.txt +0 -11
  19. {enumerific-1.0.0 → enumerific-1.0.1}/LICENSE.md +0 -0
  20. {enumerific-1.0.0 → enumerific-1.0.1}/setup.cfg +0 -0
  21. {enumerific-1.0.0 → enumerific-1.0.1}/source/enumerific.egg-info/dependency_links.txt +0 -0
  22. {enumerific-1.0.0 → enumerific-1.0.1}/source/enumerific.egg-info/top_level.txt +0 -0
  23. {enumerific-1.0.0 → enumerific-1.0.1}/source/enumerific.egg-info/zip-safe +0 -0
  24. {enumerific-1.0.0 → enumerific-1.0.1}/tests/test_enumerific_library.py +0 -0
@@ -1,44 +1,32 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: enumerific
3
- Version: 1.0.0
3
+ Version: 1.0.1
4
4
  Summary: Simplifies working with Python enums.
5
5
  Author: Daniel Sissman
6
- License: MIT License
7
-
8
- Copyright © 2024–2025 Daniel Sissman.
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy
11
- of this software and associated documentation files (the "Software"), to deal
12
- in the Software without restriction, including without limitation the rights
13
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- copies of the Software, and to permit persons to whom the Software is
15
- furnished to do so, subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in all
18
- copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- SOFTWARE.
27
- Project-URL: Documentation, https://github.com/bluebinary/enumerific/blob/main/README.md
28
- Project-URL: Changelog, https://github.com/bluebinary/enumerific/blob/main/CHANGELOG.md
29
- Project-URL: Repository, https://github.com/bluebinary/enumerific
30
- Project-URL: Issues, https://github.com/bluebinary/enumerific/issues
6
+ License-Expression: MIT
7
+ Project-URL: documentation, https://github.com/bluebinary/enumerific/blob/main/README.md
8
+ Project-URL: changelog, https://github.com/bluebinary/enumerific/blob/main/CHANGELOG.md
9
+ Project-URL: repository, https://github.com/bluebinary/enumerific
10
+ Project-URL: issues, https://github.com/bluebinary/enumerific/issues
11
+ Project-URL: homepage, https://github.com/bluebinary/enumerific
31
12
  Keywords: enum,enumeration,enumerations
32
- Classifier: License :: OSI Approved :: MIT License
33
13
  Classifier: Programming Language :: Python :: 3
34
- Classifier: Programming Language :: Python :: 3.9
35
14
  Classifier: Programming Language :: Python :: 3.10
36
15
  Classifier: Programming Language :: Python :: 3.11
37
16
  Classifier: Programming Language :: Python :: 3.12
38
17
  Classifier: Programming Language :: Python :: 3.13
39
- Requires-Python: >=3.9
18
+ Requires-Python: >=3.10
40
19
  Description-Content-Type: text/markdown
41
20
  License-File: LICENSE.md
21
+ Provides-Extra: development
22
+ Requires-Dist: black==24.10.*; extra == "development"
23
+ Requires-Dist: pytest==8.3.*; extra == "development"
24
+ Requires-Dist: pytest-codeblocks==0.17.0; extra == "development"
25
+ Provides-Extra: distribution
26
+ Requires-Dist: build; extra == "distribution"
27
+ Requires-Dist: twine; extra == "distribution"
28
+ Requires-Dist: wheel; extra == "distribution"
29
+ Dynamic: license-file
42
30
 
43
31
  # Enumerific Enums
44
32
 
@@ -46,11 +34,15 @@ The `enumerific` library provides several useful extensions to the Python built-
46
34
 
47
35
  ### Requirements
48
36
 
49
- The Enumerific library has been tested with Python 3.9, 3.10, 3.11, 3.12 and 3.13 but may work with some earlier versions such as 3.8, but has not been tested against this version or any earlier. The library is not compatible with Python 2.* or earlier.
37
+ The Enumerific library has been tested with Python 3.10, 3.11, 3.12 and 3.13, and is not
38
+ compatible with Python 3.9 or earlier.
50
39
 
51
40
  ### Installation
52
41
 
53
- The Enumerific library is available from PyPi, so may be added to a project's dependencies via its `requirements.txt` file or similar by referencing the Enumerific library's name, `enumerific`, or the library may be installed directly into your local runtime environment using `pip install` by entering the following command, and following any prompts:
42
+ Enumerific is available from the PyPI, so may be added to a project's dependencies via
43
+ its `requirements.txt` file or similar by referencing the library's name, `enumerific`,
44
+ or the library may be installed directly into your local runtime environment using `pip`
45
+ by entering the following command, and following any prompts:
54
46
 
55
47
  $ pip install enumerific
56
48
 
@@ -58,10 +50,23 @@ The Enumerific library is available from PyPi, so may be added to a project's de
58
50
 
59
51
  To use the Enumerific library, simply import the library and use it like you would the built-in `enum` library as a drop-in replacement:
60
52
 
53
+ ```python
54
+ from enumerific import Enum
55
+
56
+ class MyEnum(Enum):
57
+ Option1 = "ABC"
58
+ Option2 = "DEF"
59
+
60
+ val = MyEnum.Option1
61
61
  ```
62
- import enumerific
63
62
 
64
- class MyEnum(enumerific.Enum):
63
+ Alternatively, to make use of the extra functionality for the standard library's `Enum`
64
+ class, import the `Enum` class from the Enumerific library:
65
+
66
+ ```python
67
+ from enumerific import Enum
68
+
69
+ class MyEnum(Enum):
65
70
  Option1 = "ABC"
66
71
  Option2 = "DEF"
67
72
 
@@ -70,12 +75,11 @@ val = MyEnum.Option1
70
75
 
71
76
  You can also import the `Enum` class directly from the `enumerific` library and use it directly:
72
77
 
73
- ```
78
+ ```python
74
79
  from enumerific import Enum
75
80
 
76
81
  class MyEnum(Enum):
77
82
  Option1 = "ABC"
78
- ...
79
83
  ```
80
84
 
81
85
  The Enumerific library's own `Enum` class is a subclass of the built-in `enum.Enum` class, so all of the built-in functionality of `enum.Enum` is available, as well as several additional class methods:
@@ -88,7 +92,7 @@ The benefits of being able to validate and reconcile various input values agains
88
92
 
89
93
  Some examples of use include the following code samples, where each make use of the example `MyEnum` class, defined as follows:
90
94
 
91
- ```
95
+ ```python
92
96
  from enumerific import Enum
93
97
 
94
98
  class MyEnum(Enum):
@@ -98,7 +102,13 @@ class MyEnum(Enum):
98
102
 
99
103
  #### Example 1: Reconciling a Value
100
104
 
101
- ```
105
+ ```python
106
+ from enumerific import Enum
107
+
108
+ class MyEnum(Enum):
109
+ Option1 = "ABC"
110
+ Option2 = "DEF"
111
+
102
112
  # Given a string value in this case
103
113
  value = "ABC"
104
114
 
@@ -111,7 +121,13 @@ assert value is MyEnum.Option1 # asserts successfully as enums are singletons
111
121
 
112
122
  #### Example 2: Reconciling an Enumeration Option Name
113
123
 
114
- ```
124
+ ```python
125
+ from enumerific import Enum
126
+
127
+ class MyEnum(Enum):
128
+ Option1 = "ABC"
129
+ Option2 = "DEF"
130
+
115
131
  # Given a string value in this case
116
132
  value = "Option1"
117
133
 
@@ -124,7 +140,13 @@ assert value is MyEnum.Option1 # asserts successfully as enums are singletons
124
140
 
125
141
  #### Example 3: Validating a Value
126
142
 
127
- ```
143
+ ```python
144
+ from enumerific import Enum
145
+
146
+ class MyEnum(Enum):
147
+ Option1 = "ABC"
148
+ Option2 = "DEF"
149
+
128
150
  # The value can be an enumeration option's name, its value, or the enumeration option
129
151
  value = "Option1"
130
152
  value = "ABC"
@@ -132,13 +154,21 @@ value = MyEnum.Option1
132
154
 
133
155
  if MyEnum.validate(value) is True:
134
156
  # do something if the value could be validated
157
+ pass
135
158
  else:
136
159
  # do something else if the value could not be validated
160
+ pass
137
161
  ```
138
162
 
139
163
  #### Example 4: Iterating Over Enumeration Options
140
164
 
141
- ```
165
+ ```python
166
+ from enumerific import Enum
167
+
168
+ class MyEnum(Enum):
169
+ Option1 = "ABC"
170
+ Option2 = "DEF"
171
+
142
172
  for option in MyEnum.options():
143
173
  # do something with each option
144
174
  print(option.name, option.value)
@@ -150,14 +180,14 @@ The Enumerific library includes a suite of comprehensive unit tests which ensure
150
180
 
151
181
  To ensure that the unit tests are run within a predictable runtime environment where all of the necessary dependencies are available, a [Docker](https://www.docker.com) image is created within which the tests are run. To run the unit tests, ensure Docker and Docker Compose is [installed](https://docs.docker.com/engine/install/), and perform the following commands, which will build the Docker image via `docker compose build` and then run the tests via `docker compose run` – the output of running the tests will be displayed:
152
182
 
153
- ```
183
+ ```shell
154
184
  $ docker compose build
155
185
  $ docker compose run tests
156
186
  ```
157
187
 
158
188
  To run the unit tests with optional command line arguments being passed to `pytest`, append the relevant arguments to the `docker compose run tests` command, as follows, for example passing `-vv` to enable verbose output:
159
189
 
160
- ```
190
+ ```shell
161
191
  $ docker compose run tests -vv
162
192
  ```
163
193
 
@@ -165,4 +195,4 @@ See the documentation for [PyTest](https://docs.pytest.org/en/latest/) regarding
165
195
 
166
196
  ### Copyright & License Information
167
197
 
168
- Copyright © 2024–2025 Daniel Sissman; Licensed under the MIT License.
198
+ Copyright © 2024–2025 Daniel Sissman; licensed under the MIT License.
@@ -4,11 +4,15 @@ The `enumerific` library provides several useful extensions to the Python built-
4
4
 
5
5
  ### Requirements
6
6
 
7
- The Enumerific library has been tested with Python 3.9, 3.10, 3.11, 3.12 and 3.13 but may work with some earlier versions such as 3.8, but has not been tested against this version or any earlier. The library is not compatible with Python 2.* or earlier.
7
+ The Enumerific library has been tested with Python 3.10, 3.11, 3.12 and 3.13, and is not
8
+ compatible with Python 3.9 or earlier.
8
9
 
9
10
  ### Installation
10
11
 
11
- The Enumerific library is available from PyPi, so may be added to a project's dependencies via its `requirements.txt` file or similar by referencing the Enumerific library's name, `enumerific`, or the library may be installed directly into your local runtime environment using `pip install` by entering the following command, and following any prompts:
12
+ Enumerific is available from the PyPI, so may be added to a project's dependencies via
13
+ its `requirements.txt` file or similar by referencing the library's name, `enumerific`,
14
+ or the library may be installed directly into your local runtime environment using `pip`
15
+ by entering the following command, and following any prompts:
12
16
 
13
17
  $ pip install enumerific
14
18
 
@@ -16,10 +20,23 @@ The Enumerific library is available from PyPi, so may be added to a project's de
16
20
 
17
21
  To use the Enumerific library, simply import the library and use it like you would the built-in `enum` library as a drop-in replacement:
18
22
 
23
+ ```python
24
+ from enumerific import Enum
25
+
26
+ class MyEnum(Enum):
27
+ Option1 = "ABC"
28
+ Option2 = "DEF"
29
+
30
+ val = MyEnum.Option1
19
31
  ```
20
- import enumerific
21
32
 
22
- class MyEnum(enumerific.Enum):
33
+ Alternatively, to make use of the extra functionality for the standard library's `Enum`
34
+ class, import the `Enum` class from the Enumerific library:
35
+
36
+ ```python
37
+ from enumerific import Enum
38
+
39
+ class MyEnum(Enum):
23
40
  Option1 = "ABC"
24
41
  Option2 = "DEF"
25
42
 
@@ -28,12 +45,11 @@ val = MyEnum.Option1
28
45
 
29
46
  You can also import the `Enum` class directly from the `enumerific` library and use it directly:
30
47
 
31
- ```
48
+ ```python
32
49
  from enumerific import Enum
33
50
 
34
51
  class MyEnum(Enum):
35
52
  Option1 = "ABC"
36
- ...
37
53
  ```
38
54
 
39
55
  The Enumerific library's own `Enum` class is a subclass of the built-in `enum.Enum` class, so all of the built-in functionality of `enum.Enum` is available, as well as several additional class methods:
@@ -46,7 +62,7 @@ The benefits of being able to validate and reconcile various input values agains
46
62
 
47
63
  Some examples of use include the following code samples, where each make use of the example `MyEnum` class, defined as follows:
48
64
 
49
- ```
65
+ ```python
50
66
  from enumerific import Enum
51
67
 
52
68
  class MyEnum(Enum):
@@ -56,7 +72,13 @@ class MyEnum(Enum):
56
72
 
57
73
  #### Example 1: Reconciling a Value
58
74
 
59
- ```
75
+ ```python
76
+ from enumerific import Enum
77
+
78
+ class MyEnum(Enum):
79
+ Option1 = "ABC"
80
+ Option2 = "DEF"
81
+
60
82
  # Given a string value in this case
61
83
  value = "ABC"
62
84
 
@@ -69,7 +91,13 @@ assert value is MyEnum.Option1 # asserts successfully as enums are singletons
69
91
 
70
92
  #### Example 2: Reconciling an Enumeration Option Name
71
93
 
72
- ```
94
+ ```python
95
+ from enumerific import Enum
96
+
97
+ class MyEnum(Enum):
98
+ Option1 = "ABC"
99
+ Option2 = "DEF"
100
+
73
101
  # Given a string value in this case
74
102
  value = "Option1"
75
103
 
@@ -82,7 +110,13 @@ assert value is MyEnum.Option1 # asserts successfully as enums are singletons
82
110
 
83
111
  #### Example 3: Validating a Value
84
112
 
85
- ```
113
+ ```python
114
+ from enumerific import Enum
115
+
116
+ class MyEnum(Enum):
117
+ Option1 = "ABC"
118
+ Option2 = "DEF"
119
+
86
120
  # The value can be an enumeration option's name, its value, or the enumeration option
87
121
  value = "Option1"
88
122
  value = "ABC"
@@ -90,13 +124,21 @@ value = MyEnum.Option1
90
124
 
91
125
  if MyEnum.validate(value) is True:
92
126
  # do something if the value could be validated
127
+ pass
93
128
  else:
94
129
  # do something else if the value could not be validated
130
+ pass
95
131
  ```
96
132
 
97
133
  #### Example 4: Iterating Over Enumeration Options
98
134
 
99
- ```
135
+ ```python
136
+ from enumerific import Enum
137
+
138
+ class MyEnum(Enum):
139
+ Option1 = "ABC"
140
+ Option2 = "DEF"
141
+
100
142
  for option in MyEnum.options():
101
143
  # do something with each option
102
144
  print(option.name, option.value)
@@ -108,14 +150,14 @@ The Enumerific library includes a suite of comprehensive unit tests which ensure
108
150
 
109
151
  To ensure that the unit tests are run within a predictable runtime environment where all of the necessary dependencies are available, a [Docker](https://www.docker.com) image is created within which the tests are run. To run the unit tests, ensure Docker and Docker Compose is [installed](https://docs.docker.com/engine/install/), and perform the following commands, which will build the Docker image via `docker compose build` and then run the tests via `docker compose run` – the output of running the tests will be displayed:
110
152
 
111
- ```
153
+ ```shell
112
154
  $ docker compose build
113
155
  $ docker compose run tests
114
156
  ```
115
157
 
116
158
  To run the unit tests with optional command line arguments being passed to `pytest`, append the relevant arguments to the `docker compose run tests` command, as follows, for example passing `-vv` to enable verbose output:
117
159
 
118
- ```
160
+ ```shell
119
161
  $ docker compose run tests -vv
120
162
  ```
121
163
 
@@ -123,4 +165,4 @@ See the documentation for [PyTest](https://docs.pytest.org/en/latest/) regarding
123
165
 
124
166
  ### Copyright & License Information
125
167
 
126
- Copyright © 2024–2025 Daniel Sissman; Licensed under the MIT License.
168
+ Copyright © 2024–2025 Daniel Sissman; licensed under the MIT License.
@@ -4,24 +4,27 @@ description = "Simplifies working with Python enums."
4
4
  readme = {file = "README.md", content-type = "text/markdown"}
5
5
  keywords = ["enum", "enumeration", "enumerations"]
6
6
  authors = [{name = "Daniel Sissman"}]
7
- license = {file = "LICENSE.md", content-type = "text/markdown"}
7
+ license = "MIT"
8
8
  classifiers = [
9
- "License :: OSI Approved :: MIT License",
10
9
  "Programming Language :: Python :: 3",
11
- "Programming Language :: Python :: 3.9",
12
10
  "Programming Language :: Python :: 3.10",
13
11
  "Programming Language :: Python :: 3.11",
14
12
  "Programming Language :: Python :: 3.12",
15
13
  "Programming Language :: Python :: 3.13",
16
14
  ]
17
- requires-python = ">=3.9"
18
- dynamic = ["version"]
15
+ requires-python = ">=3.10"
16
+ dynamic = [
17
+ "version",
18
+ "dependencies",
19
+ "optional-dependencies",
20
+ ]
19
21
 
20
22
  [project.urls]
21
- Documentation = "https://github.com/bluebinary/enumerific/blob/main/README.md"
22
- Changelog = "https://github.com/bluebinary/enumerific/blob/main/CHANGELOG.md"
23
- Repository = "https://github.com/bluebinary/enumerific"
24
- Issues = "https://github.com/bluebinary/enumerific/issues"
23
+ documentation = "https://github.com/bluebinary/enumerific/blob/main/README.md"
24
+ changelog = "https://github.com/bluebinary/enumerific/blob/main/CHANGELOG.md"
25
+ repository = "https://github.com/bluebinary/enumerific"
26
+ issues = "https://github.com/bluebinary/enumerific/issues"
27
+ homepage = "https://github.com/bluebinary/enumerific"
25
28
 
26
29
  [build-system]
27
30
  requires = ["setuptools", "wheel"]
@@ -29,6 +32,11 @@ build-backend = "setuptools.build_meta"
29
32
 
30
33
  [tool.setuptools.dynamic]
31
34
  version = {file = "source/enumerific/version.txt"}
35
+ dependencies = {file = "requirements.txt"}
36
+
37
+ [tool.setuptools.dynamic.optional-dependencies]
38
+ development = {file = "requirements.development.txt"}
39
+ distribution = {file = "requirements.distribution.txt"}
32
40
 
33
41
  [tool.setuptools]
34
42
  zip-safe = true
@@ -0,0 +1,4 @@
1
+ # Enumerific Library: Development & Test Dependencies
2
+ black==24.10.*
3
+ pytest==8.3.*
4
+ pytest-codeblocks==0.17.0
@@ -0,0 +1,4 @@
1
+ # Enumerific Library: Build & Deployment Dependencies
2
+ build
3
+ twine
4
+ wheel
@@ -0,0 +1 @@
1
+ # Enumerific Library: Runtime Dependencies
@@ -0,0 +1,23 @@
1
+ from enum import *
2
+
3
+ from .logging import logger
4
+
5
+ from .exceptions import EnumValueError
6
+
7
+ from .extensible import (
8
+ Enumeration,
9
+ EnumerationType,
10
+ EnumerationInteger,
11
+ EnumerationString,
12
+ EnumerationFloat,
13
+ EnumerationComplex,
14
+ EnumerationBytes,
15
+ EnumerationTuple,
16
+ EnumerationSet,
17
+ EnumerationList,
18
+ EnumerationDictionary,
19
+ EnumerationFlag,
20
+ auto,
21
+ )
22
+
23
+ from .standard import Enum
@@ -0,0 +1,18 @@
1
+ class EnumValueError(ValueError):
2
+ pass
3
+
4
+
5
+ class EnumerationError(RuntimeError):
6
+ pass
7
+
8
+
9
+ class EnumerationOptionError(AttributeError, EnumerationError):
10
+ pass
11
+
12
+
13
+ class EnumerationSubclassingError(EnumerationError):
14
+ pass
15
+
16
+
17
+ class EnumerationNonUniqueError(EnumerationError):
18
+ pass