Fix all 123 mypy type errors across 28 source files#137
Merged
scottscott merged 1 commit intonomoticai:mainfrom Mar 18, 2026
Merged
Fix all 123 mypy type errors across 28 source files#137scottscott merged 1 commit intonomoticai:mainfrom
scottscott merged 1 commit intonomoticai:mainfrom
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
- Fix type annotations and return types in api, audit, authority, behavioral_provenance, cli, compliance_report, cross_dimensional, evaluator, evidence, executor, fleet, fleet_sim, id_registry, registry, runtime, sandbox, scorecard, sdk, seal, store, ucs_tracker, workflow_governor, async_executor - Add 5 JSON schema files for context-profile, evidence-bundle, governance-response, governance-token, reasoning-artifact - Add pytest-asyncio to dev dependencies so async executor tests run in CI - Expand test coverage for sdk certificate refresh, evidence drift history, workflow governor method concentration, API metrics and ledger endpoints, and CLI scope/authority-registry/policy-validate/roles commands Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ee60ab3 to
a90fa40
Compare
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
Resolves all 123 mypy strict-mode type errors present in the codebase. Where possible, fixes use proper type narrowing (
isinstance,typing.List, explicit annotations) rather than# type: ignoresuppressions. All 4,912 tests pass with these changes.Key Changes
Structural improvements (checked by mypy, no suppressions):
runtime.py— Useisinstancenarrowing for 5GovernanceDimensionsubclasses (ScopeCompliance,IsolationIntegrity,TemporalCompliance,HumanOverride,EthicalAlignment) instead of# type: ignore[attr-defined], so mypy verifies the subclass methods actually existruntime.py— Declare_cert_store: CertificateStore | None = Nonein__init__to replacehasattrguards with properNonechecksstore.py,authority.py,registry.py— Usetyping.Listin return annotations where alist()method on the class shadows the builtin, preserving downstream type visibilityevaluator.py— Bundle JSON schemas inside the package (src/nomotic/schemas/) soimportlib.resourcescan load them without fragileTraversable.parenttraversal that only works from source checkoutsapi.py— Correct return types on 4 handler methods that returned wrong-arity tuples on error paths; useisinstancefor playground scope dimension accessscorecard.py— Fix reference to nonexistentreport.all_gapsattribute; use explicit concatenation ofcritical_gaps + high_gaps + medium_gaps + low_gapsbehavioral_provenance.py,cross_dimensional.py,fleet.py,workflow_governor.py— Replacemax(d, key=d.get)withlambda k: d[k]to satisfy mypy'sSupportsLessThanrequirement on sort keysAnnotation and variable fixes:
api.py,fleet_sim.py— Annotate module-level dicts/lists (_DIMENSION_META,DEPARTMENTS,BEHAVIOR_PROFILES) that mypy inferred asdict[str, object]cli.py— Rename conflicting variables, add union type declarations, and fix ~20 errors fromDryRunResulttyped asdict[str, object]runtime.py— Addassert verdict is not Nonenarrowing before 3GovernanceVerdictassignmentspyproject.toml— Addtypes-PyYAMLto dev dependencies (resolves 8import-untypederrors)Bug fix:
sdk.py— Fixconn.close()inrefresh_certificate()that was closing the wrong connection variable (conninstead ofconn2)Implementation Details
# type: ignorecomments remain in the codebase — all are legitimate suppressions for known mypy limitations (tuple-length narrowing vialen(), dynamic attribute patching on server contexts,BaseHTTPRequestHandler.serveroverride, Windows-onlyctypes.windll, and untyped third-party imports)sdk.pybug fix — all other fixes are type annotations, variable renames, and structural improvementssrc/nomotic/schemas/are copies of the existing root-levelschemas/directory; the originals are preserved for external toolingassisted-by: Claude
🤖 Generated with Claude Code