diff --git a/changelog.d/1406.change.md b/changelog.d/1406.change.md new file mode 100644 index 000000000..4eae78acd --- /dev/null +++ b/changelog.d/1406.change.md @@ -0,0 +1 @@ +`attrs.make_class()` now allows for Unicode class names. diff --git a/src/attr/_make.py b/src/attr/_make.py index e3e31ffc2..a7a4075af 100644 --- a/src/attr/_make.py +++ b/src/attr/_make.py @@ -13,6 +13,7 @@ import sys import types import typing +import unicodedata from operator import itemgetter @@ -2907,7 +2908,11 @@ def make_class( .. versionadded:: 17.1.0 *bases* .. versionchanged:: 18.1.0 If *attrs* is ordered, the order is retained. .. versionchanged:: 23.2.0 *class_body* + .. versionchanged:: 25.2.0 Class names can now be unicode. """ + # Class identifiers are converted into the normal form NFKC while parsing + name = unicodedata.normalize("NFKC", name) + if isinstance(attrs, dict): cls_dict = attrs elif isinstance(attrs, (list, tuple)): diff --git a/tests/test_make.py b/tests/test_make.py index cc78cb3a4..f5e3b3178 100644 --- a/tests/test_make.py +++ b/tests/test_make.py @@ -10,6 +10,7 @@ import inspect import itertools import sys +import unicodedata from operator import attrgetter from typing import Generic, TypeVar @@ -1100,6 +1101,48 @@ def test_attr_args(self): assert repr(C(1)).startswith("