Skip to content

Commit

Permalink
Issue #34: Added inference for return, parameter and attribute types.
Browse files Browse the repository at this point in the history
  • Loading branch information
Masara committed Nov 18, 2023
1 parent 6cd1892 commit d29d3d4
Show file tree
Hide file tree
Showing 12 changed files with 921 additions and 359 deletions.
10 changes: 8 additions & 2 deletions src/safeds_stubgen/api_analyzer/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ class Attribute:
is_static: bool
type: AbstractType | None
docstring: AttributeDocstring
is_type_inferred: bool

def to_dict(self) -> dict[str, Any]:
return {
Expand All @@ -219,6 +220,7 @@ def to_dict(self) -> dict[str, Any]:
"is_public": self.is_public,
"is_static": self.is_static,
"type": self.type.to_dict() if self.type is not None else None,
"is_type_inferred": self.is_type_inferred,
}


Expand Down Expand Up @@ -256,7 +258,8 @@ class Parameter:
default_value: str | bool | int | float | None
assigned_by: ParameterAssignment
docstring: ParameterDocstring
type: AbstractType
type: AbstractType | None
is_type_inferred: bool

@property
def is_required(self) -> bool:
Expand All @@ -277,7 +280,8 @@ def to_dict(self) -> dict[str, Any]:
"is_optional": self.is_optional,
"default_value": self.default_value,
"assigned_by": self.assigned_by.name,
"type": self.type.to_dict(),
"type": self.type.to_dict() if self.type is not None else None,
"is_type_inferred": self.is_type_inferred,
}


Expand All @@ -304,6 +308,7 @@ class Result:
id: str
name: str
type: AbstractType | None
is_type_inferred: bool
docstring: ResultDocstring

def to_dict(self) -> dict[str, Any]:
Expand All @@ -312,6 +317,7 @@ def to_dict(self) -> dict[str, Any]:
"name": self.name,
"docstring": self.docstring.to_dict(),
"type": self.type.to_dict() if self.type is not None else None,
"is_type_inferred": self.is_type_inferred,
}


Expand Down
Loading

0 comments on commit d29d3d4

Please sign in to comment.