Skip to content

Conversation

@flipbit03
Copy link
Owner

@flipbit03 flipbit03 commented Jan 25, 2026

Summary

Closes #31

  • Docs: Update README with complete typing recommendation including # type: ignore[misc] for dynamic mixin and optional method stubs
  • Refactor: Remove global_rewriter singleton, attach rewriter to generated mixin class as _sqlalchemy_easy_softdelete_rewriter for better test isolation
  • Tests: Restructure tests into isolated "worlds" to enable testing different mixin configurations
  • Typecheck: make typecheck now checks both source and tests

Test Worlds

Each world has its own model base, soft delete mixin, and tests with globally unique names:

World Prefix Description
tests/default_config/ SD (Soft Delete) Default mixin configuration (original tests)
tests/custom_deleted_field_name/ CFN Custom field name (removed_at)
tests/custom_method_names/ CMN Custom method names (soft_delete/restore)
tests/disabled_methods/ DM Disabled delete/undelete methods
tests/custom_default_value/ CDV Custom default value function
tests/integer_field_type/ IFT Integer field type instead of DateTime

Test plan

  • All 70 tests pass (CI uses PostgreSQL, no skips)
  • Tests pass on Python 3.10, 3.11, 3.12, 3.13, 3.14
  • Tests pass on SQLAlchemy 1.4 and 2.0
  • make typecheck passes (source + tests)
  • make lint passes

- Update README type hint recommendation from `deleted_at: datetime` to
  `deleted_at: Mapped[datetime | None]` for proper SQLAlchemy support

- Remove global_rewriter singleton, attach rewriter to generated mixin
  class as `_sqlalchemy_easy_softdelete_rewriter` for better isolation

- Restructure tests into isolated "worlds" to enable testing different
  mixin configurations:
  - tests/default_config/ - default mixin configuration
  - tests/custom_deleted_field_name/ - custom field name (removed_at)
  - tests/custom_method_names/ - custom method names (soft_delete/restore)
  - tests/disabled_methods/ - disabled delete/undelete methods
  - tests/custom_default_value/ - custom default value function
  - tests/integer_field_type/ - integer field type instead of DateTime

- Add comprehensive tests for all mixin configuration options
@flipbit03 flipbit03 force-pushed the fix/improve-type-hint-docs-31 branch 7 times, most recently from 5b79157 to 190027a Compare January 26, 2026 00:07
@flipbit03 flipbit03 changed the title Improve type hint docs, refactor rewriter, restructure tests (#31) Improve type hint docs, restructure tests (#31) Jan 26, 2026
@flipbit03 flipbit03 force-pushed the fix/improve-type-hint-docs-31 branch 4 times, most recently from 14714bd to e076715 Compare January 26, 2026 00:48
@flipbit03 flipbit03 force-pushed the fix/improve-type-hint-docs-31 branch from e076715 to b0f2ad6 Compare January 26, 2026 01:36
- Add mypy configuration to pyproject.toml
- Add `make typecheck-hints` target to validate type hints test file
- This ensures the Mapped[datetime | None] type hint is verified at compile time
@flipbit03 flipbit03 merged commit ea4835c into main Jan 26, 2026
6 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.

[Docs / Type Hinting] Better type documentation for generated Mixin class

3 participants