Skip to content

xen, guest_tools: add type hints#403

Open
glehmann wants to merge 6 commits intogln/xapi-network-typehintsfrom
gln/xen-guest-tools-typehints
Open

xen, guest_tools: add type hints#403
glehmann wants to merge 6 commits intogln/xapi-network-typehintsfrom
gln/xen-guest-tools-typehints

Conversation

@glehmann
Copy link
Member

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.

@glehmann glehmann requested review from a team as code owners February 15, 2026 22:04
@glehmann glehmann force-pushed the gln/xapi-network-typehints branch from b3d821d to 7b59763 Compare February 15, 2026 22:06
@glehmann glehmann force-pushed the gln/xen-guest-tools-typehints branch 2 times, most recently from 29af0fb to cce863e Compare February 16, 2026 09:39
@glehmann glehmann force-pushed the gln/xapi-network-typehints branch from 7b59763 to 50754ce Compare February 16, 2026 09:39
@@ -1,9 +1,13 @@
from __future__ import annotations
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this import ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After reading a bit it seems this line will turn into a SyntaxError in 1 or 2 Python releases, right?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

See https://peps.python.org/pep-0749/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@TSnake41 TSnake41 requested a review from a team February 16, 2026 12:49
@@ -1,9 +1,13 @@
from __future__ import annotations

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@glehmann glehmann force-pushed the gln/xen-guest-tools-typehints branch from cce863e to 21e4825 Compare February 16, 2026 20:59
@olivierh-pro olivierh-pro requested a review from a team February 17, 2026 09:48
@glehmann glehmann force-pushed the gln/xen-guest-tools-typehints branch from 21e4825 to d529cdc Compare February 17, 2026 21:01
@glehmann glehmann force-pushed the gln/xapi-network-typehints branch from 50754ce to 4c9b247 Compare February 17, 2026 21:01
@glehmann glehmann force-pushed the gln/xen-guest-tools-typehints branch from d529cdc to 727c335 Compare February 17, 2026 21:40
@glehmann glehmann force-pushed the gln/xapi-network-typehints branch 2 times, most recently from 7b6389e to 6c7b248 Compare February 19, 2026 21:29
@glehmann glehmann force-pushed the gln/xen-guest-tools-typehints branch from 727c335 to 5f853c8 Compare February 19, 2026 21:29
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>
@glehmann glehmann force-pushed the gln/xen-guest-tools-typehints branch from 5f853c8 to c7b6529 Compare February 19, 2026 21:49
@glehmann glehmann force-pushed the gln/xapi-network-typehints branch from 6c7b248 to 1c70a06 Compare February 19, 2026 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants