mirror of
https://github.com/sanjeed5/awesome-cursor-rules-mdc.git
synced 2026-11-27 21:22:55 +08:00
rename folder
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
---
|
||||
description: Emphasizes the importance of prioritizing error handling and edge cases in Python code.
|
||||
globs: **/*.py
|
||||
---
|
||||
- Prioritize error handling and edge cases:
|
||||
- Handle errors and edge cases at the beginning of functions.
|
||||
- Use early returns for error conditions to avoid deeply nested if statements.
|
||||
- Place the happy path last in the function for improved readability.
|
||||
- Avoid unnecessary else statements; use the if-return pattern instead.
|
||||
- Use guard clauses to handle preconditions and invalid states early.
|
||||
- Implement proper error logging and user-friendly error messages.
|
||||
- Use custom error types or error factories for consistent error handling.
|
||||
@@ -0,0 +1,8 @@
|
||||
---
|
||||
description: Limits blocking operations in routes, favoring asynchronous and non-blocking flows.
|
||||
globs: **/routers/*.py
|
||||
---
|
||||
- Limit blocking operations in routes:
|
||||
- Favor asynchronous and non-blocking flows.
|
||||
- Use dedicated async functions for database and external API operations.
|
||||
- Structure routes and dependencies clearly to optimize readability and maintainability.
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
---
|
||||
description: Specifies the use of functional components and Pydantic models for input validation in FastAPI routes.
|
||||
globs: **/routers/*.py
|
||||
---
|
||||
- Use functional components (plain functions) and Pydantic models for input validation and response schemas.
|
||||
- Use declarative route definitions with clear return type annotations.
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
---
|
||||
description: Outlines the preferred style for conditional statements in Python files.
|
||||
globs: **/*.py
|
||||
---
|
||||
- Avoid unnecessary curly braces in conditional statements.
|
||||
- For single-line statements in conditionals, omit curly braces.
|
||||
- Use concise, one-line syntax for simple conditional statements (e.g., if condition: do_something()).
|
||||
@@ -0,0 +1,8 @@
|
||||
---
|
||||
description: Lists essential dependencies for FastAPI projects.
|
||||
globs: **/requirements.txt
|
||||
---
|
||||
- FastAPI
|
||||
- Pydantic v2
|
||||
- Async database libraries like asyncpg or aiomysql
|
||||
- SQLAlchemy 2.0 (if using ORM features)
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
---
|
||||
description: Emphasizes the reliance on FastAPI’s dependency injection system for managing state and shared resources.
|
||||
globs: **/dependencies/*.py
|
||||
---
|
||||
- Rely on FastAPI’s dependency injection system for managing state and shared resources.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
description: Defines the preferred file structure for FastAPI router modules.
|
||||
globs: **/routers/*.py
|
||||
---
|
||||
- File structure: exported router, sub-routes, utilities, static content, types (models, schemas).
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
---
|
||||
description: Specifies the use of 'def' and 'async def' for function definitions within FastAPI routers.
|
||||
globs: **/routers/*.py
|
||||
---
|
||||
- Use def for pure functions and async def for asynchronous operations.
|
||||
- Use type hints for all function signatures. Prefer Pydantic models over raw dictionaries for input validation.
|
||||
@@ -0,0 +1,8 @@
|
||||
---
|
||||
description: Specifies the use of middleware for logging, error monitoring, and performance optimization in FastAPI applications.
|
||||
globs: **/middleware/*.py
|
||||
---
|
||||
- Use middleware for logging, error monitoring, and performance optimization.
|
||||
- Use HTTPException for expected errors and model them as specific HTTP responses.
|
||||
- Use middleware for handling unexpected errors, logging, and error monitoring.
|
||||
- Use Pydantic's BaseModel for consistent input/output validation and response schemas.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
description: Prioritizes API performance metrics in FastAPI applications, focusing on response time, latency, and throughput.
|
||||
globs: **/*.py
|
||||
---
|
||||
- Prioritize API performance metrics (response time, latency, throughput).
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
---
|
||||
description: Outlines performance optimization techniques for FastAPI applications, including asynchronous operations and caching.
|
||||
globs: **/*.py
|
||||
---
|
||||
- Minimize blocking I/O operations; use asynchronous operations for all database calls and external API requests.
|
||||
- Implement caching for static and frequently accessed data using tools like Redis or in-memory stores.
|
||||
- Optimize data serialization and deserialization with Pydantic.
|
||||
- Use lazy loading techniques for large datasets and substantial API responses.
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
---
|
||||
description: Recommends minimizing the use of startup and shutdown events in favor of lifespan context managers.
|
||||
globs: **/main.py
|
||||
---
|
||||
- Minimize @app.on_event("startup") and @app.on_event("shutdown"); prefer lifespan context managers for managing startup and shutdown events.
|
||||
@@ -0,0 +1,11 @@
|
||||
---
|
||||
description: Applies general Python style guidelines including functional programming preferences and naming conventions.
|
||||
globs: **/*.py
|
||||
---
|
||||
- Write concise, technical responses with accurate Python examples.
|
||||
- Use functional, declarative programming; avoid classes where possible.
|
||||
- Prefer iteration and modularization over code duplication.
|
||||
- Use descriptive variable names with auxiliary verbs (e.g., is_active, has_permission).
|
||||
- Use lowercase with underscores for directories and files (e.g., routers/user_routes.py).
|
||||
- Favor named exports for routes and utility functions.
|
||||
- Use the Receive an Object, Return an Object (RORO) pattern.
|
||||
Reference in New Issue
Block a user