pydantic-basesettings-class-attributes
CommunityAvoid non-annotated attributes in Pydantic.
Authordragonkid
Version1.0.0
Installs0
System Documentation
What problem does it solve?
In Pydantic BaseSettings and BaseModel subclasses, class attributes without type annotations are treated as model fields, causing non-annotated attribute errors. Resolve this by moving constants outside the class as module-level constants or by using ClassVar annotations.
Core Features & Use Cases
- Avoid model-field leakage by relocating constants to module scope.
- Use ClassVar to explicitly mark non-field attributes in Pydantic models.
- Facilitate safer refactoring of hard-coded mappings and configurations.
Quick Start
Refactor a BaseSettings subclass by extracting constants to module scope (e.g., _APOLLO_MAPPING) and, where appropriate, annotate with ClassVar; then run a quick validation to ensure the model loads without errors.
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: pydantic-basesettings-class-attributes Download link: https://github.com/dragonkid/dotfiles/archive/main.zip#pydantic-basesettings-class-attributes Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 223,000+ vetted skills library on demand.