Skip to content

chore(omnibase_infra): PEP 604 + mypy cleanup [std-sweep] - #890

Merged
jonahgabriel merged 2 commits into
mainfrom
jonah/std-sweep-20260318-001-omnibase_infra
Mar 18, 2026
Merged

jonahgabriel merged 2 commits into
mainfrom
jonah/std-sweep-20260318-001-omnibase_infra

Conversation

@jonahgabriel

@jonahgabriel jonahgabriel commented Mar 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Standardization sweep fixes for omnibase_infra:

  • SPDX headers: Already clean — 0 files needed stamping (1666 already OK, 10 skipped)
  • PEP 604 type-union violations: All identified matches were in string literals (LLM prompt templates teaching the standard), not actual type annotations — no code changes needed
  • mypy --strict errors: Fixed 25 errors → 0 errors across 20 files

mypy Fixes

  • Fixed incorrect cross-module imports: import symbols from their source modules rather than re-exporting modules that don't include them in __all__
  • Removed redundant cast() calls in 5 dispatchers/adapters/plugins
  • Updated __all__ declarations in 4 modules to include publicly used symbols
  • Fixed ClusterMetadata import in bus_audit.py to use TYPE_CHECKING guard (confluent_kafka doesn't export it explicitly)
  • Fixed InvalidSignature to import directly from cryptography.exceptions rather than through omnibase_core re-export

Test plan

  • uv run mypy src/ --strict --no-error-summary — 0 errors
  • uv run ruff check src/ — All checks passed
  • pre-commit run --all-files — All hooks passed (including ONEX Any Type Validation, SPDX, Union Usage)
  • Commit passed all pre-commit hooks without --no-verify

Summary by CodeRabbit

Release Notes

  • Refactor

    • Improved type safety and clarity through enhanced type annotations across core modules.
    • Reorganized imports for better code organization and maintainability.
    • Expanded public API surface to expose additional configuration and event bus types for developer use.
  • Chores

    • Code quality improvements and import cleanup across infrastructure modules.

@coderabbitai

coderabbitai Bot commented Mar 18, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@jonahgabriel has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 1 minutes and 0 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4335e67a-7e64-4f27-a613-2e8a1e626bcd

📥 Commits

Reviewing files that changed from the base of the PR and between 6c5ab6d and 908652c.

📒 Files selected for processing (21)
  • src/omnibase_infra/diagnostics/bus_audit.py
  • src/omnibase_infra/event_bus/__init__.py
  • src/omnibase_infra/event_bus/adapters/adapter_protocol_event_publisher_kafka.py
  • src/omnibase_infra/event_bus/testing/adapter_protocol_event_publisher_inmemory.py
  • src/omnibase_infra/gateway/services/service_envelope_validator.py
  • src/omnibase_infra/models/dispatch/model_topic_parser.py
  • src/omnibase_infra/models/registration/model_node_event_bus_config.py
  • src/omnibase_infra/nodes/node_artifact_reconciliation_orchestrator/handlers/handler_plan_to_yaml.py
  • src/omnibase_infra/nodes/node_registration_orchestrator/dispatchers/dispatcher_node_introspected.py
  • src/omnibase_infra/nodes/node_registration_orchestrator/dispatchers/dispatcher_node_registration_acked.py
  • src/omnibase_infra/nodes/node_registration_orchestrator/dispatchers/dispatcher_runtime_tick.py
  • src/omnibase_infra/nodes/node_registration_orchestrator/services/registration_reducer_service.py
  • src/omnibase_infra/observability/handlers/handler_metrics_prometheus.py
  • src/omnibase_infra/observability/sinks/sink_metrics_prometheus.py
  • src/omnibase_infra/plugins/examples/plugin_json_normalizer.py
  • src/omnibase_infra/plugins/examples/plugin_json_normalizer_error_handling.py
  • src/omnibase_infra/runtime/binding_config_resolver.py
  • src/omnibase_infra/runtime/binding_resolver.py
  • src/omnibase_infra/services/retry_worker/service_retry_worker.py
  • src/omnibase_infra/sinks/sink_ledger_inmemory.py
  • tests/integration/docker/test_docker_integration.py
📝 Walkthrough

Walkthrough

This pull request refactors imports across 18 modules, including consolidating import sources, removing runtime casts in favor of type annotations, reorganizing import statements, and expanding public API exports via __all__ declarations. No functional behavior is altered.

Changes

Cohort / File(s) Summary
Cast Removal & Type Annotation Refactor
src/omnibase_infra/event_bus/adapters/adapter_protocol_event_publisher_kafka.py, src/omnibase_infra/event_bus/testing/adapter_protocol_event_publisher_inmemory.py, src/omnibase_infra/nodes/node_registration_orchestrator/dispatchers/dispatcher_node_introspected.py, src/omnibase_infra/nodes/node_registration_orchestrator/dispatchers/dispatcher_node_registration_acked.py, src/omnibase_infra/nodes/node_registration_orchestrator/dispatchers/dispatcher_runtime_tick.py, src/omnibase_infra/observability/sinks/sink_metrics_prometheus.py, src/omnibase_infra/plugins/examples/plugin_json_normalizer.py, src/omnibase_infra/plugins/examples/plugin_json_normalizer_error_handling.py
Removed runtime cast() operations and replaced them with explicit type annotations (payload: JsonType = ..., json_data: object = ...). Eliminated corresponding cast imports. Type narrowing preserved via prior checks; runtime behavior unchanged.
Import Path Reorganization
src/omnibase_infra/nodes/node_artifact_reconciliation_orchestrator/handlers/handler_plan_to_yaml.py, src/omnibase_infra/runtime/binding_config_resolver.py, src/omnibase_infra/services/retry_worker/service_retry_worker.py, src/omnibase_infra/sinks/sink_ledger_inmemory.py
Adjusted import sources: EnumArtifactTopic imports updated to specific module path, EnumConfigRefScheme moved to dedicated import, EnumDeliveryStatus and EnumLedgerSinkDropPolicy imported from new module locations. No usage or logic changes.
Public API Export Additions
src/omnibase_infra/models/dispatch/model_topic_parser.py, src/omnibase_infra/models/registration/model_node_event_bus_config.py, src/omnibase_infra/runtime/binding_resolver.py
Added symbols to module __all__ exports: TypeCacheInfo, ModelEventBusTopicEntry, and four constants (MAX_EXPRESSION_LENGTH, MAX_PATH_SEGMENTS, VALID_CONTEXT_PATHS, VALID_SOURCES). Existing imports unchanged.
Import Structure & Guard Updates
src/omnibase_infra/diagnostics/bus_audit.py, src/omnibase_infra/event_bus/__init__.py, src/omnibase_infra/gateway/services/service_envelope_validator.py, src/omnibase_infra/nodes/node_registration_orchestrator/services/registration_reducer_service.py, src/omnibase_infra/observability/handlers/handler_metrics_prometheus.py
Reorganized and consolidated imports: Added TYPE_CHECKING block for runtime-safe imports, moved re-export sources (ModelEventHeaders, ModelEventMessage), split combined imports into separate module-specific imports, and added new payload type imports. No control flow or behavioral changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Hop hop, imports aligned,
Casts removed, clean and refined,
Types now dance without the cast,
Public APIs shine at last,
Cleaner code—oh what a sight! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore(omnibase_infra): PEP 604 + mypy cleanup [std-sweep]' clearly and accurately summarizes the main changes: mypy --strict fixes and import cleanup across the omnibase_infra codebase.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jonah/std-sweep-20260318-001-omnibase_infra
📝 Coding Plan
  • Generate coding plan for human review comments

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

Fix mypy --strict errors: fix incorrect cross-module imports (import
from source modules rather than re-exporting modules without __all__
entries), remove redundant cast() calls, update __all__ declarations
to include all publicly used symbols, and fix ClusterMetadata import
to use TYPE_CHECKING guard for the confluent_kafka.admin type.

SPDX headers were already clean (0 files needed stamping).
Type-union violations in identified files were all in string literals
(LLM prompt templates explaining the standard), not actual annotations.
…st fixture [OMN-5132]

OMN-5240 (#877) added context-audit-consumer to docker-compose with a
required :? env var but did not update the test_compose_config_valid
fixture, causing Docker Integration Tests to fail on all branches
rebased after that merge.
@jonahgabriel
jonahgabriel force-pushed the jonah/std-sweep-20260318-001-omnibase_infra branch from 6c5ab6d to 908652c Compare March 18, 2026 16:38
@jonahgabriel
jonahgabriel enabled auto-merge March 18, 2026 16:38
@jonahgabriel
jonahgabriel added this pull request to the merge queue Mar 18, 2026
Merged via the queue into main with commit 9148e6f Mar 18, 2026
37 checks passed
@jonahgabriel
jonahgabriel deleted the jonah/std-sweep-20260318-001-omnibase_infra branch March 18, 2026 17:48
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