Repository navigation
Add modern type hints and reST docstrings throughout PGraph.py - #5
Merged
Merged
Conversation
Type-hints every public and most private members using PEP 604 union syntax (X | Y) and numpy.typing (ArrayLike/NDArray), with matching reST docstrings including runblock examples that are actually executed at doc build time. Adds mypy as an informational (non-blocking) CI job, and sphinx-pyrunblock/sphinx-codeautolink to the docs toolchain, replacing the unmaintained sphinx-autorun. Fixes a handful of small, incidental bugs surfaced while typing this pass touched: _metricfunc silently swallowing an unrecognized metric string instead of raising, and a missing __iter__/abstract _graphcolor that mypy couldn't otherwise see. No behavioural changes to any bugfix-cluster method (add_vertex, connect, remove, the path_* search methods, the matrix methods) -- those are typed together with their fixes in a follow-up branch, since the fix and the type hints land on the same lines for those methods. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
X | Y) andnumpy.typing(ArrayLike/NDArray), with matching reST docstrings including.. runblock:: pyconexamples that are actually executed at doc build time (viasphinx-pyrunblock, replacing the unmaintainedsphinx-autorun).mypyas an informational (non-blocking,continue-on-error: true) CI job — the type-hinting pass surfaced a baseline of pre-existing design tensions (Liskov-incompatible overrides, embedded-graph invariants not visible to the type checker) tracked separately, not fixed here.sphinx-codeautolinkto the docs toolchain, matching spatialgeometry's setup._metricfuncsilently swallowing an unrecognized metric string instead of raising, and a missing__iter__/abstract_graphcolorthat mypy couldn't otherwise see.docs/source/*.rstreferenced the module as barePGraphinstead ofpgraph.PGraph, a leftover from before thesrc/pgraph/layout migration — autodoc couldn't import anything.No behavioural changes to any bugfix-cluster method (
add_vertex,connect,remove, thepath_*search methods, the matrix methods) — those are typed together with their fixes in the next PR in this stack, since the fix and the type hints land on the same lines for those methods.Stacked on #3 (
chore/python-3.14-support) — this is the first of four PRs building on top of it: type-hints → rename → bugfixes → iscyclic.Test plan
runblockexamples execute without errormypy src/pgraph/PGraph.pyruns (informational, not blocking)