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

Use dataclass #31

Merged
merged 3 commits into from Nov 1, 2019
Merged

Conversation

foriequal0
Copy link
Contributor

@foriequal0 foriequal0 commented Oct 23, 2019

Depends on: #30

dataclass is better than NamedTuple

  • You can override def __init__() and other methods
  • It doesn't use a metaclass, so you can bring your own metaclass.
  • It has a charming .asdict() that converts recursively as opposed to ugly namedtuple._asdict() that doesn't recurse.
  • PyCharm doesn't complain that default items (statics) should be at the bottom of the definitions (False negative) when you want to add static variables (which is not default items).

@@ -8,3 +8,4 @@ codechain = {editable = true,path = "."}
pytest = "*"

[packages]
dataclasses = {markers = "python_version < '3.7'",version = "*"}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

pipenv don't install dataclasses; python_version < '3.7' on pipenv install --python 3.7 . if you put it only on setup.py.

@posgnu
Copy link
Collaborator

posgnu commented Oct 31, 2019

Seems nice.

@posgnu
Copy link
Collaborator

posgnu commented Oct 31, 2019

LGTM

@foriequal0 foriequal0 merged commit 7d32b2b into CodeChain-io:master Nov 1, 2019
@foriequal0 foriequal0 deleted the feature/dataclasses branch November 1, 2019 01:41
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.

None yet

2 participants