Skip to content

feat: auto-instantiate type-annotated Config subclasses - #9

Closed
brian14708 wants to merge 1 commit into
Randomizez:masterfrom
brian14708:develop
Closed

brian14708 wants to merge 1 commit into
Randomizez:masterfrom
brian14708:develop

Conversation

@brian14708

Copy link
Copy Markdown
Collaborator

Extends Config initialization to automatically instantiate subclasses declared via type annotations (e.g., sub: SubConfig), not just direct assignments (e.g., sub = SubConfig).

Type Safety Benefits:

  • 'sub = SubConfig' assigns the class itself, making type checkers infer type[SubConfig] (the class), breaking autocomplete and type checking
  • 'sub: SubConfig' declares an instance annotation, allowing type checkers to correctly infer SubConfig (an instance) for proper IDE support
  • This commit makes the type-safe pattern work at runtime

Extends Config initialization to automatically instantiate subclasses
declared via type annotations (e.g., sub: SubConfig), not just direct
assignments (e.g., sub = SubConfig).

Type Safety Benefits:
- 'sub = SubConfig' assigns the class itself, making type checkers infer
  type[SubConfig] (the class), breaking autocomplete and type checking
- 'sub: SubConfig' declares an instance annotation, allowing type checkers
  to correctly infer SubConfig (an instance) for proper IDE support
- This commit makes the type-safe pattern work at runtime
@brian14708 brian14708 closed this Mar 26, 2026
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