Would this be a reasonably correct way to annotate a property with a
type hint?

>>> class Foo:
...     bar: int
...     @property
...     def bar(self):
...         return 1
... 
>>> foo = Foo()
>>> import typing
>>> typing.get_type_hints(foo)
{'bar': <class 'int'>}

I could also decorate the property method return value:
...     def bar(self) -> int:

I don't see the point though, because you can't access it with get_type_hints.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to