literalenum 0.3.0__py3-none-any.whl → 0.4.0__py3-none-any.whl
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.
- {literalenum-0.3.0.dist-info → literalenum-0.4.0.dist-info}/METADATA +1 -1
- {literalenum-0.3.0.dist-info → literalenum-0.4.0.dist-info}/RECORD +6 -6
- typing_literalenum.py +42 -0
- {literalenum-0.3.0.dist-info → literalenum-0.4.0.dist-info}/WHEEL +0 -0
- {literalenum-0.3.0.dist-info → literalenum-0.4.0.dist-info}/entry_points.txt +0 -0
- {literalenum-0.3.0.dist-info → literalenum-0.4.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: literalenum
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: A Python typing construct that provides namespaced literal constants with advanced typing features.
|
|
5
5
|
Project-URL: Homepage, https://github.com/modularizer/literalenum
|
|
6
6
|
Project-URL: Repository, https://github.com/modularizer/literalenum
|
|
@@ -18,10 +18,10 @@ literalenum/compatibility_extensions/regex.py,sha256=4XDtC8VlehMlcZkcE5L9nXbKkR4
|
|
|
18
18
|
literalenum/compatibility_extensions/sqlalchemy_enum.py,sha256=DF_ce3Q7YNp98mTFXPsyWagQVzTTaczI-dRklOPh_LY,237
|
|
19
19
|
literalenum/compatibility_extensions/str_enum.py,sha256=y-VWFyaEDXmNicgyqzdEpsx-ImUdnydbF_YWhzvEVq0,329
|
|
20
20
|
literalenum/compatibility_extensions/strawberry_enum.py,sha256=mjg3Pyy0w_AggRRB_UtuWQiOguiG66eTN5E_rpwd7cg,526
|
|
21
|
-
typing_literalenum.py,sha256=
|
|
21
|
+
typing_literalenum.py,sha256=CKU4EBfMDZisrK8d9exWwp6sJhznJYp998oaRM5Igjs,27936
|
|
22
22
|
literalenum/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
23
|
-
literalenum-0.
|
|
24
|
-
literalenum-0.
|
|
25
|
-
literalenum-0.
|
|
26
|
-
literalenum-0.
|
|
27
|
-
literalenum-0.
|
|
23
|
+
literalenum-0.4.0.dist-info/METADATA,sha256=JA3sd54K2v5bhuOxtfnVroNnsGVajcRQeNMJ9fFzpVI,4819
|
|
24
|
+
literalenum-0.4.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
25
|
+
literalenum-0.4.0.dist-info/entry_points.txt,sha256=AK8je10LoLMOXuWLjXSqHV2rsTxPW9HlG7YTJGfwkCY,46
|
|
26
|
+
literalenum-0.4.0.dist-info/licenses/LICENSE,sha256=tQZYOMusRS38hVum5uAxSBrSxoQG9w0h6tkyE3RlPmw,1212
|
|
27
|
+
literalenum-0.4.0.dist-info/RECORD,,
|
typing_literalenum.py
CHANGED
|
@@ -370,6 +370,48 @@ class LiteralEnumMeta(type):
|
|
|
370
370
|
for names in cls._value_names_.values()
|
|
371
371
|
})
|
|
372
372
|
|
|
373
|
+
@property
|
|
374
|
+
def name_mapping(cls) -> Mapping[Any, str]:
|
|
375
|
+
"""A read-only ``{value: canonical_name}`` inverse mapping.
|
|
376
|
+
|
|
377
|
+
Each unique value maps to its first-declared (canonical) name::
|
|
378
|
+
|
|
379
|
+
class Method(LiteralEnum):
|
|
380
|
+
GET = "GET"
|
|
381
|
+
get = "GET" # alias
|
|
382
|
+
|
|
383
|
+
Method.name_mapping # {"GET": "GET"}
|
|
384
|
+
|
|
385
|
+
See also :attr:`names_mapping` for all names including aliases.
|
|
386
|
+
"""
|
|
387
|
+
return MappingProxyType({
|
|
388
|
+
v: names[0]
|
|
389
|
+
for v, names in zip(cls._ordered_values_, cls._value_names_.values())
|
|
390
|
+
})
|
|
391
|
+
|
|
392
|
+
@property
|
|
393
|
+
def names_by_value(cls) -> Mapping[Any, str]:
|
|
394
|
+
return cls.name_mapping
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
@property
|
|
398
|
+
def names_mapping(cls) -> Mapping[Any, tuple[str, ...]]:
|
|
399
|
+
"""A read-only ``{value: (name, ...)}`` inverse mapping.
|
|
400
|
+
|
|
401
|
+
Each unique value maps to a tuple of all its declared names
|
|
402
|
+
(canonical first, then aliases)::
|
|
403
|
+
|
|
404
|
+
class Method(LiteralEnum):
|
|
405
|
+
GET = "GET"
|
|
406
|
+
get = "GET" # alias
|
|
407
|
+
|
|
408
|
+
Method.names_mapping # {"GET": ("GET", "get")}
|
|
409
|
+
"""
|
|
410
|
+
return MappingProxyType({
|
|
411
|
+
v: names
|
|
412
|
+
for v, names in zip(cls._ordered_values_, cls._value_names_.values())
|
|
413
|
+
})
|
|
414
|
+
|
|
373
415
|
def keys(cls) -> tuple[str, ...]:
|
|
374
416
|
"""Return canonical member names in definition order (aliases excluded)."""
|
|
375
417
|
return tuple(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|