File tree Expand file tree Collapse file tree 6 files changed +37
-7
lines changed
Expand file tree Collapse file tree 6 files changed +37
-7
lines changed Original file line number Diff line number Diff line change 77[ ![ PyPI status] ( https://img.shields.io/pypi/status/enum-properties.svg )] ( https://pypi.python.org/pypi/enum-properties )
88[ ![ Documentation Status] ( https://readthedocs.org/projects/enum-properties/badge/?version=latest )] ( http://enum-properties.readthedocs.io/?badge=latest/ )
99[ ![ Code Cov] ( https://codecov.io/gh/bckohan/enum-properties/branch/main/graph/badge.svg?token=0IZOKN2DYL )] ( https://codecov.io/gh/bckohan/enum-properties )
10- [ ![ Test Status] ( https://github.com/bckohan/django- enum/actions/workflows/test.yml/badge.svg?branch=main )] ( https://github.com/bckohan/enum-properties/actions/workflows/test.yml?query=branch:main )
11- [ ![ Lint Status] ( https://github.com/bckohan/django- enum/actions/workflows/lint.yml/badge.svg?branch=main )] ( https://github.com/bckohan/enum-properties/actions/workflows/lint.yml?query=branch:main )
10+ [ ![ Test Status] ( https://github.com/bckohan/enum-properties /actions/workflows/test.yml/badge.svg?branch=main )] ( https://github.com/bckohan/enum-properties/actions/workflows/test.yml?query=branch:main )
11+ [ ![ Lint Status] ( https://github.com/bckohan/enum-properties /actions/workflows/lint.yml/badge.svg?branch=main )] ( https://github.com/bckohan/enum-properties/actions/workflows/lint.yml?query=branch:main )
1212
1313Add 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:
1414
Original file line number Diff line number Diff line change 22Change Log
33==========
44
5+ v2.2.5 (2025-03-22)
6+ ===================
7+
8+ * Fix readme badges.
9+
10+
511v2.2.4 (2025-03-17)
612===================
713
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44
55[project ]
66name = " enum-properties"
7- version = " 2.2.4 "
7+ version = " 2.2.5 "
88description = " Add properties and method specializations to Python enumeration values with a simple declarative syntax."
99requires-python = " >=3.8,<4.0"
1010authors = [
Original file line number Diff line number Diff line change 1919from dataclasses import dataclass
2020from functools import cached_property
2121
22- VERSION = (2 , 2 , 4 )
22+ VERSION = (2 , 2 , 5 )
2323
2424__title__ = "Enum Properties"
2525__version__ = "." .join (str (i ) for i in VERSION )
Original file line number Diff line number Diff line change 11from unittest import TestCase
2- from typing_extensions import Annotated
3-
2+ from enum import property
43from enum_properties import EnumProperties , symmetric
4+ import sys
5+
6+ if sys .version_info [0 :2 ] >= (3 , 11 ):
7+ from enum import property as enum_property
8+ else :
9+ from types import DynamicClassAttribute as enum_property
510
611
712class TestSymmetricDecorator (TestCase ):
@@ -82,3 +87,22 @@ def label(self):
8287 self .assertTrue (SymEnum (SymEnum .ONE .label ) is SymEnum .ONE )
8388 self .assertTrue (SymEnum (SymEnum .TWO .label ) is SymEnum .TWO )
8489 self .assertTrue (SymEnum (SymEnum .THREE .label ) is SymEnum .THREE )
90+
91+ def test_make_enum_properties_symmetric (self ):
92+ class SymEnum (EnumProperties ):
93+ ONE = 1
94+ TWO = 2
95+ THREE = 3
96+
97+ @symmetric (case_fold = True )
98+ @enum_property
99+ def label (self ):
100+ return self .name
101+
102+ self .assertEqual (SymEnum .ONE .label , "ONE" )
103+ self .assertEqual (SymEnum .TWO .label , "TWO" )
104+ self .assertEqual (SymEnum .THREE .label , "THREE" )
105+
106+ self .assertTrue (SymEnum ("one" ) is SymEnum .ONE )
107+ self .assertTrue (SymEnum ("tWo" ) is SymEnum .TWO )
108+ self .assertTrue (SymEnum ("THRee" ) is SymEnum .THREE )
You can’t perform that action at this time.
0 commit comments