Skip to content

feat(Python): add ruff + pyright and complete type annotations#1366

Merged
MistEO merged 1 commit into
mainfrom
maafw-python-strict-typing
Jun 15, 2026
Merged

feat(Python): add ruff + pyright and complete type annotations#1366
MistEO merged 1 commit into
mainfrom
maafw-python-strict-typing

Conversation

@Windsland52

Copy link
Copy Markdown
Member

Add [tool.ruff] (E/F/I/UP/B, line-length 120) and [tool.pyright] (strict) to the maafw Python binding and finish the package's type annotations so both pass clean (pyright strict: 735 -> 0 errors; ruff: clean). This lets projects depending on maafw run pyright in strict mode with no errors leaking from the binding's public API.

Notable changes:

  • define.py: add all; typed empty-literal default_factory
  • job.py: Job/JobWithResult are now Generic[TResult], so Tasker.post_task(...).get() returns Optional[TaskDetail] precisely (the key fix enabling downstream strict)
  • parameterize bare dict/list; type ctypes callbacks, holders, decorators
  • pipeline.py: cast() at the JSON-deserialization boundary
  • ctypes c_char_p callback params -> bytes; FUNCTYPE annotations -> Any
  • .vscode/settings.json: Python formatter switched to Ruff (matches pyproject)
  • .gitignore: ignore .venv/ and .ruff_cache/

Documented relaxations in pyproject.toml: reportPrivateUsage=none for the intentional cross-module _handle FFI coupling; per-file F403/F405 ignore for the define.py aggregation hub (consumed via from .define import *).

…otations

Add [tool.ruff] (E/F/I/UP/B, line-length 120) and [tool.pyright] (strict)
to the maafw Python binding and finish the package's type annotations so
both pass clean (pyright strict: 735 -> 0 errors; ruff: clean). This lets
projects depending on maafw run pyright in strict mode with no errors
leaking from the binding's public API.

Notable changes:
- define.py: add __all__; typed empty-literal default_factory
- job.py: Job/JobWithResult are now Generic[TResult], so
  Tasker.post_task(...).get() returns Optional[TaskDetail] precisely
  (the key fix enabling downstream strict)
- parameterize bare dict/list; type ctypes callbacks, holders, decorators
- pipeline.py: cast() at the JSON-deserialization boundary
- ctypes c_char_p callback params -> bytes; FUNCTYPE annotations -> Any
- .vscode/settings.json: Python formatter switched to Ruff (matches pyproject)
- .gitignore: ignore .venv/ and .ruff_cache/

Documented relaxations in pyproject.toml: reportPrivateUsage=none for the
intentional cross-module _handle FFI coupling; per-file F403/F405 ignore
for the define.py aggregation hub (consumed via `from .define import *`).

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry @Windsland52, your pull request is larger than the review limit of 150000 diff characters

@Windsland52 Windsland52 marked this pull request as ready for review June 13, 2026 15:28
@MistEO MistEO merged commit 12bc396 into main Jun 15, 2026
16 of 19 checks passed
@MistEO MistEO deleted the maafw-python-strict-typing branch June 15, 2026 16:31
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.

2 participants