@@ -20,7 +20,6 @@ available from the main module.
2020
2121# Standard Library
2222import collections
23- import dataclasses
2423import inspect
2524import types
2625import typing
@@ -35,37 +34,37 @@ _SIMPLE_MAGIC_ATTRIBUTES = ("__repr__", "__str__")
3534class _AttributeHolderProto (typing.Protocol ):
3635 __slots__ = ()
3736
38- def _get_kwargs (self ) -> list[tuple[ str , typing.Any]] :
37+ def _get_kwargs (self ) -> list:
3938 """Protocol stub."""
4039
41- def _get_args(self ) -> list[str] :
40+ def _get_args(self ) -> list:
4241 """Protocol stub."""
4342
4443
4544@typing.runtime_checkable
4645class _NamedTupleProto(typing.Protocol ):
4746 __slots__ = ()
4847
49- def _asdict (self ) -> dict[ str , typing.Any] :
48+ def _asdict (self ) -> dict:
5049 """Protocol stub."""
5150
52- def __getnewargs__(self ) -> tuple[typing. Any , ...] :
51+ def __getnewargs__(self ) -> tuple:
5352 """Protocol stub."""
5453
55- def _replace(self , **kwds: dict[ str , typing.Any]) -> _NamedTupleProto :
54+ def _replace(self , **kwds: dict ) :
5655 """ Protocol stub."""
5756
5857 @classmethod
59- def _make(cls , iterable: Iterable[typing.Any]) -> _NamedTupleProto :
58+ def _make (cls , iterable: Iterable ) :
6059 """ Protocol stub."""
6160
6261
6362@typing.runtime_checkable
6463class _DataClassProto (typing.Protocol ):
6564 __slots__ = ()
6665
67- __dataclass_params__: dataclasses._DataclassParams # type: ignore[name-defined]
68- __dataclass_fields__: dict [ str , dataclasses.Field[ typing.Any]] = {}
66+ __dataclass_params__: typing.Any
67+ __dataclass_fields__: typing.Any = {}
6968
7069cdef:
7170 bint _known_callable(item: typing.Any):
@@ -239,8 +238,9 @@ cdef class PrettyFormat:
239238 param_str += " = "
240239 else :
241240 param_str += " ="
242- cdef:
243- value = self .process_element(src = param.value, indent = next_indent, no_indent_start = True )
241+
242+ value = self .process_element(src = param.value, indent = next_indent, no_indent_start = True )
243+
244244 param_str += value
245245 param_str += " ,"
246246
@@ -284,18 +284,18 @@ cdef class PrettyFormat:
284284 str prefix = " \n " + " " * next_indent
285285
286286 for arg in src._get_args(): # pylint: disable=protected-access
287- cdef repr_val = self .process_element(arg, indent = next_indent)
287+ repr_val = self .process_element(arg, indent = next_indent)
288288 param_repr.append(f" {prefix}{repr_val}," )
289289
290290 for name, value in src._get_kwargs(): # pylint: disable=protected-access
291291 if name.isidentifier():
292- cdef repr_val = self .process_element(value, indent = next_indent, no_indent_start = True )
292+ repr_val = self .process_element(value, indent = next_indent, no_indent_start = True )
293293 param_repr.append(f" {prefix}{name}={repr_val}," )
294294 else :
295295 star_args[name] = value
296296
297297 if star_args:
298- cdef repr_val = self .process_element(star_args, indent = next_indent, no_indent_start = True )
298+ repr_val = self .process_element(star_args, indent = next_indent, no_indent_start = True )
299299 param_repr.append(f" {prefix}**{repr_val}," )
300300
301301 if param_repr:
@@ -332,7 +332,7 @@ cdef class PrettyFormat:
332332 str prefix = " \n " + " " * next_indent
333333
334334 for arg_name, value in src._asdict().items():
335- cdef repr_val = self .process_element(value, indent = next_indent, no_indent_start = True )
335+ repr_val = self .process_element(value, indent = next_indent, no_indent_start = True )
336336 param_repr.append(f" {prefix}{arg_name}={repr_val}," )
337337 if arg_name in args_annotations and not isinstance (
338338 getattr (args_annotations, arg_name, None ), typing.ForwardRef
@@ -371,7 +371,7 @@ cdef class PrettyFormat:
371371 for arg_name, field in src.__dataclass_fields__.items():
372372 if not field.repr:
373373 continue
374- cdef repr_val = self .process_element(getattr (src, arg_name), indent = next_indent, no_indent_start = True )
374+ repr_val = self .process_element(getattr (src, arg_name), indent = next_indent, no_indent_start = True )
375375
376376 comment: list [str ] = []
377377
0 commit comments