python
Python best practices and project structure, for Flask and SQLite projects.
- Kind
- Rules
- Works with
- Cursor
- Languages
- Python, SQL
- Source
- Awesome Cursor Rules @ b044f956f021
- Path
- rules/python.mdc
- License
- CC0-1.0
- Jobs
- Implementation
InstallCopy it from the source repository, or sign in and let the assistant adapt it for your project.
# Python Best Practices ## Project Structure - Use src-layout with `src/your_package_name/` - Place tests in `tests/` directory parallel to `src/` - Keep configuration in `config/` or as environment variables - Store requirements in `requirements.txt` or `pyproject.toml` - Place static files in `static/` directory - Use `templates/` for Jinja2 templates ## Code Style - Follow Black code formatting - Use isort for import sorting - Follow PEP 8 naming conventions: - snake_case for functions and variables - PascalCase for classes - UPPER_CASE for constants - Maximum line length of 88 characters (Black default) - Use absolute imports over relative imports ## Type Hints - Use type hints for all function parameters and returns - Import types from `typing` module - Use `Optional[Type]` instead of `Type | None` - Use `TypeVar` for generic types - Define custom types in `types.py` - Use `Protocol` for duck typing ## Flask Structure - Use Flask factory pattern - Organize routes using Blueprints - Use Flask-SQLAlchemy for database - Implement proper error handlers - Use Flask-Login for authentication - Structure views with proper separation of concerns ## Database …