Skip to content
Skills Library
Programming · Building & coding

python-expert

/python-expert

Expert-level Python development with Python 3.12+ features, async/await, type hints, and modern best practices. Use when the user mentions Python 3, async, type hints, FastAPI, or Django, or when the task involves modern Python, async programming, type hints, or web frameworks.

Repository
pcl ↗
Licence
Apache-2.0
Last repository change
10.09.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
2
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 10.09.2026, without references to retired models or APIs.

Licence

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

What it does and when to use it

Expert-level Python development with Python 3.12+ features, async/await, type hints, and modern best practices. Use when the user mentions Python 3, async, type hints, FastAPI, or Django, or when the task involves modern Python, async programming, type hints, or web frameworks.

Original author description

Expert-level Python development with Python 3.12+ features, async/await, type hints, and modern best practices. Use when the user mentions Python 3, async, type hints, FastAPI, or Django, or when the task involves modern Python, async programming, type hints, or web frameworks.

How it works

  1. Best Practices
  2. Common Patterns
  3. Anti-Patterns to Avoid
  4. Development Workflow
  5. Approach
  6. Reference Documentation
Original SKILL.md headings · 347 lines, 913 words
SKILL.md preview
---
name: python-expert
version: 1.1.0
description: >-
  Expert-level Python development with Python 3.12+ features, async/await, type hints, and
  modern best practices. Use when the user mentions Python 3, async, type hints, FastAPI,
  or Django, or when the task involves modern Python, async programming, type hints, or web
  frameworks.
category: languages
author: PCL Team
license: Apache-2.0
tags:
  - python
  - python3
  - async
  - type-hints
  - fastapi
  - django
allowed-tools:
  - Read
  - Write
  - Edit
  - Bash(python:*, python3:*, pip:*, pip3:*, uv:*, poetry:*, ruff:*, pytest:*)
  - Glob
  - Grep
requirements:
  python: '>=3.10'
---

# Python Expert

You are an expert Python developer with deep knowledge of modern Python (3.12+), async programming, type hints, and the Python ecosystem. You write clean, performant, and Pythonic code following PEP 8 and industry best practices.

## Best Practices

### 1. Follow PEP 8

```python
# Good naming
class UserRepository:  # PascalCase for classes
    MAX_RETRIES = 3  # UPPER_CASE for constants

    def get_active_users(self):  # snake_case for functions/methods
        active_users = []  # snake_case for variables
        return active_users

# Proper spacing
def calculate_total(items: list[int]) -> int:
    total = 0

    for item in items:
        total += item

    return total

# List comprehensions for simple transformations
numbers = [1, 2, 3, 4, 5]
squared = [n ** 2 for n in numbers]
evens = [n for n in numbers if n % 2 == 0]
```

### 2. Use Context Managers

```python
# File handling
with open('file.txt') as f:
    content = f.read()

# Database connections
with database.connection() as conn:
    conn.execute(query)

# Custom context managers
from contextlib import contextmanager

@contextmanager
def timer(name: str):
    start = time.time()
    try:
        yield
    finally:
        print(f"{name} took {time.time() - start:.2f}s")

# Usage
with timer("Database query"):
    results = db.query("SELECT * FROM users")
```

### 3. List/Dict Comprehensions

```python
# List comprehension
squares = [x**2 for x in range(10) if x % 2 == 0]

# Dict comprehension
word_lengths = {word: len(word) for word in words}

# Set comprehension
unique_lengths = {len(word) for word in words}

# Generator expression (memory efficient)
sum_of_squares = sum(x**2 for x in range(1_000_000))
```

### 4. Use Enums

```python
from enum import Enum, auto

class UserRole(Enum):
    ADMIN = auto()
    USER = auto()
    GUEST = auto()

class Status(str, Enum):
    PENDING = "pending"
    APPROVED = "approved"
    REJECTED = "rejected"

# Usage
def check_permission(role: UserRole) -> bool:
    return role == UserRole.ADMIN
```

### 5. Proper Exception Handling

```python
# Specific exceptions
try:
    user = get_user(id)
except UserNotFoundError:
    # Handle missing user
    user = create_default_user()
except DatabaseError as e:
    # Handle database errors
    logger.error(f"Database error: {e}")
    raise
except Exception as e:
    # Catch-all (use sparingly)
    logger.exception("Unexpected error")
    raise

# Custom exceptions
class ValidationError(Exception):
    """Raised when validation fails"""
    pass

class ResourceNotFoundError(Exception):
    """Raised when a resource is not found"""
    def __init__(self, resource: str, id: int):
        self.resource = resource
        self.id = id
        super().__init__(f"{resource} with id {id} not found")
```

### 6. Use Type Hints

```python
from typing import Optional, Union, Any
from collections.abc import Sequence, Mapping

def process_users(
    users: Sequence[User],
    filters: Optional[Mapping[str, Any]] = None
) -> list[User]:
    if filters is None:
        filters = {}

    return [u for u in users if matches_filters(u, filters)]

# Return types
def get_user(id: int) -> User | None:
    return users.get(id)

# Callable types
from collections.abc import Callable

def apply_function(
    items: list[int],
    func: Callable[[int], int]
) -> list[int]:
    return [func(item) for item in items]
```

### 7. Use Decorators

```python
import functools
import time

# Caching
@functools.lru_cache(maxsize=128)
def expensive_computation(n: int) -> int:
    return sum(i**2 for i in range(n))

# Timing
def timer(func):
    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        start = time.time()
        result = func(*args, **kwargs)
        print(f"{func.__name__} took {time.time() - start:.2f}s")
        return result
    return wrapper

@timer
def slow_function():
    time.sleep(1)

# Validation
def validate_positive(func):
    @functools.wraps(func)
    def wrapper(n: int):
        if n <= 0:
            raise ValueError("Number must be positive")
        return func(n)
    return wrapper

@validate_positive
def process_number(n: int) -> int:
    return n ** 2
```

## Common Patterns

### Singleton

```python
class Singleton:
    _instance = None

    def __new__(cls):
        if cls._instance is None:
            cls._instance = super().__new__(cls)
        return cls._instance
```

### Factory

```python
class UserFactory:
    @staticmethod
    def create(role: str) -> User:
        if role == "admin":
            return AdminUser()
        elif role == "guest":
            return GuestUser()
        else:
            return RegularUser()
```

### Observer

```python
class Observable:
    def __init__(self):
        self._observers: list[Callable] = []

    def subscribe(self, observer: Callable) -> None:
        self._observers.append(observer)

    def unsubscribe(self, observer: Callable) -> None:
        self._observers.remove(observer)

    def notify(self, data: Any) -> None:
        for observer in self._observers:
            observer(data)
```

## Anti-Patterns to Avoid

### 1. Mutable Default Arguments

```python
# Bad
def append_to(item, list=[]):
    list.append(item)
    return list

# Good
def append_to(item, list=None):
    if list is None:
        list = []
    list.append(item)
    return list
```

### 2. Catching Exception Too Broadly

```python
# Bad
try:
    result = risky_operation()
except:
    pass

# Good
try:
    result = risky_operation()
except ValueError as e:
    logger.error(f"Value error: {e}")
    raise
```

### 3. Not Using with for Files

```python
# Bad
f = open('file.txt')
content = f.read()
f.close()

# Good
with open('file.txt') as f:
    content = f.read()
```

## Development Workflow

### Modern Package Managers

```bash
# uv (fastest)
uv venv
uv pip install fastapi
uv run python app.py

# Poetry
poetry init
poetry add fastapi
poetry run python app.py

# pip (traditional)
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
```

### Code Quality Tools

```bash
# Ruff (fast linter + formatter)
ruff check .
ruff format .

# MyPy (type checking)
mypy src/

# Pytest
pytest
pytest --cov=src tests/
pytest -v -s
```

## Approach

When writing Python code:

1. **Use Type Hints**: Make code self-documenting and catch errors early
2. **Follow PEP 8**: Consistent style improves readability
3. **Write Tests**: Pytest with good coverage (>80%)
4. **Handle Errors Properly**: Specific exceptions, proper error messages
5. **Use Modern Python**: Take advantage of 3.10+ features
6. **Leverage Async**: For I/O-bound operations
7. **Document Code**: Docstrings for public APIs
8. **Keep It Pythonic**: Use language idioms and features

Always write clean, readable, and Pythonic code that leverages modern Python features and follows community best practices.

## Reference Documentation

Detailed material lives alongside this skill and is read on demand:

- [Core Expertise](references/CORE_CONCEPTS.md) — Modern Python (3.12+), Async Programming, Web Frameworks, Testing
Files in this package (2)
  • SKILL.md 8 KB
  • references/CORE_CONCEPTS.md 12 KB

Versions

RepositoryScoreLicence
This page · personamanagmentlayer/pcl100Apache-2.0
jggomez/expert-ai-developer-skills100Apache-2.0
traylinx/switchAILocal100Apache-2.0
personamanagmentlayer/pcl100Apache-2.0
miaoge-ge/coding-agent-skills100MIT
wesleyegberto/software-engineering-skills90MIT

Database snapshot: 13.11.2026 · package version fbe80d772bee (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100python-development
    Professional Python development skill covering modern Python 3.10+, FastAPI, Django, Flask, async programming, data processing, and best practices. Use this skill when developing Python web applications, building FastAPI/Django projects, implementing async programming, or need…
  • 100python-development
    Professional Python development skill covering modern Python 3.10+, FastAPI, Django, Flask, async programming, data processing, and best practices. Use this skill when developing Python web applications, building FastAPI/Django projects, implementing async programming, or need…
  • 100python
    Python language (3.10-3.14). Covers typing, async, and modern patterns. Use when writing Python applications. USE WHEN: user mentions "python", "type hints", "dataclasses", "async/await", asks about "asyncio", "context managers", "match statement", "walrus operator", "PEP 695",…
  • 100fastapi-expert
    Expert-level FastAPI development for high-performance Python APIs with async support. Use when the user mentions Python, API, async, REST, OpenAPI, or Pydantic, or when the task involves FastAPI Features.
  • 95developing-with-python
    Python 3.11+ development with type hints, async patterns, FastAPI, and pytest. Use for backend services, CLI tools, data processing, and API development.
  • 100fastapi
    FastAPI modern Python web framework. Covers routing, Pydantic models, dependency injection, and async support. Use when building Python APIs. USE WHEN: user mentions "fastapi", "pydantic", "async python api", "python rest api", asks about "dependency injection python", "python…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.