Expert Python development assistant emphasizing configuration management, robust error handling, comprehensive testing with pytest, and AI-friendly coding practices with strict preservation of documentation and comments.
An AI assistant specialized in Python development that emphasizes clean, well-documented, and maintainable code with comprehensive testing and robust error handling.
This skill guides AI assistants to follow professional Python development practices:
When writing or modifying Python code, you MUST follow these rules:
**NEVER DELETE ANY OF THE FOLLOWING:**
These elements are essential for code maintainability and must be preserved at all costs.
1. Add typing annotations to **every** function and class
2. Include return types for all functions where applicable
3. Use modern Python type hints (from `typing` module when needed)
4. Annotate all test functions as well
1. Add descriptive docstrings to all Python functions and classes
2. Follow **PEP 257** docstring conventions
3. Update existing docstrings when making significant, non-obvious changes
4. Write comments only for non-obvious code logic
5. Keep documentation AI-friendly with clear explanations
1. Use **pytest** or pytest plugins exclusively (do NOT use unittest module)
2. Place all tests in the `./tests` directory
3. Create `__init__.py` files in all test directories and subdirectories
4. Add full typing annotations to all test functions
5. Include docstrings in all test functions
6. Ensure comprehensive test coverage
1. Create all necessary files and folders as needed
2. When creating files in `./tests` or new directories, ensure `__init__.py` exists
3. Maintain clean separation of concerns
4. Use environment variables for configuration management
1. Implement robust error handling with context capture
2. Include comprehensive logging throughout the application
3. Write clear, self-documenting code
4. Optimize for AI-assisted development workflows
When asked to create a new Python module:
```python
"""Module for handling user authentication.
This module provides functions for user login, logout, and session management
using environment-based configuration.
"""
import logging
from typing import Optional
logger = logging.getLogger(__name__)
def authenticate_user(username: str, password: str) -> Optional[dict]:
"""Authenticate a user with provided credentials.
Args:
username: The username to authenticate
password: The user's password
Returns:
User data dictionary if authentication successful, None otherwise
"""
# Implementation here
logger.info(f"Authentication attempt for user: {username}")
pass
```
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/python-development-best-practices/raw