Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Add type annotations for operations #1227

Open
wants to merge 4 commits into
base: 3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pyinfra/operations/runit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Manage runit services.
"""

from __future__ import annotations

from typing import Optional

from pyinfra import host
Expand Down
20 changes: 15 additions & 5 deletions scripts/generate_operations_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,21 @@ def build_operations_docs():
)

# Build args string
args = [
"{0}={1}".format(arg, defaults[arg]) if arg in defaults else arg
for arg in argspec.args
if arg not in ("state", "host") and not arg.startswith("_")
]
args = []

for arg in argspec.args:
if arg in ("state", "host") or arg.startswith("_"):
continue

value = arg

if arg in argspec.annotations:
value += f": {argspec.annotations[arg]}"

if arg in defaults:
value += f"={defaults[arg]}"

args.append(value)

if len(", ".join(args)) <= MODULE_DEF_LINE_MAX:
args_string = ", ".join(args)
Expand Down
Loading