1+ # ################################################################################
2+ #
3+ # Ruff linter and code formatter for A2A
4+ #
5+ # This file follows the standards in Google Python Style Guide
6+ # https://google.github.io/styleguide/pyguide.html
7+ #
8+
9+ line-length = 80 # Google Style Guide §3.2: 80 columns
10+ indent-width = 4 # Google Style Guide §3.4: 4 spaces
11+
12+ target-version = " py310" # Minimum Python version
13+
14+ [lint ]
15+ ignore = [
16+ " I001" ,
17+ " COM812" ,
18+ " FBT001" ,
19+ " FBT002" ,
20+ " D203" ,
21+ " D213" ,
22+ " ANN001" ,
23+ " ANN201" ,
24+ " ANN204" ,
25+ " D100" , # Ignore Missing docstring in public module (often desired at top level __init__.py)
26+ " D102" , # Ignore return type annotation in public method
27+ " D104" , # Ignore Missing docstring in public package (often desired at top level __init__.py)
28+ " D107" , # Ignore Missing docstring in __init__ (use class docstring)
29+ " TD002" , # Ignore Missing author in TODOs (often not required)
30+ " TD003" , # Ignore Missing issue link in TODOs (often not required/available)
31+ " T201" , # Ignore print presence
32+ " RUF012" , # Ignore Mutable class attributes should be annotated with `typing.ClassVar`
33+ " RUF013" , # Ignore implicit optional
34+ ]
35+
36+ select = [
37+ " E" , # pycodestyle errors (PEP 8)
38+ " W" , # pycodestyle warnings (PEP 8)
39+ " F" , # Pyflakes (logical errors, unused imports/variables)
40+ " I" , # isort (import sorting - Google Style §3.1.2)
41+ " D" , # pydocstyle (docstring conventions - Google Style §3.8)
42+ " N" , # pep8-naming (naming conventions - Google Style §3.16)
43+ " UP" , # pyupgrade (use modern Python syntax)
44+ " ANN" ,# flake8-annotations (type hint usage/style - Google Style §2.22)
45+ " A" , # flake8-builtins (avoid shadowing builtins)
46+ " B" , # flake8-bugbear (potential logic errors & style issues - incl. mutable defaults B006, B008)
47+ " C4" , # flake8-comprehensions (unnecessary list/set/dict comprehensions)
48+ " ISC" ,# flake8-implicit-str-concat (disallow implicit string concatenation across lines)
49+ " T20" ,# flake8-print (discourage `print` - prefer logging)
50+ " SIM" ,# flake8-simplify (simplify code, e.g., `if cond: return True else: return False`)
51+ " PTH" ,# flake8-use-pathlib (use pathlib instead of os.path where possible)
52+ " PL" , # Pylint rules ported to Ruff (PLC, PLE, PLR, PLW)
53+ " PIE" ,# flake8-pie (misc code improvements, e.g., no-unnecessary-pass)
54+ " RUF" ,# Ruff-specific rules (e.g., RUF001-003 ambiguous unicode)
55+ " RET" ,# flake8-return (consistency in return statements)
56+ " SLF" ,# flake8-self (check for private member access via `self`)
57+ " TID" ,# flake8-tidy-imports (relative imports, banned imports - configure if needed)
58+ " YTT" ,# flake8-boolean-trap (checks for boolean positional arguments, truthiness tests - Google Style §3.10)
59+ " TD" , # flake8-todos (check TODO format - Google Style §3.7)
60+ ]
61+
62+ exclude = [
63+ " .bzr" ,
64+ " .direnv" ,
65+ " .eggs" ,
66+ " .git" ,
67+ " .hg" ,
68+ " .mypy_cache" ,
69+ " .nox" ,
70+ " .pants.d" ,
71+ " .pytype" ,
72+ " .ruff_cache" ,
73+ " .svn" ,
74+ " .tox" ,
75+ " .venv" ,
76+ " __pypackages__" ,
77+ " _build" ,
78+ " buck-out" ,
79+ " build" ,
80+ " dist" ,
81+ " node_modules" ,
82+ " venv" ,
83+ " */migrations/*" ,
84+ " test_*" ,
85+ ]
86+
87+ [lint .isort ]
88+ # force-sort-within-sections = true
89+ # combine-as-imports = true
90+ case-sensitive = true
91+ # force-single-line = false
92+ # known-first-party = []
93+ # known-third-party = []
94+ lines-after-imports = 2
95+ lines-between-types = 1
96+ # no-lines-before = ["LOCALFOLDER"]
97+ # required-imports = []
98+ # section-order = ["future", "standard-library", "third-party", "first-party", "local-folder"]
99+
100+ [lint .pydocstyle ]
101+ convention = " google"
102+
103+ [lint .flake8-annotations ]
104+ mypy-init-return = true
105+ allow-star-arg-any = true
106+
107+ [lint .pep8-naming ]
108+ ignore-names = [" test_*" , " setUp" , " tearDown" , " mock_*" ]
109+ classmethod-decorators = [" classmethod" , " pydantic.validator" , " pydantic.root_validator" ]
110+ staticmethod-decorators = [" staticmethod" ]
111+
112+ [lint .flake8-tidy-imports ]
113+ ban-relative-imports = " all" # Google generally prefers absolute imports (§3.1.2)
114+
115+ [lint .flake8-quotes ]
116+ docstring-quotes = " double"
117+ inline-quotes = " single"
118+
119+ [lint .per-file-ignores ]
120+ "__init__.py" = [" F401" ] # Ignore unused imports in __init__.py
121+ "*_test.py" = [" D" , " ANN" ] # Ignore docstring and annotation issues in test files
122+ "test_*.py" = [" D" , " ANN" ] # Ignore docstring and annotation issues in test files
123+ "types.py" = [" D" , " E501" , " N815" ] # Ignore docstring and annotation issues in types.py
124+
125+ [format ]
126+ docstring-code-format = true
127+ docstring-code-line-length = " dynamic" # Or set to 80
128+ quote-style = " single"
129+ indent-style = " space"
0 commit comments