mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-21 19:32:13 +08:00
protobuf: Annotate well_known_types.pyi (#9323)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
committed by
GitHub
parent
503eab31d7
commit
578cebe1c5
@@ -36,3 +36,6 @@ google.protobuf.internal.containers.BaseContainer.__hash__
|
||||
|
||||
# Metaclass differs:
|
||||
google.protobuf.descriptor.OneofDescriptor
|
||||
|
||||
# Runtime does not have __iter__ (yet...): hack in spirit of https://github.com/python/typeshed/issues/7813
|
||||
google.protobuf.internal.well_known_types.ListValue.__iter__
|
||||
|
||||
18
stubs/protobuf/@tests/test_cases/check_struct.py
Normal file
18
stubs/protobuf/@tests/test_cases/check_struct.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# pyright: reportUnnecessaryTypeIgnoreComment=true
|
||||
from __future__ import annotations
|
||||
|
||||
from google.protobuf.struct_pb2 import ListValue, Struct
|
||||
|
||||
list_value = ListValue()
|
||||
|
||||
lst = list(list_value) # Ensure type checkers recognise that the class is iterable (doesn't have an `__iter__` method at runtime)
|
||||
|
||||
list_value[0] = 42.42
|
||||
list_value[0] = "42"
|
||||
list_value[0] = None
|
||||
list_value[0] = True
|
||||
list_value[0] = [42.42, "42", None, True, [42.42, "42", None, True], {"42": 42}]
|
||||
list_value[0] = ListValue()
|
||||
list_value[0] = Struct()
|
||||
|
||||
list_element = list_value[0]
|
||||
Reference in New Issue
Block a user