Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Replaced tabs with 4 spaces #105

Merged
merged 4 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/safeds_stubgen/stubs_generator/_generate_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
from safeds_stubgen.docstring_parsing import AttributeDocstring, ClassDocstring, FunctionDocstring


INDENTATION = " "


class NamingConvention(IntEnum):
PYTHON = 1
SAFE_DS = 2
Expand Down Expand Up @@ -239,7 +242,7 @@ def _create_imports_string(self) -> str:
return f"\n{import_string}\n"

def _create_class_string(self, class_: Class, class_indentation: str = "") -> str:
inner_indentations = class_indentation + "\t"
inner_indentations = class_indentation + INDENTATION

# Constructor parameter
if class_.is_abstract:
Expand Down Expand Up @@ -633,7 +636,7 @@ def _create_parameter_string(
f"{name_annotation}{camel_case_name}{type_string}{param_value}",
)

inner_indentations = indentations + "\t"
inner_indentations = indentations + INDENTATION
if parameters_data:
inner_param_data = f",\n{inner_indentations}".join(parameters_data)
return f"\n{inner_indentations}{inner_param_data}\n{indentations}"
Expand Down Expand Up @@ -664,7 +667,7 @@ def _create_enum_string(self, enum_data: Enum) -> str:
# Check if the name is a Safe-DS keyword and escape it
camel_case_name = _replace_if_safeds_keyword(camel_case_name)

enum_text += f"\t{annotation}{camel_case_name}\n"
enum_text += f"{INDENTATION}{annotation}{camel_case_name}\n"
return f"{enum_signature} {{{enum_text}}}"

return enum_signature
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@
package tests.data.variousModulesPackage.abstractModule

class AbstractModuleClass {
@PythonName("abstract_property_method") attr abstractPropertyMethod: union<Float, Int>
@PythonName("abstract_property_method") attr abstractPropertyMethod: union<Float, Int>

// TODO Result type information missing.
@Pure
@PythonName("abstract_method")
fun abstractMethod()
// TODO Result type information missing.
@Pure
@PythonName("abstract_method")
fun abstractMethod()

// TODO List type has to many type arguments.
@Pure
@PythonName("abstract_method_params")
fun abstractMethodParams(
@PythonName("param_1") param1: Int,
@PythonName("param_2") param2: Boolean = false,
@PythonName("param_3") param3: Boolean = true
) -> result1: List<String, Int>
// TODO List type has to many type arguments.
@Pure
@PythonName("abstract_method_params")
fun abstractMethodParams(
@PythonName("param_1") param1: Int,
@PythonName("param_2") param2: Boolean = false,
@PythonName("param_3") param3: Boolean = true
) -> result1: List<String, Int>

// TODO Result type information missing.
@Pure
@PythonName("abstract_static_method")
static fun abstractStaticMethod()
// TODO Result type information missing.
@Pure
@PythonName("abstract_static_method")
static fun abstractStaticMethod()

@Pure
@PythonName("abstract_static_method_params")
static fun abstractStaticMethodParams(
param: Float
) -> result1: Boolean
@Pure
@PythonName("abstract_static_method_params")
static fun abstractStaticMethodParams(
param: Float
) -> result1: Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ from tests.data.variousModulesPackage.aliasing.aliasingModule3 import ImportMeAl
class AliasingModuleClassB()

class AliasingModuleClassC() {
@PythonName("typed_alias_attr")
static attr typedAliasAttr: AliasingModuleClassB
// TODO An internal class must not be used as a type in a public class.
@PythonName("infer_alias_attr")
static attr inferAliasAttr: _AliasingModuleClassA
@PythonName("typed_alias_attr2")
static attr typedAliasAttr2: AliasingModule2ClassA
@PythonName("infer_alias_attr2")
static attr inferAliasAttr2: AliasingModule2ClassA
// TODO Attribute has no type information.
@PythonName("infer_alias_attr3")
static attr inferAliasAttr3
// TODO An internal class must not be used as a type in a public class.
// TODO List type has to many type arguments.
@PythonName("alias_list")
static attr aliasList: List<union<AliasingModuleClassB, _AliasingModuleClassA>, AliasingModule2ClassA, ImportMeAliasingModuleClass>
@PythonName("typed_alias_attr")
static attr typedAliasAttr: AliasingModuleClassB
// TODO An internal class must not be used as a type in a public class.
@PythonName("infer_alias_attr")
static attr inferAliasAttr: _AliasingModuleClassA
@PythonName("typed_alias_attr2")
static attr typedAliasAttr2: AliasingModule2ClassA
@PythonName("infer_alias_attr2")
static attr inferAliasAttr2: AliasingModule2ClassA
// TODO Attribute has no type information.
@PythonName("infer_alias_attr3")
static attr inferAliasAttr3
// TODO An internal class must not be used as a type in a public class.
// TODO List type has to many type arguments.
@PythonName("alias_list")
static attr aliasList: List<union<AliasingModuleClassB, _AliasingModuleClassA>, AliasingModule2ClassA, ImportMeAliasingModuleClass>
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ class AliasingModuleClassB()
class ImportMeAliasingModuleClass()

class AliasingModuleClassC() {
@PythonName("typed_alias_attr")
static attr typedAliasAttr: AliasingModuleClassB
@PythonName("typed_alias_infer")
static attr typedAliasInfer: AliasingModuleClassC
// TODO List type has to many type arguments.
@PythonName("alias_list")
static attr aliasList: List<union<AliasingModuleClassB, String>, ImportMeAliasingModuleClass>
@PythonName("typed_alias_attr")
static attr typedAliasAttr: AliasingModuleClassB
@PythonName("typed_alias_infer")
static attr typedAliasInfer: AliasingModuleClassC
// TODO List type has to many type arguments.
@PythonName("alias_list")
static attr aliasList: List<union<AliasingModuleClassB, String>, ImportMeAliasingModuleClass>
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ package tests.data.variousModulesPackage.aliasing.aliasingModule3
from tests.data.variousModulesPackage.aliasing.aliasingModule2 import ImportMeAliasingModuleClass

class ImportMeAliasingModuleClass() {
@PythonName("import_alias_attr")
static attr importAliasAttr: ImportMeAliasingModuleClass
// TODO List type has to many type arguments.
@PythonName("alias_list")
static attr aliasList: List<ImportMeAliasingModuleClass, String>
@PythonName("import_alias_attr")
static attr importAliasAttr: ImportMeAliasingModuleClass
// TODO List type has to many type arguments.
@PythonName("alias_list")
static attr aliasList: List<ImportMeAliasingModuleClass, String>
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,99 +6,99 @@ from tests.data.mainPackage.anotherPath.anotherModule import AnotherClass
class AttributesClassA()

class AttributesClassB() {
@PythonName("type_hint_public")
static attr typeHintPublic: Int
@PythonName("no_type_hint_public")
static attr noTypeHintPublic: Int
@PythonName("object_attr")
static attr objectAttr: AttributesClassA
// TODO Attribute has no type information.
@PythonName("callexpr_attr_class")
static attr callexprAttrClass
// TODO Attribute has no type information.
@PythonName("callexpr_attr_function")
static attr callexprAttrFunction
// TODO Safe-DS does not support tuple types.
@PythonName("tuple_attr_1")
static attr tupleAttr1: Tuple<Any>
// TODO Safe-DS does not support tuple types.
@PythonName("tuple_attr_2")
static attr tupleAttr2: Tuple<union<Int, String>>
// TODO Safe-DS does not support tuple types.
@PythonName("tuple_attr_3")
static attr tupleAttr3: Tuple<String, Int>
@PythonName("defined_three_times")
static attr definedThreeTimes: Int
@PythonName("list_attr_1")
static attr listAttr1: List<Any>
@PythonName("list_attr_2")
static attr listAttr2: List<union<AttributesClassA, String>>
// TODO List type has to many type arguments.
@PythonName("list_attr_3")
static attr listAttr3: List<String, AttributesClassA>
// TODO List type has to many type arguments.
@PythonName("list_attr_4")
static attr listAttr4: List<String, union<AttributesClassA, Int>>
// TODO Safe-DS does not support set types.
@PythonName("set_attr_1")
static attr setAttr1: Set<Any>
// TODO Safe-DS does not support set types.
@PythonName("set_attr_2")
static attr setAttr2: Set<union<AttributesClassA, String>>
// TODO Safe-DS does not support set types.
// TODO Set type has to many type arguments.
@PythonName("set_attr_3")
static attr setAttr3: Set<String, AttributesClassA>
// TODO Safe-DS does not support set types.
// TODO Set type has to many type arguments.
@PythonName("set_attr_4")
static attr setAttr4: Set<String, union<AttributesClassA, Int>>
@PythonName("dict_attr_1")
static attr dictAttr1: Map<Any, Any>
@PythonName("dict_attr_2")
static attr dictAttr2: Map<String, Int>
@PythonName("dict_attr_3")
static attr dictAttr3: Map<union<Int, String>, AttributesClassA?>
@PythonName("bool_attr")
static attr boolAttr: Boolean
@PythonName("none_attr")
static attr noneAttr: Nothing?
@PythonName("flaot_attr")
static attr flaotAttr: Float
@PythonName("int_or_bool_attr")
static attr intOrBoolAttr: union<Boolean, Int>
@PythonName("str_attr_with_none_value")
static attr strAttrWithNoneValue: String
static attr optional: Int?
static attr final: String
static attr finals: union<Int, String>
@PythonName("final_union")
static attr finalUnion: union<Int, String>
static attr `literal`: literal<"Some String">
@PythonName("multiple_literals")
static attr multipleLiterals: literal<"Literal_1", "Literal_2", 3, true>
@PythonName("mixed_literal_union")
static attr mixedLiteralUnion: union<Int, String, literal<"L1", 2, 4, false>>
@PythonName("multi_attr_1")
static attr multiAttr1: Int
@PythonName("multi_attr_3")
static attr multiAttr3: List<String>
@PythonName("multi_attr_5")
static attr multiAttr5: String
@PythonName("multi_attr_6")
static attr multiAttr6: String
@PythonName("multi_attr_7")
static attr multiAttr7: String
@PythonName("multi_attr_8")
static attr multiAttr8: String
@PythonName("attr_type_from_outside_package")
static attr attrTypeFromOutsidePackage: AnotherClass
@PythonName("attr_default_value_from_outside_package")
static attr attrDefaultValueFromOutsidePackage: AnotherClass
@PythonName("init_attr")
attr initAttr: Boolean
@PythonName("type_hint_public")
static attr typeHintPublic: Int
@PythonName("no_type_hint_public")
static attr noTypeHintPublic: Int
@PythonName("object_attr")
static attr objectAttr: AttributesClassA
// TODO Attribute has no type information.
@PythonName("callexpr_attr_class")
static attr callexprAttrClass
// TODO Attribute has no type information.
@PythonName("callexpr_attr_function")
static attr callexprAttrFunction
// TODO Safe-DS does not support tuple types.
@PythonName("tuple_attr_1")
static attr tupleAttr1: Tuple<Any>
// TODO Safe-DS does not support tuple types.
@PythonName("tuple_attr_2")
static attr tupleAttr2: Tuple<union<Int, String>>
// TODO Safe-DS does not support tuple types.
@PythonName("tuple_attr_3")
static attr tupleAttr3: Tuple<String, Int>
@PythonName("defined_three_times")
static attr definedThreeTimes: Int
@PythonName("list_attr_1")
static attr listAttr1: List<Any>
@PythonName("list_attr_2")
static attr listAttr2: List<union<AttributesClassA, String>>
// TODO List type has to many type arguments.
@PythonName("list_attr_3")
static attr listAttr3: List<String, AttributesClassA>
// TODO List type has to many type arguments.
@PythonName("list_attr_4")
static attr listAttr4: List<String, union<AttributesClassA, Int>>
// TODO Safe-DS does not support set types.
@PythonName("set_attr_1")
static attr setAttr1: Set<Any>
// TODO Safe-DS does not support set types.
@PythonName("set_attr_2")
static attr setAttr2: Set<union<AttributesClassA, String>>
// TODO Safe-DS does not support set types.
// TODO Set type has to many type arguments.
@PythonName("set_attr_3")
static attr setAttr3: Set<String, AttributesClassA>
// TODO Safe-DS does not support set types.
// TODO Set type has to many type arguments.
@PythonName("set_attr_4")
static attr setAttr4: Set<String, union<AttributesClassA, Int>>
@PythonName("dict_attr_1")
static attr dictAttr1: Map<Any, Any>
@PythonName("dict_attr_2")
static attr dictAttr2: Map<String, Int>
@PythonName("dict_attr_3")
static attr dictAttr3: Map<union<Int, String>, AttributesClassA?>
@PythonName("bool_attr")
static attr boolAttr: Boolean
@PythonName("none_attr")
static attr noneAttr: Nothing?
@PythonName("flaot_attr")
static attr flaotAttr: Float
@PythonName("int_or_bool_attr")
static attr intOrBoolAttr: union<Boolean, Int>
@PythonName("str_attr_with_none_value")
static attr strAttrWithNoneValue: String
static attr optional: Int?
static attr final: String
static attr finals: union<Int, String>
@PythonName("final_union")
static attr finalUnion: union<Int, String>
static attr `literal`: literal<"Some String">
@PythonName("multiple_literals")
static attr multipleLiterals: literal<"Literal_1", "Literal_2", 3, true>
@PythonName("mixed_literal_union")
static attr mixedLiteralUnion: union<Int, String, literal<"L1", 2, 4, false>>
@PythonName("multi_attr_1")
static attr multiAttr1: Int
@PythonName("multi_attr_3")
static attr multiAttr3: List<String>
@PythonName("multi_attr_5")
static attr multiAttr5: String
@PythonName("multi_attr_6")
static attr multiAttr6: String
@PythonName("multi_attr_7")
static attr multiAttr7: String
@PythonName("multi_attr_8")
static attr multiAttr8: String
@PythonName("attr_type_from_outside_package")
static attr attrTypeFromOutsidePackage: AnotherClass
@PythonName("attr_default_value_from_outside_package")
static attr attrDefaultValueFromOutsidePackage: AnotherClass
@PythonName("init_attr")
attr initAttr: Boolean

@Pure
@PythonName("some_func")
static fun someFunc() -> result1: Boolean
@Pure
@PythonName("some_func")
static fun someFunc() -> result1: Boolean
}
Loading