Skip to content

refactor: improve type safety with generic parameters and package support#15

Merged
Kamilbenkirane merged 2 commits intomainfrom
refactor/improve-type-safety-and-package-support
Nov 7, 2025
Merged

refactor: improve type safety with generic parameters and package support#15
Kamilbenkirane merged 2 commits intomainfrom
refactor/improve-type-safety-and-package-support

Conversation

@Kamilbenkirane
Copy link
Member

Summary

This PR enhances type safety across the codebase and adds comprehensive support for the packages workspace:

  • Type Safety: Added Params generic parameter to Client and Stream classes for capability-specific parameter typing
  • Package Support: Extended CI/CD workflows and Make commands to include packages/ directory in all quality checks
  • Constraint Enhancement: Added special_values parameter to Range constraint for flexible validation
  • Test Updates: Fixed type annotations to match updated abstract method signatures

Key Changes

Type Safety Improvements

  • Added Params type parameter to Client[In, Out, Params] for strongly-typed parameters per capability
  • Updated Stream[Out, Params] to pass parameters through to _parse_output()
  • Fixed abstract method signatures with proper type annotations and overrides
  • Configured mypy to handle test and package module patterns appropriately

Package Support

  • Updated .github/workflows/ci.yml to include packages/ in format, lint, type-check, and security jobs
  • Extended Makefile commands (lint, format, typecheck, security) to check packages
  • Added mypy configuration for celeste_* package modules

Constraint Enhancement

  • Range constraint now accepts special_values list to allow specific values outside min/max bounds

Test Plan

  • All pre-commit hooks pass (format, lint, type check, security)
  • All existing tests pass
  • CI/CD workflows updated to validate packages directory
  • Type safety verified with mypy across core, tests, and packages

Impact

  • No breaking changes to public API
  • Improved developer experience with better type inference
  • Foundation for type-safe package development

…port

This commit enhances type safety across the codebase and adds support for packages workspace:

**Type Safety Improvements:**
- Add `Params` type parameter to `Client` class for capability-specific parameter typing
- Update `Stream` class with `Params` generic for type-safe parameter passing
- Add proper type annotations to abstract methods (`_parse_content`, `_create_inputs`, etc.)
- Fix mypy type errors with proper overrides and return type annotations
- Disable specific mypy error codes for tests and package modules to reduce noise

**Package Support:**
- Extend CI/CD workflows to include `packages/` directory in linting, formatting, type checking, and security scans
- Update Makefile commands to check packages alongside core source
- Add mypy configuration for package modules with appropriate error code handling

**Constraint Enhancement:**
- Add `special_values` parameter to `Range` constraint to allow specific values that bypass min/max validation

**Test Updates:**
- Fix type annotations in test files to match updated abstract method signatures
- Add proper type ignores where needed for test flexibility

All changes maintain backward compatibility while improving type safety and developer experience.
The packages/ directory exists locally but may not be present in CI until committed.
Add conditional checks to only include packages/ in checks if the directory exists.
@Kamilbenkirane Kamilbenkirane merged commit 6074344 into main Nov 7, 2025
10 of 12 checks passed
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