Rule
0 installs · 0 said it worked
Cursor rules guiding Python code with typed, documented, pytest-based tests
A Cursor rules file that makes the AI assistant write Python with typing annotations, PEP 257 docstrings, pytest-only tests placed under ./tests, and a clean project structure using uv, Ruff, and CI/CD.
People use this for
- cursor rules python typed code
- python pytest test writing rules
- pytest typed tests annotations
- python docstring pep 257 guidelines
- write python with type hints
- Name
cursor-rules-guiding-python-code-with-typed-documented-pytest-ba- Works with
- Cursor
- License
- CC0(as observed at the source)
- Version
- v1 · updated Nov 29, 2026
Imported on Nov 29, 2026 from github.com . License observed at the source on Nov 29, 2026: CC0.
Are you the author?Claim this profileRequest removal
Use this rule
$ curl -fsSL "https://promptcommunity.dev/api/v1/posts/cursor-rules-guiding-python-code-with-typed-documented-pytest-based-test-gp5v/export/mdc" -o .cursor/rules/cursor-rules-guiding-python-code-with-typed-documented-pytest-ba.mdcThen open a new session; Cursor picks it up from .cursor/rules/.
Manual install
Save cursor-rules-guiding-python-code-with-typed-documented-pytest-ba.mdc as .cursor/rules/cursor-rules-guiding-python-code-with-typed-documented-pytest-ba.mdc for this project or ~/.cursor/rules/cursor-rules-guiding-python-code-with-typed-documented-pytest-ba.mdc for every project, then start a new session.
Rule
description: "Cursor rules for Python development with best practices integration." globs: */ alwaysApply: false
You are an AI assistant specialized in Python development. Your approach emphasizes:
- Clear project structure with separate directories for source code, tests, docs, and config.
- Modular design with distinct files for models, services, controllers, and utilities.
- Configuration management using environment variables.
- Robust error handling and logging, including context capture.
- Comprehensive testing with pytest.
- Detailed documentation using docstrings and README files.
- Dependency management via https://github.com/astral-sh/uv and virtual environments.
- Code style consistency using Ruff.
- CI/CD implementation with GitHub Actions or GitLab CI.
AI-friendly coding practices:
- You provide code snippets and explanations tailored to these principles, optimizing for clarity and AI-assisted development.
Follow the following rules:
- For any Python file, ALWAYS add typing annotations to each function or class. Include explicit return types (including None where appropriate). Add descriptive docstrings to all Python functions and classes.
- Please follow PEP 257 docstring conventions. Update existing docstrings as needed.
- Make sure you keep any comments that exist in a file.
- When writing tests, ONLY use pytest or pytest plugins (not unittest). All tests should have typing annotations. Place all tests under ./tests. Create any necessary directories. If you create packages under ./tests or ./src/<package_name>, be sure to add an init.py if one does not exist.
All tests should be fully annotated and should contain docstrings. Be sure to import the following if TYPE_CHECKING: from _pytest.capture import CaptureFixture from _pytest.fixtures import FixtureRequest from _pytest.logging import LogCaptureFixture from _pytest.monkeypatch import MonkeyPatch from pytest_mock.plugin import MockerFixture
No result recorded yet. Added it? File a Tried-it report so the next person knows how it went in your editor.
Tried it
Reports from people who added this rule to their editor. They roll up into the badges above.
No one has filed a report yet. Try the prompt and be the first.
Related rules
- Python docstring coverage and drift checker for code review
A skill-style system prompt that makes the assistant measure Python docstring coverage via AST analysis, flag stale or missing docstrings, and plan a CI-gated documentation fix.
Coding · @f
- Claude api: reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming,…
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER — read BEFORE opening the target file; don't skip because it "looks like a one-liner" — whenever: the prompt names Claude/Anthropic in any fo
Coding · @anthropic
- Agent role that turns TypeScript typing work into a tracked TODO plan
A senior TypeScript type-expert role prompt covering type design, generics, narrowing, and migration, with a required output of TODO_ts-type-expert.md containing checkable task items.
Coding · @wkaandemir
- Cursor rules for writing and testing Xian smart contracts in Python
A Cursor rules file that guides the assistant through writing Xian blockchain smart contracts in Python, covering naming, state, context variables, events, error handling, and unittest-based testing with security checks.
Coding · @patrickjs
- Cursor rules enforcing clean, readable, maintainable code practices
A Cursor .mdc rule file that guides the assistant toward clean code: named constants, meaningful names, sparing comments, single-purpose functions, DRY, language style standards, extracted conditionals, continuous refactoring, and version control.
Coding · @patrickjs
License: CC0v1 · published Nov 29, 2026
Comments
No comments yet. If you tried this prompt, say how it went.