File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -128,15 +128,15 @@ def _new_str(self: object) -> str:
128128def activate_union_aliases () -> None :
129129 """When printing `typing.Union`s, replace all aliased unions by the aliased names.
130130 This monkey patches `__repr__` and `__str__` for `typing.Union`."""
131- _union_type . __repr__ = _new_repr
132- _union_type . __str__ = _new_str
131+ object . __setattr__ ( _union_type , " __repr__" , _new_repr )
132+ object . __setattr__ ( _union_type , " __str__" , _new_str )
133133
134134
135135def deactivate_union_aliases () -> None :
136136 """Undo what :func:`.alias.activate` did. This restores the original `__repr__`
137137 and `__str__` for `typing.Union`."""
138- _union_type . __repr__ = _original_repr
139- _union_type . __str__ = _original_str
138+ object . __setattr__ ( _union_type , " __repr__" , _original_repr )
139+ object . __setattr__ ( _union_type , " __str__" , _original_str )
140140
141141
142142_ALIASED_UNIONS : list = []
You can’t perform that action at this time.
0 commit comments