Skip to content

Improve type annotations throughout pystemd - #111

Merged
aleivag merged 1 commit into
systemd:mainfrom
aleivag:improve-typing-annotations
Jan 6, 2026
Merged

Improve type annotations throughout pystemd#111
aleivag merged 1 commit into
systemd:mainfrom
aleivag:improve-typing-annotations

Conversation

@aleivag

Copy link
Copy Markdown
Contributor

This commit modernizes and enhances type annotations across the codebase:

  • Add comprehensive type annotations to pystemd.run function signature including all 30 parameters and return type
  • Create SupportsFileno Protocol for proper typing of file-like objects
  • Add from future import annotations to all Python source files for forward compatibility
  • Migrate from old typing syntax to modern Python 3.10+ syntax:
    • Union[A, B] -> A | B
    • Optional[T] -> T | None
    • List[T] -> list[T]
    • Tuple[T, ...] -> tuple[T, ...]
    • Dict[K, V] -> dict[K, V]
  • Update init.pyi stub file to match improved run() signature
  • Add proper type annotations to exit method in base.py
  • Remove unused typing imports (Union, Optional, List, Tuple, Dict) where replaced by modern syntax

These changes improve IDE support, enable better static type checking, and make the codebase more maintainable while maintaining backward compatibility with Python 3.10+.

@aleivag
aleivagforce-pushed the improve-typing-annotations branch from e7b71ec to 74b302bCompareJanuary 6, 2026 23:11
This commit modernizes and enhances type annotations across the codebase:
- Add comprehensive type annotations to pystemd.run function signature
including all 30 parameters and return type
- Create SupportsFileno Protocol for proper typing of file-like objects
- Add from __future__ import annotations to all Python source files
for forward compatibility
- Migrate from old typing syntax to modern Python 3.10+ syntax:
* Union[A, B] -> A | B
* Optional[T] -> T | None
* List[T] -> list[T]
* Tuple[T, ...] -> tuple[T, ...]
* Dict[K, V] -> dict[K, V]
- Update __init__.pyi stub file to match improved run() signature
- Add proper type annotations to __exit__ method in base.py
- Remove unused typing imports (Union, Optional, List, Tuple, Dict)
where replaced by modern syntax
These changes improve IDE support, enable better static type checking,
and make the codebase more maintainable while maintaining backward
compatibility with Python 3.10+.
@aleivag
aleivagforce-pushed the improve-typing-annotations branch from 74b302b to 0c91f65CompareJanuary 6, 2026 23:13
@aleivag
aleivag marked this pull request as ready for review January 6, 2026 23:15
@aleivag
aleivag merged commit 0ae84d2 into systemd:mainJan 6, 2026
6 of 33 checks passed
@aleivag
aleivag deleted the improve-typing-annotations branch January 6, 2026 23:15
Sign up for freeto 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.

1 participant

@aleivag