type-checking
Type Checking with Pyright/Basedpyright
Use pyright or basedpyright for gradual type checking adoption.
Core Principles
- Minimize Logic Changes: Type checking should NOT change runtime behavior
- Test After Changes: Always run tests after adding type hints
- Hunt Down Root Causes: Never use
# type: ignoreas first resort
Quick Start
When fixing type errors:
# 1. Run type checker
pyright <file-or-directory>
# or
basedpyright <file-or-directory>
# 2. Fix errors (see patterns.md for common fixes)
# 3. Verify no behavior changes
git diff main
pytest tests/
Fix Priority Order
- Add proper type annotations (Optional, specific types)
- Fix decorator return types
- Use
cast()for runtime-compatible but statically unverifiable types - Last resort:
# type: ignoreonly for legitimate cases
Common Quick Fixes
Field Defaults
# Use keyword syntax
role: Role = Field(default=Role.MEMBER, description="...")
# Positional default - avoid
role: Role = Field(Role.MEMBER, description="...")
Optional Parameters
# Correct
def my_function(channel_id: Optional[str] = None):
# Wrong
def my_function(channel_id: str = None):
Weak Types - NEVER Use
# NEVER
items: list[Any]
data: dict
result: Any
# ALWAYS use specific types
items: list[DataItem]
data: dict[str, ProcessedResult]
result: SpecificType | OtherType
Prefer cast() Over type: ignore
from typing import cast
# Preferred
typed_results = cast(list[ResultProtocol], results)
selected = select_by_score(typed_results)
# Less clear
selected = select_by_score(results) # type: ignore[arg-type]
When to Use type: ignore
Only for:
- Function attributes:
func._attr = val # type: ignore[attr-defined] - Dynamic/runtime attributes not in type system
- External library quirks (protobuf, webhooks)
- Legacy patterns requiring significant refactoring
DO NOT use for simple fixes (add Optional, fix return types, add imports).
Reference Files
For detailed patterns and procedures:
- references/patterns.md - Common Pydantic + Pyright patterns with examples
- references/expanding-coverage.md - How to add new modules to type checking
Remember: Always verify changes with git diff main before committing.
More from gigaverse-app/skillet
metaskill-authoring
Write Claude Code skills and SKILL.md files. Use when creating new skills, writing skill content, structuring SKILL.md, organizing skill directories, or when user mentions "write skill", "create skill", "author skill", "new skill", "skill structure", "SKILL.md", "skill content", "skill template".
9metaskill-triggering
Optimize skill triggers and descriptions for reliable activation. Use when skill is not triggering, optimizing trigger keywords, writing frontmatter, debugging activation, or when user mentions "trigger", "frontmatter", "description", "skill not triggering", "optimize trigger", "skill won't fire", "skill activation", "trigger keywords".
8metaskill-packaging
Package skills, agents, commands, and hooks as Claude Code plugins. Use when creating plugins, packaging skills for distribution, setting up plugin structure, dogfooding plugins, or when user mentions "plugin structure", "plugin.json", "package plugin", "distribute plugin", "marketplace", "dogfood", "install plugin", "plugin placement", "--plugin-dir".
8metaskill-naming
Brainstorm and validate names for plugins, skills, agents, and commands. Use when naming a new plugin, choosing atom names, validating naming conventions, or when user mentions "name plugin", "name skill", "naming convention", "brainstorm names", "what should I call", "plugin name", "good name for".
7metaskill-grouping
Create skill groups (multiple related skills packaged as a plugin). Use when creating plugins, organizing multiple related skills, building skill families, packaging tools together, or when user mentions "plugin", "multiple skills", "related skills", "skill group", "skill family", "organize skills", "cross-reference", "package skills", "shared agents". ALWAYS consider this pattern when someone asks to "create a skill" - they often need a skill GROUP packaged as a plugin.
7nicegui-development
Use when building UI with NiceGUI, creating components, fixing styling issues, or when user mentions "nicegui", "quasar", "tailwind", "ui.row", "ui.column", "gap spacing", "state management", "controller", "dialog", "modal", "ui component", "ui layout".
6