Skip to content

Immutable registry keys with Literal types (v0.8.3) - #90

Merged
octo-youcef merged 4 commits into
mainfrom
feature/immutable-registry-keys
May 1, 2026
Merged

Immutable registry keys with Literal types (v0.8.3)#90
octo-youcef merged 4 commits into
mainfrom
feature/immutable-registry-keys

Conversation

@octo-youcef

Copy link
Copy Markdown
Collaborator

Summary

Refactors query and quality rule names to use Literal types instead of str for improved type safety and immutability.

Closes #86

Changes

  • Query names: All 5 built-in queries now use Literal["exact-name"] type annotation
    • find-dead-code, analyze-module-centrality, find-critical-functions, analyze-call-complexity, detect-circular-dependencies
  • Quality rule names: All 3 built-in rules now use Literal["exact-name"] type annotation
    • type-coverage, docstring-coverage, param-complexity

Benefits

  • Type safety: Typos in registry lookups caught at type-check time instead of runtime
  • IDE autocomplete: IDEs can suggest valid query/rule names from Literal type
  • Immutability: Frozen attrs classes with Literal types prevent runtime name modifications
  • Self-documenting: Type signature shows exact valid values

Testing

  • All 289 tests passing
  • No behavior changes - purely a type safety improvement
  • Coverage: 80.49% (above 75% threshold)

Commits

  1. Use Literal types for query names (immutable registry keys)
  2. Use Literal types for quality rule names (immutable registry keys)
  3. Update CHANGELOG for v0.8.3
  4. Bump version: 0.8.2 → 0.8.3

🤖 Generated with Claude Code

octo-youcef and others added 4 commits May 1, 2026 15:31
Changed all 5 query classes to use Literal types for their name field:
- DeadCodeQuery: Literal["find-dead-code"]
- ModuleCentralityQuery: Literal["analyze-module-centrality"]
- CriticalFunctionsQuery: Literal["find-critical-functions"]
- CallComplexityQuery: Literal["analyze-call-complexity"]
- CircularDependenciesQuery: Literal["detect-circular-dependencies"]

Benefits:
- Type checker enforces exact string values
- IDE autocomplete shows valid query names
- Prevents accidental name modifications at runtime
- Better registry integrity (names are keys)

All 27 query tests passing.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Changed all 3 quality rule classes to use Literal types for their name field:
- TypeCoverageRule: Literal["type-coverage"]
- DocstringCoverageRule: Literal["docstring-coverage"]
- ParamComplexityRule: Literal["param-complexity"]

Benefits:
- Type checker enforces exact string values
- IDE autocomplete shows valid rule names
- Prevents accidental name modifications at runtime
- Better registry integrity (names are keys)
- Consistent with query system

All 85 quality tests passing.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@octo-youcef
octo-youcef marked this pull request as ready for review May 1, 2026 05:36
@octo-youcef
octo-youcef merged commit 8c54864 into main May 1, 2026
8 checks passed
@octo-youcef
octo-youcef deleted the feature/immutable-registry-keys branch May 1, 2026 05:36
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.

Make query and quality rule names immutable literals

2 participants