-
Notifications
You must be signed in to change notification settings - Fork 9
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
Develop cleanup 2 #82
base: develop
Are you sure you want to change the base?
Conversation
class LabelMarginsPx(NamedTuple): | ||
horizontal: int | ||
vertical: int | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Python docs, NamedTuple
type hint is a "Typed version of collections.namedtuple()". See https://docs.python.org/3/library/typing.html#typing.NamedTuple
Don't you prefer to use collections.namedtuple
, instead of a regular Python class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. Some benefits:
- Types. With
collections.namedtuple
you just have names, without the types, so you wouldn't get type checking. - Syntax. This behaves and looks like a normal Python class, but the init and string representation are managed for you. This also makes it easy to switch out with similar data containers, like
pydantic.BaseModel
in case you need input validation.
Following up from #66