-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
protobuf
: Annotate well_known_types.pyi
#9323
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
Conversation
This comment has been minimized.
This comment has been minimized.
You may need to invent a fictional Type checkers aren't very good at understanding that classes with |
Thanks, I was just wondering why it "passes" in mypy... |
This comment has been minimized.
This comment has been minimized.
You'll need to add an entry to https://github.com/python/typeshed/blob/main/stubs/protobuf/%40tests/stubtest_allowlist.txt to get stubtest to shut up about the fictional |
No idea what's going on with pytype, that might need some investigation. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Ahh, I'm guessing this breaks pytype because you're importing from one of the files that we exclude from the pytype check: https://github.com/python/typeshed/blob/main/tests/pytype_exclude_list.txt I guess if need be, we could maybe just add more files to that excludelist. Hopefully that will fix it. |
This comment has been minimized.
This comment has been minimized.
protobuf
: Annotate well_known_types.pyi
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.
Thanks! A few comments:
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
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.
LGTM
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
google.protobuf.struct_pb2.Struct
and.List
offer high-level methods which we are partially blind to, making things likelist(list_value)
fail.The methods return either JSON primitive types (numbers are always floats!),
Struct
orList
, and accept that along with plain sequences and mappings of the above. python/typing#182 comes handy in that we can now rely on recursive type aliases.