data.SourceFunction

 1from .SourceType import SourceType
 2from .SourceVariable import SourceVariable
 3
 4
 5class SourceFunction:
 6    """
 7    Data class representing a python function.
 8    """
 9
10    def __init__(self) -> None:
11        self.static = False
12        self.name: str = ''
13        self.params: list[SourceVariable] = []
14        self.returns: SourceType = SourceType()
15
16    def get_dependencies(self) -> set[str]:
17        """
18        Generates a list of dependencies.
19
20        :return: All dependencies of the function.
21        """
22        return self.returns.dependencies.union(
23            {inner for outer in self.params for inner in outer.get_dependencies()}
24        )
25
26    def __str__(self) -> str:
27        return ('{static}' if self.static else '') + \
28            '<color:DarkRed>' + \
29            self.name + \
30            '</color>(' + \
31            ', '.join([str(param) for param in self.params]) + \
32            ')' + \
33            (
34                ' → <color:MidnightBlue>' + str(self.returns) + '</color>'
35                if str(self.returns) else ''
36            )
class SourceFunction:
 6class SourceFunction:
 7    """
 8    Data class representing a python function.
 9    """
10
11    def __init__(self) -> None:
12        self.static = False
13        self.name: str = ''
14        self.params: list[SourceVariable] = []
15        self.returns: SourceType = SourceType()
16
17    def get_dependencies(self) -> set[str]:
18        """
19        Generates a list of dependencies.
20
21        :return: All dependencies of the function.
22        """
23        return self.returns.dependencies.union(
24            {inner for outer in self.params for inner in outer.get_dependencies()}
25        )
26
27    def __str__(self) -> str:
28        return ('{static}' if self.static else '') + \
29            '<color:DarkRed>' + \
30            self.name + \
31            '</color>(' + \
32            ', '.join([str(param) for param in self.params]) + \
33            ')' + \
34            (
35                ' → <color:MidnightBlue>' + str(self.returns) + '</color>'
36                if str(self.returns) else ''
37            )

Data class representing a python function.

static
name: str
def get_dependencies(self) -> set[str]:
17    def get_dependencies(self) -> set[str]:
18        """
19        Generates a list of dependencies.
20
21        :return: All dependencies of the function.
22        """
23        return self.returns.dependencies.union(
24            {inner for outer in self.params for inner in outer.get_dependencies()}
25        )

Generates a list of dependencies.

Returns

All dependencies of the function.