Skip to content

Commit bbd530e

Browse files
Merge pull request #53 from radaron/social/HSS-29595-upgrade-python-version-in-richenum
Upgrade python version to support 3.9 and 3.10
2 parents 9ed7e13 + 2d82c13 commit bbd530e

File tree

9 files changed

+24
-51
lines changed

9 files changed

+24
-51
lines changed

.github/workflows/python-version-tests.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
python-version: ["3.7", "3.8"]
15+
python-version: ["3.8", "3.9", "3.10"]
1616

1717
steps:
1818
- uses: actions/checkout@v3
@@ -27,7 +27,6 @@ jobs:
2727
sudo apt install flake8
2828
sudo apt install pylint
2929
pip install pytest
30-
pip install six
3130
- name: Run Tests
3231
run: |
3332
flake8 tests src setup.py

AUTHORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Developed and maintained by `Hearsay Social, Inc.
44
Contributors
55
============
66
| `Adam DePue <http://github.com/adepue>`_
7+
| `Aron radics <http://github.com/radaron>`_
78
| `Akshay Shah <http://github.com/akshayjshah>`_
89
| `Dale Hui <http://github.com/dhui>`_
910
| `Robert MacCloy <http://github.com/rbm>`_

CHANGELOG.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,10 @@ Changelog
3838
1.0.0 (2013-08-16)
3939
------------------
4040
- Initial public release.
41+
42+
2.0.0 (2024-06-04)
43+
------------------
44+
- Remove six
45+
- Remove python 3.7 support
46+
- Add python 3.9 and 3.10 support
47+
- Remove tox.ini

README.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
========
22
richenum
33
========
4-
.. image:: https://circleci.com/gh/hearsaycorp/richenum/tree/master.svg?style=svg
4+
.. image:: https://github.com/hearsaycorp/richenum/actions/workflows/python-version-tests.yml/badge.svg
55
:alt: Build Status
6-
:target: https://circleci.com/gh/hearsaycorp/richenum/tree/master
76

87
.. image:: https://img.shields.io/pypi/v/richenum.svg
98
:alt: Latest PyPI Version
@@ -16,7 +15,7 @@ richenum
1615
.. image:: https://img.shields.io/pypi/dm/richenum.svg
1716
:alt: Pypi Downloads
1817
:target: https://pypi.org/project/richenum/
19-
18+
2019
=====
2120
About
2221
=====

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name='richenum',
8-
version='1.3.1',
8+
version='2.0.0',
99
description='Enum library for python.',
1010
long_description=(
1111
open('README.rst').read() + '\n\n' +
@@ -16,8 +16,9 @@
1616
'License :: OSI Approved :: MIT License',
1717
'Programming Language :: Python',
1818
'Programming Language :: Python :: 3',
19-
'Programming Language :: Python :: 3.7',
2019
'Programming Language :: Python :: 3.8',
20+
'Programming Language :: Python :: 3.9',
21+
'Programming Language :: Python :: 3.10',
2122
'Programming Language :: Python :: Implementation :: CPython',
2223
'Topic :: Software Development :: Libraries :: Python Modules',
2324
],
@@ -30,6 +31,5 @@
3031
packages=find_packages('src'),
3132
tests_require=['pytest'],
3233
setup_requires=["pytest-runner"],
33-
install_requires=['six'],
3434
test_suite='tests'
3535
)

src/richenum/enums.py

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,9 @@
77
from functools import total_ordering
88
import logging
99
import numbers
10-
from six import PY3
11-
from six import string_types
12-
from six import with_metaclass
1310

1411
from operator import itemgetter
1512

16-
if PY3:
17-
unicode = str # workaround for flake8
18-
1913

2014
logger = logging.getLogger(__name__)
2115

@@ -34,15 +28,6 @@ class EnumLookupError(LookupError):
3428
pass
3529

3630

37-
def _str_or_ascii_replace(stringy):
38-
if PY3:
39-
return stringy
40-
else:
41-
if isinstance(stringy, str):
42-
stringy = stringy.decode('utf-8')
43-
return stringy.encode('ascii', 'replace')
44-
45-
4631
def _items(dict):
4732
try:
4833
return dict.iteritems()
@@ -96,16 +81,15 @@ def __init__(self, canonical_name, display_name, *args, **kwargs):
9681
def __repr__(self):
9782
return "<%s: %s ('%s')>" % (
9883
self.__class__.__name__,
99-
_str_or_ascii_replace(self.canonical_name),
100-
_str_or_ascii_replace(self.display_name),
84+
self.canonical_name,
85+
self.display_name,
10186
)
10287

10388
def __unicode__(self):
104-
return unicode(self.display_name)
89+
return str(self.display_name)
10590

10691
def __str__(self):
107-
return str(self.display_name) if PY3 else unicode(self).encode(
108-
'utf-8', 'xmlcharrefreplace')
92+
return str(self.display_name)
10993

11094
def __hash__(self):
11195
return hash(self.canonical_name)
@@ -152,8 +136,8 @@ def __repr__(self):
152136
return "<%s #%s: %s ('%s')>" % (
153137
self.__class__.__name__,
154138
self.index,
155-
_str_or_ascii_replace(self.canonical_name),
156-
_str_or_ascii_replace(self.display_name),
139+
self.canonical_name,
140+
self.display_name,
157141
)
158142

159143
def __lt__(self, other):
@@ -225,7 +209,7 @@ def __contains__(cls, item):
225209
members = cls.members()
226210
if not members:
227211
return False
228-
if not type(members[0]) == type(item):
212+
if not type(members[0]) is type(item):
229213
return False
230214
return (item in members)
231215

@@ -279,7 +263,7 @@ def lookup(cls, field, value):
279263
return member
280264

281265
if (
282-
not isinstance(member_value, string_types) and
266+
not isinstance(member_value, str) and
283267
isinstance(member_value, collectionsAbc.Iterable) and
284268
value in member_value
285269
):
@@ -311,7 +295,7 @@ def choices(cls, value_field='canonical_name', display_field='display_name'):
311295
return [m.choicify(value_field=value_field, display_field=display_field) for m in cls.members()]
312296

313297

314-
class RichEnum(with_metaclass(_RichEnumMetaclass, _EnumMethods)):
298+
class RichEnum(_EnumMethods, metaclass=_RichEnumMetaclass):
315299
"""
316300
Enumeration that can represent a name for referencing (canonical_name) and
317301
a name for displaying (display_name).
@@ -339,7 +323,7 @@ class RichEnum(with_metaclass(_RichEnumMetaclass, _EnumMethods)):
339323
__virtual__ = True
340324

341325

342-
class OrderedRichEnum(with_metaclass(_OrderedRichEnumMetaclass, _EnumMethods)):
326+
class OrderedRichEnum(_EnumMethods, metaclass=_OrderedRichEnumMetaclass):
343327
"""
344328
Use OrderedRichEnum when you need a RichEnum with index-based
345329
access into the enum, e.g. OrderedRichEnumExample.from_index(0),

tests/richenum/test_ordered_rich_enums.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
import unittest
77
import re
88
import pytest
9-
from six import PY3
10-
if PY3:
11-
unicode = str # for flake8, mainly
129

1310
from richenum import EnumConstructionException # noqa
1411
from richenum import EnumLookupError # noqa
@@ -116,8 +113,6 @@ def test_unicode_handling(self):
116113
exp = re.compile(r"<BreakfastEnumValue #3: oatmeal..? \('Oatmeal..?'\)>")
117114
assert exp.search(repr(poop_oatmeal)) is not None
118115
self.assertEqual(str(poop_oatmeal), "Oatmeal💩")
119-
if not PY3:
120-
self.assertEqual(unicode(poop_oatmeal), u"Oatmeal💩")
121116

122117
def test_enum_hashable(self):
123118
self.assertTrue(hash(coffee))

tests/richenum/test_rich_enums.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
import re
66
import unittest
77
import pytest
8-
import six
9-
if six.PY3:
10-
unicode = str # for flake8, mainly
118

129
from richenum import EnumConstructionException # noqa
1310
from richenum import EnumLookupError # noqa
@@ -142,8 +139,6 @@ def test_unicode_handling(self):
142139
exp = re.compile(r"<VegetableEnumValue: okra..? \('Okra..?'\)>")
143140
self.assertIsNotNone(exp.search(repr(poop_okra)))
144141
self.assertEqual(str(poop_okra), "Okra💩")
145-
if not six.PY3:
146-
self.assertEqual(unicode(poop_okra), u"Okra💩")
147142

148143
def test_string_coercion(self):
149144
class DisplayProxy():

tox.ini

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)