AI Agent Hub
Back to skills
💻

Python Programming Guidelines

Development Updated 2026.08.30

Paste the following prompt into your AI chat to install this skill:

Please install @user_f12a44b7/self-dev-python according to https://skillhub.cn/install/skillhub.md.

About this skill

Problem

Python code can run locally but still drift in style, dependencies, language version, and test coverage after review. This skill turns Python coding guidelines into concrete checks instead of linking to PEP 8 alone.

How It Works

It organizes the work around a pre-commit loop: validate syntax with py_compile, run focused pytest tests, and prefer Python 3.10+ features such as match statements, the walrus operator, and type hints. Dependency handling checks for uv first and falls back to pip, with project isolation through a virtual environment. Style rules cover 4-space indentation, snake_case functions and variables, PascalCase classes, UPPER_CASE constants, and import ordering by stdlib, third-party, and local groups. Common patterns include docstrings, pathlib, context managers, and f-strings.

Boundaries

The guidance is best for new projects and shared repositories where Python 3.10+ is supported. It does not replace architecture, performance tuning, or security audits; teams that require strict PEP 8 line length of 79 should treat the 88-character default as a Black-style convention.

Use Cases

  • Set import order, naming, and indentation for a new Python repository to match PEP 8.
  • Before a PR, verify Python 3.10+ features, type hints, and focused pytest unit tests.
  • Choose a uv or pip virtual environment for data scripts and handle I/O with pathlib and context managers.
  • Run py_compile and pytest before commit to catch hardcoded secrets and mutable default arguments.

Best For

  • Engineers maintaining Python utility libraries who need consistent naming, imports, and testing.
  • Backend developers reviewing LLM-generated code against PEP 8 and Python 3.10+ features.
  • Engineers maintaining data pipelines who want standards for dependencies, I/O, type hints, and pre-commit checks.
  • Open-source contributors who need a checklist for pytest, docstrings, and anti-patterns before review.