Skip to content

Refactor Enum Construction (for better IDE Support)#71

Merged
hf-kklein merged 7 commits intodevelopfrom
enum_construction
Nov 3, 2021
Merged

Refactor Enum Construction (for better IDE Support)#71
hf-kklein merged 7 commits intodevelopfrom
enum_construction

Conversation

@hf-kklein
Copy link
Copy Markdown
Contributor

@hf-kklein hf-kklein commented Nov 1, 2021

fixes #48
grafik

implies #70

@hf-kklein hf-kklein self-assigned this Nov 1, 2021
@hf-kklein hf-kklein marked this pull request as ready for review November 1, 2021 15:38
@hf-kklein hf-kklein requested review from a team and hf-krechan November 1, 2021 15:38
Copy link
Copy Markdown
Collaborator

@hf-krechan hf-krechan left a comment

Choose a reason for hiding this comment

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

Nice approach with this str-enum class =)

strategy:
matrix:
python-version: [3.9]
python-version: ["3.10"]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

oha living the future ^^

on:
push:
branches: [ develop, master ]
branches: [develop, master]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do you have a yaml formatter now?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

prettier does yaml, too

matrix:
python-version: [ 3.8 ]
os: [ ubuntu-latest ]
python-version: [3.8]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why is here only Python v3.8?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is all part of #70 ...

SONSTIGES_GERAET = "SONSTIGES_GERAET" # Sonstiges Gerät
PREPAYMENTZAEHLER = "PREPAYMENTZAEHLER" # Prepaymentzähler
EDL_21 = "EDL_21" # EDL21
_96_H_ZAEHLER = "96_H_ZAEHLER" # 96 h Zähler
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this a legit variable name?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ah yes it is ^^

An enum that has string values.
"""

# see https://docs.python.org/3/library/enum.html?highlight=strenum#others
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

👍 nice thanks for this link

json_string = schema.dumps(ansprechpartner, ensure_ascii=False)
assert "Müller-Schmidt" in json_string
assert "Mühlenweg" in json_string
assert '"FRAU"' in json_string
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I thought there should be just FRAU without the quotes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

nope. because to json, the enum just behaves like a normal string (or int). only when the json is deserialized into something type it becomes an enum value.

@hf-kklein hf-kklein merged commit f8c02f5 into develop Nov 3, 2021
@hf-kklein hf-kklein deleted the enum_construction branch November 3, 2021 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve Enum construction

2 participants