Productivity Actions¶
This category collects BetterPy features that streamline common editing and navigation workflows, helping you move faster through everyday Python tasks.
Copy Actions¶
Copy with imports¶
Copy with imports copies the selected Python code and prepends the import statements that are referenced inside that selection.
How to use it¶
Select Python code, then run Edit | Copy Special | Copy with Imports.
Notes¶
- The selected text is copied as-is, with only trailing whitespace trimmed.
- Import statements already inside the selection are not duplicated.
- The feature is gated by the Copy with imports setting under Settings | BetterPy | Productivity Actions | Copying.
Generate Actions¶
Generate class actions¶
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¶
dataclassinserts a plain@dataclass.frozen dataclass (kw_only)inserts@dataclass(frozen=True, kw_only=True).pydantic model (with config)inserts aBaseModelplus an emptyConfigDict().
How it behaves¶
- The action is available from
Code | Generate(⌘N / Alt+Insert) 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, orConfigDict, BetterPy adds them without duplicating existing imports. - After insertion, BetterPy selects the generated class name and starts inline rename.
Examples¶
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.
Documentation Enhancements¶
Attribute Docstring in Quick Documentation¶
Show attribute docstrings directly in Quick Documentation when a class attribute is followed by a string literal. This brings Python's attribute-docstring convention into the standard documentation popup instead of leaving it hidden in the class body.
How to invoke¶
Place the caret on a class attribute and open Quick Documentation with F1 / Ctrl+Q or the usual editor documentation action.
If the next statement after the attribute is a string literal, BetterPy returns that text as the attribute's quick documentation.
Example¶
Quick Documentation for title shows:
What it supports¶
- Regular class attributes.
- Dataclass fields.
- TypedDict fields.
- Pydantic-style model fields.
- Whitespace between the attribute declaration and the docstring literal.
What it deliberately avoids¶
- Local variables and other non-class assignments.
- Attributes without an immediately following string literal.
- Non-string statements after the attribute declaration.
Notes¶
- The feature is gated by the Attribute Docstring in Quick Documentation setting under Settings | BetterPy | Productivity Actions | Documentation and is enabled by default.
- BetterPy also reuses the same attribute-docstring lookup from the enhanced dataclass quick info feature, so both views stay consistent.
Docstring Example Rendering¶
Renders doctests and fenced Python examples in Quick Documentation for Python docstrings, so runnable examples are easier to scan and copy.
How to invoke: F1 / Ctrl+Q on a documented function, class, or module.
Notes¶
- Doctest prompts and fenced Python blocks are rendered as Python code blocks.
- The rendered example includes a copy link that copies only executable input for doctest snippets.
- The feature is gated by the Docstring Example Rendering setting under Settings | BetterPy | Productivity Actions | Documentation.
Anonymous usage analytics (PostHog)¶
BetterPy can send anonymous usage analytics to PostHog when the IDE allows usage statistics. The data helps prioritize feature work and catch broad product issues without collecting code, file paths, project names, or personal data.
What is collected¶
- BetterPy plugin version.
- IDE type and version.
- Operating system and JVM version.
- A random anonymous installation id.
- Coarse feature-usage events, such as a feature id and action id.
What is not collected¶
- Source code or snippets.
- File paths, project names, package names, or symbol names.
- Personal information.
How to control it¶
Analytics are automatically disabled when the IDE's usage statistics setting is off. You can also disable the feature from Settings | BetterPy | Privacy | Anonymous usage analytics (PostHog).
When the setting is turned off from BetterPy settings, the plugin sends a final anonymous opt-out event so opt-out rates can be measured.