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