Recently moved to pyright for our type checking needs. While running pyright on a file that works with the google.cloud.Key type, I get a long list of errors saying “Argument of type ‘Key | list[Key]’ cannot be assigned to parameter…” for every function that accepts a parameter of Key type, with the calling code using the .key property of a ndb.Model. Example:
class Foo(Model):
some_property = model.StringProperty()
def do_something(model_key: Key) -> None:
do_the_thing(model_key)
foo = get_foo("some_identifier")
do_something(foo.key)
I cannot find anything in the docs or in the SDK source to suggest that ‘foo.key’ here would ever be a list[Key]. However, if I look at the type stubs for this, it gives the following:
class ModelKey(Property):
def __init__(self) -> None: ...
def __get__(self, entity: Model, unused_cls: type[Model] | None = ...) -> key_module.Key | list[key_module.Key] | None: ...
Can anyone share any docs or knowledge around how the ‘foo.key’ call could ever return a list?