Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
bighardperson avatar

Python

  • 8 installs
  • 33 repo stars
  • Updated April 26, 2026
  • bighardperson/computer-science-skills-collection

Python is a skill that provides PEP 8 coding guidelines and idiomatic best practices for writing, reviewing, and refactoring Python.

About

Python is a coding-guidelines skill for writing, reviewing, and refactoring Python. It enforces PEP 8 style, syntax validation via py_compile, unit-test execution, modern non-EOL Python versions, uv for dependencies, and idiomatic Pythonic patterns. A developer references it while working on Python code and before committing.

  • Python coding guidelines enforcing PEP 8 and idiomatic patterns
  • Pre-commit checks: py_compile, pytest/unittest, ruff or black
  • Modern Python only: 3.10+, uv for dependency management

Python by the numbers

  • 8 all-time installs (skills.sh)
  • Ranked #214 of 290 Python skills by installs in the Skillselion catalog
  • Data as of Jul 30, 2026 (Skillselion catalog sync)
At a glance

python capabilities & compatibility

Capabilities
code review · refactoring · testing
Use cases
code review · refactoring · testing
IDEs
pycharm
From the docs

What python says it does

Python coding guidelines and best practices. Use when writing, reviewing, or refactoring Python code.
SKILL.md
**Minimum:** Python 3.10+ (3.9 EOL Oct 2025)
SKILL.md
npx skills add https://github.com/bighardperson/computer-science-skills-collection --skill python

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs8
repo stars33
Last updatedApril 26, 2026
Repositorybighardperson/computer-science-skills-collection

What it does

Apply PEP 8 style, pre-commit checks, and idiomatic patterns when writing or refactoring Python.

Who is it for?

Writing idiomatic, PEP 8-compliant Python with pre-commit validation

Skip if: Python 2 or EOL versions, which it explicitly forbids

When should I use this skill?

Writing, reviewing, or refactoring Python code

What you get

Idiomatic Python that passes py_compile, tests, and formatting before commit.

  • Python coding rules
  • pre-commit checklist

By the numbers

  • max line length 88 chars (Black) or 79 (PEP 8)
  • 8-item quick checklist

Files

SKILL.mdMarkdownGitHub ↗

Python Coding Guidelines

Code Style (PEP 8)

  • 4 spaces for indentation (never tabs)
  • Max line length: 88 chars (Black default) or 79 (strict PEP 8)
  • Two blank lines before top-level definitions, one within classes
  • Imports: stdlib → third-party → local, alphabetized within groups
  • Snake_case for functions/variables, PascalCase for classes, UPPER_CASE for constants

Before Committing

# Syntax check (always)
python -m py_compile *.py

# Run tests if present
python -m pytest tests/ -v 2>/dev/null || python -m unittest discover -v 2>/dev/null || echo "No tests found"

# Format check (if available)
ruff check . --fix 2>/dev/null || python -m black --check . 2>/dev/null

Python Version

  • Minimum: Python 3.10+ (3.9 EOL Oct 2025)
  • Target: Python 3.11-3.13 for new projects
  • Never use Python 2 syntax or patterns
  • Use modern features: match statements, walrus operator, type hints

Dependency Management

Check for uv first, fall back to pip:

# Prefer uv if available
if command -v uv &>/dev/null; then
    uv pip install <package>
    uv pip compile requirements.in -o requirements.txt
else
    pip install <package>
fi

For new projects with uv: uv init or uv venv && source .venv/bin/activate

Pythonic Patterns

# ✅ List/dict comprehensions over loops
squares = [x**2 for x in range(10)]
lookup = {item.id: item for item in items}

# ✅ Context managers for resources
with open("file.txt") as f:
    data = f.read()

# ✅ Unpacking
first, *rest = items
a, b = b, a  # swap

# ✅ EAFP over LBYL
try:
    value = d[key]
except KeyError:
    value = default

# ✅ f-strings for formatting
msg = f"Hello {name}, you have {count} items"

# ✅ Type hints
def process(items: list[str]) -> dict[str, int]:
    ...

# ✅ dataclasses/attrs for data containers
from dataclasses import dataclass

@dataclass
class User:
    name: str
    email: str
    active: bool = True

# ✅ pathlib over os.path
from pathlib import Path
config = Path.home() / ".config" / "app.json"

# ✅ enumerate, zip, itertools
for i, item in enumerate(items):
    ...
for a, b in zip(list1, list2, strict=True):
    ...

Anti-patterns to Avoid

# ❌ Mutable default arguments
def bad(items=[]):  # Bug: shared across calls
    ...
def good(items=None):
    items = items or []

# ❌ Bare except
try:
    ...
except:  # Catches SystemExit, KeyboardInterrupt
    ...
except Exception:  # Better
    ...

# ❌ Global state
# ❌ from module import * 
# ❌ String concatenation in loops (use join)
# ❌ == None (use `is None`)
# ❌ len(x) == 0 (use `not x`)

Testing

  • Use pytest (preferred) or unittest
  • Name test files test_*.py, test functions test_*
  • Aim for focused unit tests, mock external dependencies
  • Run before every commit: python -m pytest -v

Docstrings

def fetch_user(user_id: int, include_deleted: bool = False) -> User | None:
    """Fetch a user by ID from the database.
    
    Args:
        user_id: The unique user identifier.
        include_deleted: If True, include soft-deleted users.
    
    Returns:
        User object if found, None otherwise.
    
    Raises:
        DatabaseError: If connection fails.
    """

Quick Checklist

  • [ ] Syntax valid (py_compile)
  • [ ] Tests pass (pytest)
  • [ ] Type hints on public functions
  • [ ] No hardcoded secrets
  • [ ] f-strings, not .format() or %
  • [ ] pathlib for file paths
  • [ ] Context managers for I/O
  • [ ] No mutable default args

Related skills

FAQ

What Python version does the skill target?

Minimum 3.10+, targeting 3.11 to 3.13; never Python 2.

What checks should run before committing?

py_compile for syntax, pytest or unittest for tests, and ruff or black for formatting.

Pythonbackend

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.