fix UFOFormatVersion tuple's __str__ in python 3.11

python 3.11 doesn't like when a mixin overrides a dunder method like __str__, for some reasons it keep using Enum.__str__, see
https://github.com/fonttools/fonttools/pull/2655
This commit is contained in:
Cosimo Lupo 2022-07-06 11:13:55 +01:00
parent ce38db6562
commit 5ca57917c6
2 changed files with 8 additions and 0 deletions

View File

@ -98,6 +98,11 @@ class UFOFormatVersion(tuple, _VersionTupleEnumMixin, enum.Enum):
FORMAT_2_0 = (2, 0)
FORMAT_3_0 = (3, 0)
# python 3.11 doesn't like when a mixin overrides a dunder method like __str__
# for some reasons it keep using Enum.__str__, see
# https://github.com/fonttools/fonttools/pull/2655
UFOFormatVersion.__str__ = _VersionTupleEnumMixin.__str__
class UFOFileStructure(enum.Enum):
ZIP = "zip"

View File

@ -79,6 +79,9 @@ class GLIFFormatVersion(tuple, _VersionTupleEnumMixin, enum.Enum):
versions.add(cls.FORMAT_2_0)
return frozenset(versions)
# workaround for py3.11, see https://github.com/fonttools/fonttools/pull/2655
GLIFFormatVersion.__str__ = _VersionTupleEnumMixin.__str__
# ------------
# Simple Glyph