Skip to content

Productivity Actions

This category collects BetterPy features that streamline common editing and navigation workflows, helping you move faster through everyday Python tasks.


Generate Actions

Generate class actions

Since 2026.04.13 · Maturity Stable

Use BetterPy's Generate menu entries to scaffold common Python class shapes without leaving the editor. Each action inserts the class at the caret, adds any required imports, and selects the generated class name so you can rename it immediately.

Available generators

  • dataclass inserts a plain @dataclass.
  • frozen dataclass (kw_only) inserts @dataclass(frozen=True, kw_only=True).
  • pydantic model (with config) inserts a BaseModel plus an empty ConfigDict().

How it behaves

  • The action is available from Code | Generate in Python files.
  • When the caret is inside a class body, the generated class is inserted into that class with matching indentation.
  • When the file is missing imports such as dataclass, BaseModel, or ConfigDict, BetterPy adds them without duplicating existing imports.
  • After insertion, BetterPy selects the generated class name and starts inline rename.

Examples

from dataclasses import dataclass


@dataclass
class NewDataclass:
    pass
from dataclasses import dataclass


@dataclass(frozen=True, kw_only=True)
class NewFrozenDataclass:
    pass
from pydantic import BaseModel, ConfigDict


class NewModel(BaseModel):
    model_config = ConfigDict()
    pass

Placement rules

If the caret is between existing statements, BetterPy inserts the generated class at that position instead of always appending it to the end of the file. That makes it practical to scaffold nested helper classes exactly where you want them.