xen, guest_tools: add type hints#403
xen, guest_tools: add type hints#403glehmann wants to merge 6 commits intogln/xapi-network-typehintsfrom
Conversation
b3d821d to
7b59763
Compare
29af0fb to
cce863e
Compare
7b59763 to
50754ce
Compare
| @@ -1,9 +1,13 @@ | |||
| from __future__ import annotations | |||
There was a problem hiding this comment.
According to documentation (PEP 563), this import allows to declare type annotation that can be evaluated even if it is not in the scope yet.
There was a problem hiding this comment.
What is this import ?
This https://docs.python.org/3/library/__future__.html#future__.annotations ?
There was a problem hiding this comment.
After reading a bit it seems this line will turn into a SyntaxError in 1 or 2 Python releases, right?
There was a problem hiding this comment.
According to documentation (PEP 563), this import allows to declare type annotation that can be evaluated even if it is not in the scope yet.
But it seems PEP 563 is now replaced by PEP 649 itself supplemented by PEP 749.
And PEP 749 says:
from __future__ import annotations (PEP 563) will continue to exist with its current behavior at least until Python 3.13 reaches its end-of-life. Subsequently, it will be deprecated and eventually removed.
There was a problem hiding this comment.
We use from __future__ import annotations as a way to ease imports when using the type annotations.
It's already often used in this project:
$ rg 'from __future__ import annotations' | wc -l
28
It will eventually be deprecated, but it isn't yet in the last python (3.14.3). It is the way to go for the targeted python version (3.11) by this project.
| @@ -1,9 +1,13 @@ | |||
| from __future__ import annotations | |||
There was a problem hiding this comment.
According to documentation (PEP 563), this import allows to declare type annotation that can be evaluated even if it is not in the scope yet.
cce863e to
21e4825
Compare
21e4825 to
d529cdc
Compare
50754ce to
4c9b247
Compare
d529cdc to
727c335
Compare
7b6389e to
6c7b248
Compare
727c335 to
5f853c8
Compare
Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
5f853c8 to
c7b6529
Compare
6c7b248 to
1c70a06
Compare
This allows more validation both in the CI and when writing the tests in our IDEs.
This work was mostly done with AI, validated by the code checkers, and manually cleaned up by me.