From c560dfd3b470cc9beeb8329e05169fef410bf9bb Mon Sep 17 00:00:00 2001 From: Aron Radics Date: Wed, 5 Jun 2024 15:39:44 +0200 Subject: [PATCH 1/4] Drop python 2 support --- .github/workflows/python-version-tests.yml | 1 - setup.py | 1 - src/richenum/enums.py | 36 ++++++---------------- tests/richenum/test_ordered_rich_enums.py | 5 --- tests/richenum/test_rich_enums.py | 5 --- 5 files changed, 10 insertions(+), 38 deletions(-) diff --git a/.github/workflows/python-version-tests.yml b/.github/workflows/python-version-tests.yml index 301169f..f746e51 100644 --- a/.github/workflows/python-version-tests.yml +++ b/.github/workflows/python-version-tests.yml @@ -27,7 +27,6 @@ jobs: sudo apt install flake8 sudo apt install pylint pip install pytest - pip install six - name: Run Tests run: | flake8 tests src setup.py diff --git a/setup.py b/setup.py index 2cf4031..4f45d13 100755 --- a/setup.py +++ b/setup.py @@ -30,6 +30,5 @@ packages=find_packages('src'), tests_require=['pytest'], setup_requires=["pytest-runner"], - install_requires=['six'], test_suite='tests' ) diff --git a/src/richenum/enums.py b/src/richenum/enums.py index 2e970ab..55ece25 100644 --- a/src/richenum/enums.py +++ b/src/richenum/enums.py @@ -7,15 +7,9 @@ from functools import total_ordering import logging import numbers -from six import PY3 -from six import string_types -from six import with_metaclass from operator import itemgetter -if PY3: - unicode = str # workaround for flake8 - logger = logging.getLogger(__name__) @@ -34,15 +28,6 @@ class EnumLookupError(LookupError): pass -def _str_or_ascii_replace(stringy): - if PY3: - return stringy - else: - if isinstance(stringy, str): - stringy = stringy.decode('utf-8') - return stringy.encode('ascii', 'replace') - - def _items(dict): try: return dict.iteritems() @@ -96,16 +81,15 @@ def __init__(self, canonical_name, display_name, *args, **kwargs): def __repr__(self): return "<%s: %s ('%s')>" % ( self.__class__.__name__, - _str_or_ascii_replace(self.canonical_name), - _str_or_ascii_replace(self.display_name), + self.canonical_name, + self.display_name, ) def __unicode__(self): - return unicode(self.display_name) + return str(self.display_name) def __str__(self): - return str(self.display_name) if PY3 else unicode(self).encode( - 'utf-8', 'xmlcharrefreplace') + return str(self.display_name) def __hash__(self): return hash(self.canonical_name) @@ -152,8 +136,8 @@ def __repr__(self): return "<%s #%s: %s ('%s')>" % ( self.__class__.__name__, self.index, - _str_or_ascii_replace(self.canonical_name), - _str_or_ascii_replace(self.display_name), + self.canonical_name, + self.display_name, ) def __lt__(self, other): @@ -225,7 +209,7 @@ def __contains__(cls, item): members = cls.members() if not members: return False - if not type(members[0]) == type(item): + if not type(members[0]) is type(item): return False return (item in members) @@ -279,7 +263,7 @@ def lookup(cls, field, value): return member if ( - not isinstance(member_value, string_types) and + not isinstance(member_value, str) and isinstance(member_value, collectionsAbc.Iterable) and value in member_value ): @@ -311,7 +295,7 @@ def choices(cls, value_field='canonical_name', display_field='display_name'): return [m.choicify(value_field=value_field, display_field=display_field) for m in cls.members()] -class RichEnum(with_metaclass(_RichEnumMetaclass, _EnumMethods)): +class RichEnum(_EnumMethods, metaclass=_RichEnumMetaclass): """ Enumeration that can represent a name for referencing (canonical_name) and a name for displaying (display_name). @@ -339,7 +323,7 @@ class RichEnum(with_metaclass(_RichEnumMetaclass, _EnumMethods)): __virtual__ = True -class OrderedRichEnum(with_metaclass(_OrderedRichEnumMetaclass, _EnumMethods)): +class OrderedRichEnum(_EnumMethods, metaclass=_OrderedRichEnumMetaclass): """ Use OrderedRichEnum when you need a RichEnum with index-based access into the enum, e.g. OrderedRichEnumExample.from_index(0), diff --git a/tests/richenum/test_ordered_rich_enums.py b/tests/richenum/test_ordered_rich_enums.py index e01397e..ed968ff 100644 --- a/tests/richenum/test_ordered_rich_enums.py +++ b/tests/richenum/test_ordered_rich_enums.py @@ -6,9 +6,6 @@ import unittest import re import pytest -from six import PY3 -if PY3: - unicode = str # for flake8, mainly from richenum import EnumConstructionException # noqa from richenum import EnumLookupError # noqa @@ -116,8 +113,6 @@ def test_unicode_handling(self): exp = re.compile(r"") assert exp.search(repr(poop_oatmeal)) is not None self.assertEqual(str(poop_oatmeal), "Oatmeal💩") - if not PY3: - self.assertEqual(unicode(poop_oatmeal), u"Oatmeal💩") def test_enum_hashable(self): self.assertTrue(hash(coffee)) diff --git a/tests/richenum/test_rich_enums.py b/tests/richenum/test_rich_enums.py index 1fea3a8..ea1118f 100644 --- a/tests/richenum/test_rich_enums.py +++ b/tests/richenum/test_rich_enums.py @@ -5,9 +5,6 @@ import re import unittest import pytest -import six -if six.PY3: - unicode = str # for flake8, mainly from richenum import EnumConstructionException # noqa from richenum import EnumLookupError # noqa @@ -142,8 +139,6 @@ def test_unicode_handling(self): exp = re.compile(r"") self.assertIsNotNone(exp.search(repr(poop_okra))) self.assertEqual(str(poop_okra), "Okra💩") - if not six.PY3: - self.assertEqual(unicode(poop_okra), u"Okra💩") def test_string_coercion(self): class DisplayProxy(): From 11ec273bd7fc6203c565ddaa85452d80e20276e7 Mon Sep 17 00:00:00 2001 From: Aron Radics Date: Wed, 5 Jun 2024 15:40:02 +0200 Subject: [PATCH 2/4] Add python 3.9 and 3.10 support --- .github/workflows/python-version-tests.yml | 2 +- CHANGELOG.rst | 7 +++++++ setup.py | 5 +++-- tox.ini | 7 ------- 4 files changed, 11 insertions(+), 10 deletions(-) delete mode 100644 tox.ini diff --git a/.github/workflows/python-version-tests.yml b/.github/workflows/python-version-tests.yml index f746e51..b54859f 100644 --- a/.github/workflows/python-version-tests.yml +++ b/.github/workflows/python-version-tests.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.7", "3.8"] + python-version: ["3.8", "3.9", "3.10"] steps: - uses: actions/checkout@v3 diff --git a/CHANGELOG.rst b/CHANGELOG.rst index af0c26d..284fbd7 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -38,3 +38,10 @@ Changelog 1.0.0 (2013-08-16) ------------------ - Initial public release. + +2.0.0 (2024-06-04) +------------------ + - Remove six + - Remove python 3.7 support + - Add python 3.9 and 3.10 support + - Remove tox.ini \ No newline at end of file diff --git a/setup.py b/setup.py index 4f45d13..aa11093 100755 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name='richenum', - version='1.3.1', + version='2.0.0', description='Enum library for python.', long_description=( open('README.rst').read() + '\n\n' + @@ -16,8 +16,9 @@ 'License :: OSI Approved :: MIT License', 'Programming Language :: Python', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: Implementation :: CPython', 'Topic :: Software Development :: Libraries :: Python Modules', ], diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 104b219..0000000 --- a/tox.ini +++ /dev/null @@ -1,7 +0,0 @@ -[tox] -envlist = py27,py35,py36,py37,pypy -[testenv] -deps = - pytest - six -commands = pytest \ No newline at end of file From 9d0d8d888be6ecf7c3e5512a0cccb0a287f1dd1b Mon Sep 17 00:00:00 2001 From: Aron Radics Date: Wed, 5 Jun 2024 19:45:36 +0200 Subject: [PATCH 3/4] Extend authors --- AUTHORS.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.rst b/AUTHORS.rst index f656e9d..9df2739 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -4,6 +4,7 @@ Developed and maintained by `Hearsay Social, Inc. Contributors ============ | `Adam DePue `_ +| `Aron radics `_ | `Akshay Shah `_ | `Dale Hui `_ | `Robert MacCloy `_ From 2d82c13b70f03185fc29bb27472ad9e18e05632b Mon Sep 17 00:00:00 2001 From: Aron Radics Date: Wed, 5 Jun 2024 19:58:35 +0200 Subject: [PATCH 4/4] Update Readme --- README.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 5a016f3..1af9e19 100644 --- a/README.rst +++ b/README.rst @@ -1,9 +1,8 @@ ======== richenum ======== -.. image:: https://circleci.com/gh/hearsaycorp/richenum/tree/master.svg?style=svg +.. image:: https://github.com/hearsaycorp/richenum/actions/workflows/python-version-tests.yml/badge.svg :alt: Build Status - :target: https://circleci.com/gh/hearsaycorp/richenum/tree/master .. image:: https://img.shields.io/pypi/v/richenum.svg :alt: Latest PyPI Version @@ -16,7 +15,7 @@ richenum .. image:: https://img.shields.io/pypi/dm/richenum.svg :alt: Pypi Downloads :target: https://pypi.org/project/richenum/ - + ===== About =====