Python Cursor Rules
Best Cursor AI coding rules for Python development. Enforce type hints, PEP 8, Pythonic patterns, and modern Python best practices in your .cursorrules file.
- Always use type hints for all function parameters and return types - Prefer dataclasses or Pydantic models over plain dicts for structured data - Use pathlib.Path over os.path for file system operations - Raise specific, descriptive exceptions rather than generic Exception - Use f-strings for string formatting (not % or .format()) - Follow PEP 8: max line length 88 (Black default), snake_case naming - Use context managers (with) for all resource management - Prefer list/dict/set comprehensions over loops where readable
How to use with Cursor
Create a `.cursorrules` file in your project root and paste these rules. Cursor reads this automatically on every AI interaction.
Related Rules
TypeScript Cursor Rules
Cursor rules for TypeScript: enforce strict mode, eliminate any types, and write type-safe code with these .cursorrules configurations.
React Cursor Rules
Cursor rules for React: component patterns, hooks best practices, performance optimization, and clean state management conventions.
Next.js Cursor Rules
Cursor rules for Next.js App Router: server components, data fetching, routing, and deployment best practices.
Rust Cursor Rules
Cursor rules for Rust: ownership patterns, error handling with Result, idiomatic Rust, and performance-aware coding conventions.