Python module
A blueprint that creates a Python module folder with __init__.py, the module itself and a pytest test. Python module names are written in snake_case, so the file names use {name.snake}.
Config
Section titled “Config”module.exports = { blueprints: [ { title: "Python module", variables: [{ key: "name", prompt: "Module name" }], snippets: { init: `from .{name.snake} import {name.pascal}
__all__ = ["{name.pascal}"]`, module: `"""{name.raw}."""
class {name.pascal}: """{name.raw}."""
def __init__(self) -> None: pass`, test: `from .{name.snake} import {name.pascal}
def test_{name.snake}_can_be_created(): assert {name.pascal}() is not None`, }, structure: { folders: [ { name: "{name.snake}", files: [ { name: "__init__.py", snippet: "init" }, { name: "{name.snake}.py", snippet: "module" }, { name: "test_{name.snake}.py", snippet: "test" }, ], }, ], }, }, ],};-
Right-click the folder where the module should live (for example
src) and choose Run Blueprintor…. -
Select Python module.
-
Enter
my idea. The same folder would be created formy-idea,my_ideaorMyIdea.
Result
Section titled “Result”Directorysrc
Directorymy_idea
- __init__.py
- my_idea.py
- test_my_idea.py
from .my_idea import MyIdea
__all__ = ["MyIdea"]"""my idea."""
class MyIdea: """my idea."""
def __init__(self) -> None: passfrom .my_idea import MyIdea
def test_my_idea_can_be_created(): assert MyIdea() is not NoneThe three forms are used for different jobs: {name.snake} for module and file names, {name.pascal} for the class, {name.raw} for the human-readable text in docstrings.