chore: bring pyright strict mode to zero errors - #4
Merged
Conversation
Annotate the full source tree and test suite so `pyright` passes in strict
mode with zero errors, and make the CI `typecheck` job blocking.
The bulk of this is annotation debt inherited from upstream and newly surfaced
by the fork's CI: missing parameter/return types, typed test fixtures and mock
helpers, and oxml-layer accessor declarations. A small number of genuine
latent bugs uncovered along the way are also fixed:
- `Document.add_comment` normalizes a `None` `text` argument to `""`.
- `OpcPackage.walk_parts` drops its mutable default argument.
- `BaseStyle` accessors read the always-present style element, fixing the
post-`delete()` state.
- `CT_NumBuilder.__attrs__` is the intended one-tuple `("w:numId",)`.
Making the `| None` accessor signatures honest also completes two previously
error-raising edge paths (both now covered by tests):
- Assigning `None` to a cell's `bg_color` clears shading instead of raising.
- Assigning a next-paragraph-style whose own `style_id` is `None` removes the
`w:next` setting, consistent with assigning `None` or self.
Tooling: bump `pyright` to `1.1.410` (clears a typeshed false positive) and
remove `continue-on-error` from the CI typecheck job.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y9zbyKfqck1a5RM6Y7LLTN
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y9zbyKfqck1a5RM6Y7LLTN
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
Annotate the full source tree and test suite so
pyrightpasses in strict mode with zero errors, and make the CItypecheckjob blocking (previouslycontinue-on-error).The vast majority is annotation debt inherited from upstream and newly surfaced by the fork's CI: missing parameter/return types, typed test fixtures and mock helpers, and oxml-layer accessor declarations. No runtime behavior change there.
Real fixes uncovered along the way
Document.add_commentnormalizes aNonetextargument to""instead of forwardingNone.OpcPackage.walk_partsno longer uses a mutable default argument.BaseStyleaccessors read the always-present style element, fixing the post-delete()state.CT_NumBuilder.__attrs__is the intended one-tuple("w:numId",).Making the
| Noneaccessor signatures honest also completes two previously error-raising edge paths (both now tested):Noneto a cell'sbg_colorclears shading instead of raisingValueError.style_idisNoneremoves thew:nextsetting.Tooling
pyrightto1.1.410(clears a typeshed false positive).continue-on-errorfrom the CItypecheckjob.Verification
uv run ruff check ./ruff format --check .— cleanuv run pyright— 0 errors, 0 warningsuv run pytest— 1653 passeduv run behave— 654 scenarios passedVersion bumped to
1.2.1(patch); CHANGELOG updated.🤖 Generated with Claude Code
https://claude.ai/code/session_01Y9zbyKfqck1a5RM6Y7LLTN