Skip to content

Commit 950fab4

Browse files
dataclasses: Avoid using private class (#124465)
typing.get_origin() does what we need here, without reaching into typing internals. This shouldn't change any behavior (so I am going to skip news), but it sets a good example for other users introspecting typing objects.
1 parent 5a60566 commit 950fab4

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

Lib/dataclasses.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -690,11 +690,8 @@ def _frozen_get_del_attr(cls, fields, func_builder):
690690

691691

692692
def _is_classvar(a_type, typing):
693-
# This test uses a typing internal class, but it's the best way to
694-
# test if this is a ClassVar.
695693
return (a_type is typing.ClassVar
696-
or (type(a_type) is typing._GenericAlias
697-
and a_type.__origin__ is typing.ClassVar))
694+
or (typing.get_origin(a_type) is typing.ClassVar))
698695

699696

700697
def _is_initvar(a_type, dataclasses):

0 commit comments

Comments
 (0)