There are several type hints I’ve read about that we should start using, given in checklist below.
[x] Self : For any functions that return instance of given class, use typing.Self as the return type e.g. def FromJSON(...) -> Self: Edit: on further review, does not work this way...
[x] Final : For any consts, use Final on the type, e.g. self.MAX_VAL : Final[int] = 50
[x] (optional) TypeGuard : Not sure if we use this or not, but if a function is used to check that a variable is the right type, and returns true if so, we can do def foo(bar) -> TypeGuard[int] and then type-checker knows that if foo(baz) == True, then baz is of type int. Might maybe be of use in schemas, but this seems like an outside chance.
There are several type hints I’ve read about that we should start using, given in checklist below.
typing.Self
as the return type e.g.def FromJSON(...) -> Self:
Edit: on further review, does not work this way...Final
: For any consts, useFinal
on the type, e.g.self.MAX_VAL : Final[int] = 50
TypeGuard
: Not sure if we use this or not, but if a function is used to check that a variable is the right type, and returns true if so, we can dodef foo(bar) -> TypeGuard[int]
and then type-checker knows that iffoo(baz) == True
, thenbaz
is of typeint
. Might maybe be of use in schemas, but this seems like an outside chance.