Files
scylladb/.github/instructions/python.instructions.md
Piotr Szymaniak 378bcd69e3 tree: add AGENTS.md router and improve AI instruction files
Add AGENTS.md as a minimal router that directs AI agents to the
relevant instruction files based on what they are editing.

Improve the instruction files:

- cpp.instructions.md: clarify seastarx.hh scope (headers, not
  "many files"), explain std::atomic restriction (single-shard
  model, not "blocking"), scope macros prohibition to new ad-hoc
  only, add coroutine exception propagation pattern, add invariant
  checking section preferring throwing_assert() over SCYLLA_ASSERT
  (issue #7871)
- python.instructions.md: demote PEP 8 to fallback after local
  style, clarify that only wildcard imports are prohibited
- copilot-instructions.md: show configure.py defaults to dev mode,
  add frozen toolchain section, clarify --no-gather-metrics applies
  to test.py, fix Python test paths to use .py extension, add
  license header guidance for new files

Closes scylladb/scylladb#29023
2026-04-19 21:59:52 +03:00

1.4 KiB

applyTo
applyTo
**/*.py

Python Guidelines

Important: Match existing code style. Some directories (like test/cqlpy and test/alternator) prefer simplicity over type hints and docstrings.

Style

  • Match style of the file and directory you are editing; fall back to PEP 8 if unclear
  • Use type hints for function signatures (unless directory style omits them)
  • Use f-strings for formatting
  • Line length: 160 characters max
  • 4 spaces for indentation

Imports

Order: standard library, third-party, local imports

import os
import sys

import pytest
from cassandra.cluster import Cluster

from test.utils import setup_keyspace

Avoid wildcard imports (from module import *).

Documentation

All public functions/classes need docstrings (unless the current directory conventions omit them):

def my_function(arg1: str, arg2: int) -> bool:
    """
    Brief summary of function purpose.

    Args:
        arg1: Description of first argument.
        arg2: Description of second argument.

    Returns:
        Description of return value.
    """
    pass

Testing Best Practices

  • Maintain bisectability: all tests must pass in every commit
  • Mark currently-failing tests with @pytest.mark.xfail, unmark when fixed
  • Use descriptive names that convey intent
  • Docstrings/comments should explain what the test verifies and why, and if it reproduces a specific issue or how it fits into the larger test suite