Skip to content

Bugfix: Implement __str__ for enum props to fix query string #259

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

Merged
merged 2 commits into from
Dec 6, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
class AnEnum(str, Enum):
FIRST_VALUE = "FIRST_VALUE"
SECOND_VALUE = "SECOND_VALUE"

def __str__(self) -> str:
return str(self.value)
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ class AnIntEnum(IntEnum):
VALUE_NEGATIVE_1 = -1
VALUE_1 = 1
VALUE_2 = 2

def __str__(self) -> str:
return str(self.value)
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
class DifferentEnum(str, Enum):
DIFFERENT = "DIFFERENT"
OTHER = "OTHER"

def __str__(self) -> str:
return str(self.value)
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
class AnEnum(str, Enum):
FIRST_VALUE = "FIRST_VALUE"
SECOND_VALUE = "SECOND_VALUE"

def __str__(self) -> str:
return str(self.value)
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ class AnIntEnum(IntEnum):
VALUE_NEGATIVE_1 = -1
VALUE_1 = 1
VALUE_2 = 2

def __str__(self) -> str:
return str(self.value)
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
class DifferentEnum(str, Enum):
DIFFERENT = "DIFFERENT"
OTHER = "OTHER"

def __str__(self) -> str:
return str(self.value)
3 changes: 3 additions & 0 deletions openapi_python_client/templates/int_enum.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ class {{ enum.reference.class_name }}(IntEnum):
{% for key, value in enum.values.items() %}
{{ key }} = {{ value }}
{% endfor %}

def __str__(self) -> str:
return str(self.value)
3 changes: 3 additions & 0 deletions openapi_python_client/templates/str_enum.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ class {{ enum.reference.class_name }}(str, Enum):
{% for key, value in enum.values.items() %}
{{ key }} = "{{ value }}"
{% endfor %}

def __str__(self) -> str:
return str(self.value)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to just do return self.value, but mypy couldn't figure out the type