Repository navigation
Open
Labels
bugLabel for all kind of bugs.connectorsConnector issues - builtin integrations with other tools.operationsIssues with operations.
Description
Describe the bug
The pyinfra.api.host.Host class is incompletely typed, e.g. the host.groups attribute is not typed.
Ideally the entire Host class in https://github.com/pyinfra-dev/pyinfra/blob/3.x/src/pyinfra/api/host.py#L100-L456 should be fully typed, because it is exposed as API.
To Reproduce
from pyinfra import host
from typing import reveal_type
reveal_type(host)
print(f"{type(host)=}")
reveal_type(host.data)
print(f"{type(host.data)=}")
print(f"{type(host)=}")
reveal_type(host.groups)
print(f"{type(host.groups)=}")
host.noop("test noop")
reveal_type(host)
print(f"{type(host)=}")Running mypy --strict --disallow-any-expr test.py shows:
test.py:4: note: Revealed type is "pyinfra.api.host.Host"
test.py:7: note: Revealed type is "pyinfra.api.host.HostData"
test.py:11: error: Expression has type "Any" [misc]
test.py:11: note: Revealed type is "Any"
test.py:12: error: Expression type contains "Any" (has type "type[Any]") [misc]
test.py:12: error: Expression has type "Any" [misc]
test.py:16: note: Revealed type is "pyinfra.api.host.Host"
Expected behavior
A clear and concise description of what you expected to happen.
Meta
- Include output of
pyinfra --support.
If you are having issues with pyinfra or wish to make feature requests, please
check out the GitHub issues at https://github.com/Fizzadar/pyinfra/issues .
When adding an issue, be sure to include the following:
System: Linux
Platform: Linux-7.3.4+deb14-amd64-x86_64-with-glibc2.43
Release: 7.3.4+deb14-amd64
Machine: x86_64
pyinfra: v3.11.0
cyclopts: v4.17.0
distro: v1.9.0
gevent: v26.9.0
jinja2: v3.1.6
packaging: v26.3
paramiko: v5.1.0
pydantic: v2.14.1
python-dateutil: v2.9.0.post0
rich: v15.0.0
typeguard: v4.6.0
types-paramiko: v4.0
typing-extensions: v4.16.0
Executable: /usr/local/bin/pyinfra
Python: 3.14.10 (CPython, GCC 16.2.0)
- How was pyinfra installed (source/pip)?
- Include pyinfra-debug.log (if one was created)
- Consider including output with
-vvand--debug.
Related bugs
I found this issue while using mypy --strict --disallow-any-expr on my pyinfra code, which reveals some underlying issues, like #2082 #2081 #2083
Metadata
Metadata
Assignees
Labels
bugLabel for all kind of bugs.connectorsConnector issues - builtin integrations with other tools.operationsIssues with operations.
Activity