Skip to content

TsukiNi22/ai-utils / skills/python/python-project

python-project

Verified

Set up a new Python project in Tsukini's way - a script, an application in the layout of his MAGIC project (src/main.py + app.py + const.py, Class/, tool/, data/, requirements.txt) or an installable package (src layout, __init__.py with the version and the public API, __main__.py, const.py with frozen dataclasses, exception.py with error codes, main() returning the exit code, pyproject.toml with a console command, pytest tests) - generated by scripts/new_project.py with the Xartania headers, then README / license / CI / git with the other skills. Use whenever the user wants to create, bootstrap or scaffold a Python project, package, tool or script project.

templates/common/const.py

View on GitHub
{{HEADER:const.py:Constants of the project}}

##### Import #####
# Import that can't be in the try
from sys import exit, stderr

# Import that can be checked
try:
    from dataclasses import dataclass
    from typing import ClassVar
except ImportError as e:
    stderr.write(f"Import Error ({__file__}): {e}\n")
    exit(255) # Special exit code (only place used)

##### Const #####
VERSION = "{{VERSION}}" # Version of the project, single source (a literal: read by the packaging without import)

@dataclass(frozen=True)
class Return():
    """
        Return values
    """
    OK: int = 0 # Return value upon success on a call function
    KO: int = 1 # Return value upon fail on a call function

@dataclass(frozen=True)
class Error():
    """
        Error values
    """
    FATAL: int  = 0b1000    # Global error, the whole execution stops                  (100% execution stop)
    LOCAL: int  = 0b100     # Local error, the local execution probably can't go on   (some chance of execution stop)
    ACTION: int = 0b10      # Same~~ as Return.KO, an action of the program fails      (low chance of execution stop)

@dataclass(frozen=True)
class Values:
    """
        Different values without a precise category
    """
    NAME: str = "{{NAME}}" # Name of the project
    VERSION: str = VERSION # Version of the project
    DEFAULTS: ClassVar[dict[str, str]] = {} # Default settings

@dataclass(frozen=True)
class Files:
    """
        Different files path
    """
    DATA: str = "data/" # Data folder of the project

##### Declaration #####
RETURN  = Return()
ERROR   = Error()
VALUES  = Values()
FILES   = Files()
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 319kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 319kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 319kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 196kUpdated Claude CodeCodexVerifiedInstall