-
Notifications
You must be signed in to change notification settings - Fork 0
/
generic_fn.py
35 lines (32 loc) · 1.21 KB
/
generic_fn.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class GenericFn:
"""
Represents a generic function with its respective relevant attributes.
Attributes:
annotation (str): The inline annotation (optional; may be the empty string).
fn_name (str): The name of the function.
params (list[str]): A string representing the generic parameters enclosed in angle brackets.
args (str): A string representing the generic arguments provided when calling the function.
fn_body (str): The body of the generic function. May contain calls to other generic ~
functions. Also contains the return type
"""
def __init__(
self,
annotation: str,
fn_name: str,
params: str,
args: str,
fn_body: str,
):
self.annotation = annotation
self.fn_name = fn_name
self.params = [p.strip() for p in params.split(",")]
self.args = args
self.fn_body = fn_body
def __repr__(self) -> str:
return (
f"Annotation: {self.annotation}\n"
f"Function Name: {self.fn_name}\n"
f"Parameters: {self.params}\n"
f"Arguments: {self.args}\n"
f"Function Body:\n{self.fn_body}\n\n"
)