Closed MicaelJarniac closed 1 month ago
Currently you can make this work at runtime if you replace list["Foo"] with "list[Foo]" which is what I do
Currently you can make this work at runtime if you replace list["Foo"] with "list[Foo]" which is what I do
I suspect a from __future__ import annotations
would work too, then?
This is another thing I was thinking about suggesting, automatically doing this import, so it can use list[Foo]
instead of list["Foo"]
or "list[Foo]"
.
This works now on b7
I'm on Python 3.9.9, using
betterproto==2.0.0b5
.On the generated code, it uses
typing.List
, and sometimes doesList["FooBar"]
ifFooBar
hasn't already been defined. This does work.I do, however, use Ruff for linting and fixing common issues, and it turns
typing.List["FooBar"]
intolist["FooBar"]
, since I'm already on a Python version that supports it.This, though, causes errors with betterproto:
TypeError: 'str' object is not callable
I can tell Ruff to not do this fix, but I think it'd be great if betterproto supported it correctly.
Generating code using
typing.List
is fine I guess, as it supports more Python versions, but also having support for the newlist
behavior would be great, as in newer versions,typing.List
is deprecated.I only mentioned
list
, but I suspect it'll be a similar thing for other types.