1 python rules available
One Copilot rule matches python: a best-practices rule focused on type hints. Copilot's inline suggestions follow the surrounding file closely, so the file stresses version-appropriate typing and the project's configured tools.
GitHub Copilot reads repository-wide custom instructions from .github/copilot-instructions.md and path-specific instructions from .github/instructions/*.instructions.md files with an applyTo glob. Copilot can also use AGENTS.md files, where the nearest file in the directory tree takes precedence. Which file types are honored depends on the surface: VS Code, Visual Studio, JetBrains, Xcode, Eclipse and GitHub.com differ.
.github/instructions/python.instructions.mdStarting point, not a tested configuration for your repository. Used for files matching applyTo on surfaces that support path-specific instructions. Review the instructions, adapt the file paths and run your project's existing checks.
--- applyTo: "**/*.py" --- # Python instructions for GitHub Copilot ## Focus for this project - Match the type-hint syntax to requires-python: Optional[X] on 3.9, X | None on 3.10+, unless the module uses from __future__ import annotations. - Suggest pytest tests with plain assert statements and fixtures, not unittest classes, unless the file already uses unittest. - Prefer pathlib.Path over os.path for new file-handling code. ## Python conventions - Read requires-python in pyproject.toml first. Use built-in generics such as list[str] (3.9+) and X | None unions (3.10+) only when the minimum version allows them at runtime. - Annotate public functions and keep Any out of new signatures. - Raise specific exception types and never use a bare except:. - Use the formatter, linter and type checker already configured in pyproject.toml instead of introducing new ones. ## Before you finish - Run the configured linter and type checker (for example ruff check . and mypy) and pytest -q and report the actual output. If you cannot run them, say so and list the exact commands instead of saying they pass. - Summarize which of the rules above affected the change. - When reviewing a pull request, comment only where a change breaks one of these instructions and quote the instruction.
Create your own GitHub Copilot rules for Python and share with the community.
Ask for a small change to one matching file. Check the tool's loaded context or instruction view, inspect the diff for the requested convention, and run the relevant build or test. A well-formatted file does not guarantee the model follows every instruction.
Instruction support differs by surface: VS Code supports repository-wide, path-specific and AGENTS.md instructions; Visual Studio supports repository-wide and path-specific; JetBrains and Xcode use .github/copilot-instructions.md. GitHub's documentation describes AGENTS.md files stored anywhere in the repository, with the nearest file in the directory tree taking precedence, or alternatively a single CLAUDE.md or GEMINI.md in the root. Support differs by surface; GitHub's IDE page lists AGENTS.md among the instruction types for VS Code.
Documentation checked 2026-11-05: GitHub Docs: Adding repository custom instructionsGitHub Docs: Repository instructions in your IDE
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
You want Copilot completions in a Python 3.9 codebase to stop suggesting X | None annotations that fail at runtime on that version.
Ask Copilot Chat: write a function that loads settings from a TOML path and returns a typed dict.
A typed function using pathlib and tomllib (3.11+) or the project's TOML library on older versions, annotations valid for requires-python, and a pytest test.
Content reviewed 2026-11-05. Confirm instruction activation in your installed client before relying on it.