Skip to content

Commit

Permalink
+ Fixed python3.11中 Constants 排重逻辑不正确
Browse files Browse the repository at this point in the history
  • Loading branch information
007gzs committed Mar 15, 2024
1 parent ade8d0d commit c5d4462
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ["3.10"]#, "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12"]
django-version: [django-3.2, django-4.2, django-5.0, django-pre, django-main]
include:
- python-version: "3.6"
Expand Down
15 changes: 13 additions & 2 deletions cool/core/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,19 @@ class ConstantsItem:
def __init__(self, code, desc):
self.code = code
self.desc = desc
if hasattr(self, '_value_'):
self._value_ = ConstantsItemWrapper(self._value_)
if hasattr(self, '_value_') and not isinstance(self._value_, ConstantsItemWrapper):
self.__value__ = ConstantsItemWrapper(self._value_)

def __setattr__(self, key, value):
if key == '_value_':
setattr(self, '__value__', ConstantsItemWrapper(value))
else:
super().__setattr__(key, value)

def __getattribute__(self, item):
if item == '_value_' and hasattr(self, '__value__'):
return getattr(self, '__value__')
return super().__getattribute__(item)

def __str__(self):
return str(self.code)
Expand Down
3 changes: 2 additions & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ Changelog

Version 1.2.11
------------------
增加 `MODEL_SET_VERBOSE_NAME_TO_DB_COMMENT`配置, 当 model 的 field 未设置 `db_comment` 时, 自动将 `db_comment` 设置为 `verbose_name` 的值
+ 增加 `MODEL_SET_VERBOSE_NAME_TO_DB_COMMENT`配置, 当 model 的 field 未设置 `db_comment` 时, 自动将 `db_comment` 设置为 `verbose_name` 的值
+ Fixed python3.11中 `Constants` 排重逻辑不正确

Version 1.2.10
------------------
Expand Down

0 comments on commit c5d4462

Please sign in to comment.