Optimize Python .cursorrules PEP 8 async await Dataclasses .cursorrules prompt file
About .cursorrules prompt file
What you can build
Code Quality Checker Tool: A tool that analyzes Python code for adherence to PEP 8, checks for consistent use of type hints, and evaluates code structure for modularity and reusability. It would also provide recommendations for implementing functional programming patterns and usage of async/await for asynchronous operations.
Python Async Playground: An interactive website that enables users to write and test Python code using async/await. It would demonstrate how to implement asynchronous operations effectively, with examples and exercises for learning.
Secure API Development Kit: A library focused on aiding Python developers to create secure APIs. It includes utilities for input validation, CORS setup, authentication, and tools to return meaningful error messages and appropriate HTTP status codes.
Dataclass and Pydantic Model Generator: A tool that generates Python dataclasses or Pydantic models from provided JSON schemas, ensuring correct implementation of data structures with features such as validation and serialization.
Naming Convention Analyzer: A tool that scans Python code to verify adherence to specified naming conventions, such as snake_case for function and variable names, and PascalCase for class names, ensuring consistency across the codebase.
Comprehensive Python Logging Toolkit: A toolkit that simplifies the implementation of proper logging practices in Python projects, guiding developers on best practices for using f-strings and log messages, and integrating error logging and monitoring.
Compact Commits CLI Tool: A command-line interface tool that aids developers in maintaining focused and small commit messages, enforcing guidelines for meaningful descriptions in version control systems.
DRY Principle Recommender: An application that analyzes Python codebases to identify repeated code patterns, recommending refactorizations to follow the DRY principle, thereby enhancing code maintainability and reducing redundancy.
Comprehension Enhancer Plugin: A plugin for Python IDEs that identifies opportunities for using list/dict/set comprehensions to improve code readability, providing suggestions directly within the development environment.
API Endpoint Documenter: A tool that automatically generates and maintains up-to-date documentation for Python-based API endpoints, supporting developers in keeping documentation current and aligned with code changes.
Benefits
- Emphasizes modern Python features like f-strings, async/await, and type hints, promoting clarity, performance, and maintainability.
- Encourages best practices with PEP 8 adherence, DRY principle, and specific naming conventions for readability and consistency.
- Advocates for structured version control and comprehensive documentation for smooth collaboration and project transparency.
Synopsis
Developers building Python applications with modern best practices will benefit from this prompt to create scalable, maintainable, and secure codebases.
Overview of .cursorrules prompt
The .cursorrules file outlines coding standards and best practices for Python development. It specifies the use of Python 3.8+ features and adherence to the PEP 8 style guide with a 120-character line length. The file emphasizes consistent use of type hints, functional programming patterns, and async/await for asynchronous tasks. It encourages writing modular, reusable code with f-strings for string formatting, list/dict/set comprehensions, and the use of dataclasses or Pydantic models. Naming conventions include snake_case for functions and variables, PascalCase for classes, and UPPER_CASE for constants. The file advises using specific exception types, implementing logging, returning meaningful error messages, and proper error logging and monitoring. It discusses the use of environment variables for configuration and security measures. Version control guidelines recommend meaningful commit messages, feature branches, pull requests, and small, focused commits. Documentation should include up-to-date README files, documented API endpoints, and current inline documentation.