-
Notifications
You must be signed in to change notification settings - Fork 9
Improve typing #359
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
Improve typing #359
Conversation
This is largely teaching mypy about the gen/ path, removing those `type-ignore` comments on the imports, and then fixing up the aftermath. There's also a bit of type narrowing, minor 'Pythonic' tweaks, and unpinning the types-protobuf dependency (and fixing those lints), so that we can eventually get better types 😄.
d5e5b7a to
ee8b056
Compare
| field.has_presence and not for_items | ||
| ) | ||
| self._required = field_level.required | ||
| type_case = field_level.WhichOneof("type") |
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.
already set above
| rules: list[Rules] = self._factory.get(self._field.message_type) | ||
| if not rules: |
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.
noticed we weren't exiting early here, since self._factory.get is never returning None. Switched to check if we have any rules in the list. Should be slightly faster.
|
|
||
|
|
||
| def make_timestamp(msg: message.Message) -> celtypes.TimestampType: | ||
| def make_timestamp(msg: duration_pb2.Duration) -> celtypes.TimestampType: |
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.
Should this be a timestamp_pb2.Timestamp?
This is largely teaching mypy about the gen/ path, removing those
type-ignorecomments on the imports, and then fixing up the aftermath.There's also a bit of type narrowing, minor 'Pythonic' tweaks, and tweaking the types-protobuf dependency (and fixing those lints), so that we can eventually get better types 😄.