@@ -759,7 +759,7 @@ def parse_line(self, line: str) -> None:
759
759
def render (
760
760
self ,
761
761
clinic : Clinic | None ,
762
- signatures : Iterable [Function ]
762
+ signatures : Iterable [Module | Class | Function ]
763
763
) -> str :
764
764
function = None
765
765
for o in signatures :
@@ -1633,6 +1633,7 @@ def create_regex(
1633
1633
return re .compile (pattern )
1634
1634
1635
1635
1636
+ @dc .dataclass (slots = True , repr = False )
1636
1637
class Block :
1637
1638
r"""
1638
1639
Represents a single block of text embedded in
@@ -1679,18 +1680,16 @@ class Block:
1679
1680
"preindent" would be "____" and "indent" would be "__".
1680
1681
1681
1682
"""
1682
- def __init__ (self , input , dsl_name = None , signatures = None , output = None , indent = '' , preindent = '' ):
1683
- assert isinstance (input , str )
1684
- self .input = input
1685
- self .dsl_name = dsl_name
1686
- self .signatures = signatures or []
1687
- self .output = output
1688
- self .indent = indent
1689
- self .preindent = preindent
1683
+ input : str
1684
+ dsl_name : str | None = None
1685
+ signatures : list [Module | Class | Function ] = dc .field (default_factory = list )
1686
+ output : Any = None # TODO: Very dynamic; probably untypeable in its current form?
1687
+ indent : str = ''
1688
+ preindent : str = ''
1690
1689
1691
- def __repr__ (self ):
1690
+ def __repr__ (self ) -> str :
1692
1691
dsl_name = self .dsl_name or "text"
1693
- def summarize (s ) :
1692
+ def summarize (s : object ) -> str :
1694
1693
s = repr (s )
1695
1694
if len (s ) > 30 :
1696
1695
return s [:26 ] + "..." + s [0 ]
@@ -4619,10 +4618,13 @@ def state_modulename_name(self, line: str | None) -> None:
4619
4618
4620
4619
if not (existing_function .kind == self .kind and existing_function .coexist == self .coexist ):
4621
4620
fail ("'kind' of function and cloned function don't match! (@classmethod/@staticmethod/@coexist)" )
4622
- self .function = existing_function .copy (name = function_name , full_name = full_name , module = module , cls = cls , c_basename = c_basename , docstring = '' )
4623
-
4624
- self .block .signatures .append (self .function )
4625
- (cls or module ).functions .append (self .function )
4621
+ function = existing_function .copy (
4622
+ name = function_name , full_name = full_name , module = module ,
4623
+ cls = cls , c_basename = c_basename , docstring = ''
4624
+ )
4625
+ self .function = function
4626
+ self .block .signatures .append (function )
4627
+ (cls or module ).functions .append (function )
4626
4628
self .next (self .state_function_docstring )
4627
4629
return
4628
4630
0 commit comments