Skip to content

python: add type annotations to PMDA API#2622

Open
natoscott wants to merge 1 commit into
performancecopilot:mainfrom
natoscott:pmda-python-typing
Open

python: add type annotations to PMDA API#2622
natoscott wants to merge 1 commit into
performancecopilot:mainfrom
natoscott:pmda-python-typing

Conversation

@natoscott

Copy link
Copy Markdown
Member

No description provided.

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Repository UI (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: ead3eea0-b065-41f1-b9e1-83f6b08d3d21

📥 Commits

Reviewing files that changed from the base of the PR and between 0186ab1 and 3f69b5b.

📒 Files selected for processing (1)
  • src/python/pcp/pmda.py

📝 Walkthrough

Summary by CodeRabbit

  • Refactor
    • Enhanced code quality and IDE integration to improve the development experience and code maintainability.

Walkthrough

Type annotations are added throughout src/python/pcp/pmda.py. The typing module imports (Any, Callable, Optional, Union) are introduced at the top, and all public function and method signatures across module-level helpers, ctypes wrapper structs (pmdaMetric, pmdaInstid, pmdaIndom, pmdaUnits), MetricDispatch, and PMDA are updated with explicit parameter and return type hints. No control-flow logic is changed.

Changes

Type annotations for pmda.py

Layer / File(s) Summary
Typing imports and module-level helper annotations
src/python/pcp/pmda.py
Adds Any, Callable, Optional, Union from typing and annotates pmdaAddLabels, pmdaAddLabelFlags, pmdaAddNotes, and pmdaGetContext with explicit parameter and return types. Copyright year updated to 2025.
Typed constructors and methods on ctypes wrapper structs
src/python/pcp/pmda.py
Annotates __init__ and all instance methods of pmdaMetric, pmdaInstid, pmdaIndom, and pmdaUnits, including Optional[Union[dict, list]] for instance sets and typed return annotations on all cache and lookup methods.
Typed MetricDispatch public API
src/python/pcp/pmda.py
Annotates MetricDispatch.__init__ and all public methods (add_metric, remove_metric, add_indom, replace_indom, inst_lookup, inst_name_lookup, pmid_name_lookup) with typed parameters (pmdaMetric, pmdaIndom, pmInDom, Union, Optional) and -> None or -> Optional[str] returns.
Typed PMDA class methods and static helpers
src/python/pcp/pmda.py
Annotates PMDA.__init__ with Optional[str] for logfile/helpfile, lifecycle methods (pmda_notready, pmda_ready, run) with -> None, all static callback setters with Callable[..., Any] -> None, and identity/mapping helpers (pmid, indom, units, uptime, log, dbg, err) with explicit types.

Poem

🐇 Hoppity-hop through the type-annotated land,
Where Optional[str] fits snug in each hand.
Callable[..., Any] — the callbacks now speak,
No more bare params playing hide-and-seek!
With Union and pmInDom neatly in line,
This rabbit declares: the signatures shine. ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive No description was provided by the author, making it impossible to evaluate relevance to the changeset. Consider adding a brief description explaining the purpose and scope of the type annotation additions to help reviewers understand the motivation.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'python: add type annotations to PMDA API' accurately and directly summarizes the main change—adding Python type annotations throughout the PMDA module.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@natoscott natoscott force-pushed the pmda-python-typing branch from 8321483 to 3f69b5b Compare June 16, 2026 03:07
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.

1 participant