Skip to content

Commit

Permalink
generate comments properly
Browse files Browse the repository at this point in the history
  • Loading branch information
CheatCod committed Nov 15, 2024
1 parent 0c9b8ac commit a10d3e7
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 115 deletions.
6 changes: 0 additions & 6 deletions core/data/tests/anonymous_struct_with_rename/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
from __future__ import annotations

from enum import Enum
from pydantic import BaseModel, ConfigDict, Field
from typing import List, Literal, Union

Expand Down Expand Up @@ -37,11 +36,6 @@ class AnonymousStructWithRenameKebabCaseInner(BaseModel):
something_else: bool = Field(alias="something-else")


class AnonymousStructWithRenameTypes(str, Enum):
LIST = "list"
LONG_FIELD_NAMES = "longFieldNames"
KEBAB_CASE = "kebabCase"

class AnonymousStructWithRenameList(BaseModel):
AnonymousStructWithRenameTypes: Literal["list"] = "list"
content: AnonymousStructWithRenameListInner
Expand Down
9 changes: 0 additions & 9 deletions core/data/tests/can_apply_prefix_correctly/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
from __future__ import annotations

from enum import Enum
from pydantic import BaseModel
from typing import Dict, List, Literal, Union

Expand All @@ -12,14 +11,6 @@ class ItemDetailsFieldValue(BaseModel):
hello: str


class AdvancedColorsTypes(str, Enum):
STRING = "String"
NUMBER = "Number"
NUMBER_ARRAY = "NumberArray"
REALLY_COOL_TYPE = "ReallyCoolType"
ARRAY_REALLY_COOL_TYPE = "ArrayReallyCoolType"
DICTIONARY_REALLY_COOL_TYPE = "DictionaryReallyCoolType"

class AdvancedColorsString(BaseModel):
AdvancedColorsTypes: Literal["String"] = "String"
c: str
Expand Down
29 changes: 15 additions & 14 deletions core/data/tests/can_generate_algebraic_enum/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
from __future__ import annotations

from enum import Enum
from pydantic import BaseModel
from typing import List, Literal, Union

Expand All @@ -14,13 +13,9 @@ class ItemDetailsFieldValue(BaseModel):
"""
pass

class AdvancedColorsTypes(str, Enum):
STRING = "String"
NUMBER = "Number"
UNSIGNED_NUMBER = "UnsignedNumber"
NUMBER_ARRAY = "NumberArray"
REALLY_COOL_TYPE = "ReallyCoolType"

"""
This is a case comment
"""
class AdvancedColorsString(BaseModel):
AdvancedColorsTypes: Literal["String"] = "String"
content: str
Expand All @@ -37,17 +32,20 @@ class AdvancedColorsNumberArray(BaseModel):
AdvancedColorsTypes: Literal["NumberArray"] = "NumberArray"
content: List[int]

"""
Comment on the last element
"""
class AdvancedColorsReallyCoolType(BaseModel):
AdvancedColorsTypes: Literal["ReallyCoolType"] = "ReallyCoolType"
content: ItemDetailsFieldValue

"""
Enum comment
"""
AdvancedColors = Union[AdvancedColorsString, AdvancedColorsNumber, AdvancedColorsUnsignedNumber, AdvancedColorsNumberArray, AdvancedColorsReallyCoolType]
class AdvancedColors2Types(str, Enum):
STRING = "string"
NUMBER = "number"
NUMBER_ARRAY = "number-array"
REALLY_COOL_TYPE = "really-cool-type"

"""
This is a case comment
"""
class AdvancedColors2String(BaseModel):
AdvancedColors2Types: Literal["string"] = "string"
content: str
Expand All @@ -60,6 +58,9 @@ class AdvancedColors2NumberArray(BaseModel):
AdvancedColors2Types: Literal["number-array"] = "number-array"
content: List[int]

"""
Comment on the last element
"""
class AdvancedColors2ReallyCoolType(BaseModel):
AdvancedColors2Types: Literal["really-cool-type"] = "really-cool-type"
content: ItemDetailsFieldValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@
"""
from __future__ import annotations

from enum import Enum
from pydantic import BaseModel
from typing import Literal, Union


class SomeEnumTypes(str, Enum):
A = "A"
C = "C"

class SomeEnumA(BaseModel):
SomeEnumTypes: Literal["A"] = "A"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
from __future__ import annotations

from enum import Enum
from pydantic import BaseModel
from typing import Literal, Union

Expand All @@ -28,16 +27,21 @@ class AutofilledBySomethingElseInner(BaseModel):
"""


class AutofilledByTypes(str, Enum):
US = "Us"
SOMETHING_ELSE = "SomethingElse"

"""
This field was autofilled by us
"""
class AutofilledByUs(BaseModel):
AutofilledByTypes: Literal["Us"] = "Us"
content: AutofilledByUsInner

"""
Something else autofilled this field
"""
class AutofilledBySomethingElse(BaseModel):
AutofilledByTypes: Literal["SomethingElse"] = "SomethingElse"
content: AutofilledBySomethingElseInner

"""
Enum keeping track of who autofilled a field
"""
AutofilledBy = Union[AutofilledByUs, AutofilledBySomethingElse]
5 changes: 0 additions & 5 deletions core/data/tests/can_generate_empty_algebraic_enum/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@
"""
from __future__ import annotations

from enum import Enum
from pydantic import BaseModel
from typing import Literal, Union


class AddressDetails(BaseModel):
pass

class AddressTypes(str, Enum):
FIXED_ADDRESS = "FixedAddress"
NO_FIXED_ADDRESS = "NoFixedAddress"

class AddressFixedAddress(BaseModel):
AddressTypes: Literal["FixedAddress"] = "FixedAddress"
content: AddressDetails
Expand Down
25 changes: 12 additions & 13 deletions core/data/tests/can_handle_anonymous_struct/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
from __future__ import annotations

from enum import Enum
from pydantic import BaseModel
from typing import Literal, Union

Expand Down Expand Up @@ -32,18 +31,23 @@ class AutofilledBySomethingElseInner(BaseModel):
"""


class AutofilledByTypes(str, Enum):
US = "Us"
SOMETHING_ELSE = "SomethingElse"

"""
This field was autofilled by us
"""
class AutofilledByUs(BaseModel):
AutofilledByTypes: Literal["Us"] = "Us"
content: AutofilledByUsInner

"""
Something else autofilled this field
"""
class AutofilledBySomethingElse(BaseModel):
AutofilledByTypes: Literal["SomethingElse"] = "SomethingElse"
content: AutofilledBySomethingElseInner

"""
Enum keeping track of who autofilled a field
"""
AutofilledBy = Union[AutofilledByUs, AutofilledBySomethingElse]
class EnumWithManyVariantsAnonVariantInner(BaseModel):
"""
Expand All @@ -60,14 +64,6 @@ class EnumWithManyVariantsAnotherAnonVariantInner(BaseModel):
thing: int


class EnumWithManyVariantsTypes(str, Enum):
UNIT_VARIANT = "UnitVariant"
TUPLE_VARIANT_STRING = "TupleVariantString"
ANON_VARIANT = "AnonVariant"
TUPLE_VARIANT_INT = "TupleVariantInt"
ANOTHER_UNIT_VARIANT = "AnotherUnitVariant"
ANOTHER_ANON_VARIANT = "AnotherAnonVariant"

class EnumWithManyVariantsUnitVariant(BaseModel):
EnumWithManyVariantsTypes: Literal["UnitVariant"] = "UnitVariant"

Expand All @@ -90,4 +86,7 @@ class EnumWithManyVariantsAnotherAnonVariant(BaseModel):
EnumWithManyVariantsTypes: Literal["AnotherAnonVariant"] = "AnotherAnonVariant"
content: EnumWithManyVariantsAnotherAnonVariantInner

"""
This is a comment (yareek sameek wuz here)
"""
EnumWithManyVariants = Union[EnumWithManyVariantsUnitVariant, EnumWithManyVariantsTupleVariantString, EnumWithManyVariantsAnonVariant, EnumWithManyVariantsTupleVariantInt, EnumWithManyVariantsAnotherUnitVariant, EnumWithManyVariantsAnotherAnonVariant]
7 changes: 3 additions & 4 deletions core/data/tests/can_handle_unit_type/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
from __future__ import annotations

from enum import Enum
from pydantic import BaseModel, ConfigDict, Field
from typing import Literal

Expand All @@ -17,11 +16,11 @@ class StructHasVoidType(BaseModel):
this_is_a_unit: None = Field(alias="thisIsAUnit")


class EnumHasVoidTypeTypes(str, Enum):
HAS_A_UNIT = "hasAUnit"

class EnumHasVoidTypeHasAUnit(BaseModel):
EnumHasVoidTypeTypes: Literal["hasAUnit"] = "hasAUnit"
content: None

"""
This enum has a variant associated with unit data
"""
EnumHasVoidType = EnumHasVoidTypeHasAUnit
7 changes: 0 additions & 7 deletions core/data/tests/excluded_by_target_os/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@ class TestEnumVariant9Inner(BaseModel):
field_2: str = Field(alias="field2")


class TestEnumTypes(str, Enum):
VARIANT_1 = "Variant1"
VARIANT_5 = "Variant5"
VARIANT_7 = "Variant7"
VARIANT_8 = "Variant8"
VARIANT_9 = "Variant9"

class TestEnumVariant1(BaseModel):
TestEnumTypes: Literal["Variant1"] = "Variant1"

Expand Down
11 changes: 0 additions & 11 deletions core/data/tests/recursive_enum_decorator/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
from __future__ import annotations

from enum import Enum
from pydantic import BaseModel
from typing import Literal, Union

Expand All @@ -22,11 +21,6 @@ class MoreOptionsBuiltInner(BaseModel):
top: MoreOptions


class MoreOptionsTypes(str, Enum):
NEWS = "news"
EXACTLY = "exactly"
BUILT = "built"

class MoreOptionsNews(BaseModel):
MoreOptionsTypes: Literal["news"] = "news"
content: bool
Expand All @@ -40,11 +34,6 @@ class MoreOptionsBuilt(BaseModel):
content: MoreOptionsBuiltInner

MoreOptions = Union[MoreOptionsNews, MoreOptionsExactly, MoreOptionsBuilt]
class OptionsTypes(str, Enum):
RED = "red"
BANANA = "banana"
VERMONT = "vermont"

class OptionsRed(BaseModel):
OptionsTypes: Literal["red"] = "red"
content: bool
Expand Down
8 changes: 3 additions & 5 deletions core/data/tests/serialize_anonymous_field_as/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
"""
from __future__ import annotations

from enum import Enum
from pydantic import BaseModel
from typing import Literal, Union


class SomeEnumTypes(str, Enum):
CONTEXT = "Context"
OTHER = "Other"

"""
The associated String contains some opaque context
"""
class SomeEnumContext(BaseModel):
SomeEnumTypes: Literal["Context"] = "Context"
content: str
Expand Down
9 changes: 3 additions & 6 deletions core/data/tests/smart_pointers/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
from __future__ import annotations

from enum import Enum
from pydantic import BaseModel
from typing import List, Literal, Union

Expand Down Expand Up @@ -56,11 +55,6 @@ class RcyColors(BaseModel):
green: str


class BoxyColorsTypes(str, Enum):
RED = "Red"
BLUE = "Blue"
GREEN = "Green"

class BoxyColorsRed(BaseModel):
BoxyColorsTypes: Literal["Red"] = "Red"

Expand All @@ -71,4 +65,7 @@ class BoxyColorsGreen(BaseModel):
BoxyColorsTypes: Literal["Green"] = "Green"
content: str

"""
This is a comment.
"""
BoxyColors = Union[BoxyColorsRed, BoxyColorsBlue, BoxyColorsGreen]
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,13 @@
"""
from __future__ import annotations

from enum import Enum
from pydantic import BaseModel
from typing import List, Literal, Union


class ItemDetailsFieldValue(BaseModel):
pass

class AdvancedColorsTypes(str, Enum):
STRING = "string"
NUMBER = "number"
NUMBER_ARRAY = "number-array"
REALLY_COOL_TYPE = "reallyCoolType"

class AdvancedColorsString(BaseModel):
AdvancedColorsTypes: Literal["string"] = "string"
content: str
Expand Down
Loading

0 comments on commit a10d3e7

Please sign in to comment.