Skip to main content

drep/languages/definitions/
python.rs

1//! The Python ecosystem: ruff over `.py`.
2
3use crate::languages::spec::{
4    DEFAULT_TOOL_TIMEOUT_SECS, DiagnosticsStream, LanguageSupport, OutputFormat, ToolSpec,
5};
6
7/// Python deterministic checker.
8pub static RUFF: ToolSpec = ToolSpec {
9    name: "ruff",
10    command: &["ruff", "check", "--output-format", "json"],
11    local_paths: &["venv/bin/ruff", ".venv/bin/ruff"],
12    config_files: &["pyproject.toml", "ruff.toml", ".ruff.toml"],
13    config_flag: None,
14    output_format: OutputFormat::Json,
15    diagnostics_stream: DiagnosticsStream::Stdout,
16    timeout_secs: DEFAULT_TOOL_TIMEOUT_SECS,
17    timeout_context: None,
18    establishes_compilation: false,
19    serial_in_repository: false,
20    accepts_files: true,
21};
22
23/// Python language entry.
24pub static PYTHON: LanguageSupport = LanguageSupport {
25    name: "python",
26    display_name: "Python",
27    extensions: &[".py"],
28    filenames: &[],
29    filename_prefixes: &[],
30    tools: &[&RUFF],
31    conventions: &[
32        "Follows PEP 8 naming and structure",
33        "Type hints on public APIs, and correct use of Optional/None",
34        "Context managers for resources rather than manual cleanup",
35        "Mutable default arguments, and late-binding closures in loops",
36    ],
37    vendored_dirs: &["__pycache__", "venv", ".venv", "env", ".tox", ".eggs"],
38};
39
40/// The family's entries in registration order. See `ALL_LANGUAGES`.
41pub(crate) static FAMILY: &[&LanguageSupport] = &[&PYTHON];