Repository navigation
Expand file tree
/
Copy pathruff.toml
More file actions
145 lines (138 loc) · 4.31 KB
/
Copy pathruff.toml
File metadata and controls
145 lines (138 loc) · 4.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# Ruff lint configuration.
#
# Lint rules are enabled incrementally. Only list explicit rule codes in
# `select` (never "ALL" or whole groups) so that new Ruff releases cannot
# silently enable new rules.
#
# Formatting is still handled by yapf (see run_tests.sh).
# Ruff only uses this to decide when to wrap imports (see [lint.isort] below);
# line length for code is enforced by yapf (80 columns). If E501 is enabled
# later, set its limit with `lint.pycodestyle.max-line-length` instead.
line-length = 1000
# Minimum Python version the code must run on. Ruff uses it to decide which
# syntax is valid (e.g. 3.12-only syntax is flagged as an error on older
# targets) and which version-specific rules/fixes apply.
#
# Python 3.12 is what CI (cloudbuild.py.yaml) and the import-automation
# executor/helper/validator Docker images use.
target-version = "py312"
extend-exclude = [
# Generated protobuf code.
"*_pb2.py",
# Local scratch outputs and virtual environments.
"**/scratch/**",
"**/.env/**",
# Jupyter notebooks (exploration only; also not checked by yapf).
"*.ipynb",
]
[per-file-target-version]
# import-automation/workflow/ is still built and tested on Python 3.11:
# - import-automation/workflow/cloudbuild.yaml builds the manifest catalog
# and py_compile's the workflow/DAG files on python:3.11-slim.
# - import-automation/cloudbuild.yaml runs import_automation_e2e.py and the
# DAG E2E test on Python 3.11 images.
# The Airflow DAGs here may also run on Cloud Composer, whose Python version
# is managed outside this repo.
# Keeping this at py311 makes Ruff flag 3.12-only syntax in these files.
# TODO: Remove this override once the builds above move to Python 3.12 and
# the Cloud Composer environment is confirmed to run Python 3.12+.
"import-automation/workflow/**" = "py311"
[lint]
select = [
# Syntax errors and invalid statements.
"E9",
"F63",
"F7",
# Undefined names.
"F821",
"F822",
"F823",
# Repeated keys in dict literals.
"F601",
# Invalid escape sequences in strings.
"W605",
# Comparisons to None/True/False, `not in`/`is not`, type comparisons.
"E711",
"E712",
"E713",
"E714",
"E721",
# Redefined-but-unused names and unused local variables.
"F811",
"F841",
# f-strings without placeholders.
"F541",
# Unused imports.
"F401",
# Import sorting (isort).
"I001",
# Star imports (`from x import *`) and names that may come from them.
"F403",
"F405",
# Multiple imports or statements on one line.
# Note: E402 (late imports after sys.path edits) is deferred until imports are
# made root-relative.
"E401",
"E701",
"E702",
"E703",
# Bare `except:`, which also catches KeyboardInterrupt and SystemExit.
"E722",
# Lambda assignments and ambiguous names (`l`, `O`, `I`).
"E731",
"E741",
"E742",
"E743",
# Import shadowing, late/undefined __future__ imports, nested star imports.
"F402",
"F404",
"F406",
"F407",
# Invalid `%`-format strings.
"F501",
"F502",
"F503",
"F504",
"F505",
"F506",
"F507",
"F508",
"F509",
# Invalid `.format()` strings.
"F521",
"F522",
"F523",
"F524",
"F525",
# Repeated dict variable keys, invalid starred unpacking, unused annotations,
# and `raise NotImplemented`.
"F602",
"F621",
"F622",
"F842",
"F901",
# Missing newline at end of file.
"W292",
# Directive, mock, string-concatenation, and deprecated-UTC guards.
"RUF100",
"PGH003",
"PGH004",
"PGH005",
"ISC001",
"DTZ003",
"DTZ004",
]
[lint.isort]
# Google Python style: one import per line, `import x` and `from x import y`
# sorted together by module name within each section.
force-single-line = true
force-sort-within-sections = true
single-line-exclusions = ["typing", "collections.abc"]
# Keep each import on a single line, even if it's long (the Google style guide
# exempts imports from the line limit). yapf never adds parentheses, so it
# leaves these lines alone; wrapping them would make Ruff and yapf disagree on
# where the closing parenthesis goes.
split-on-trailing-comma = false
[lint.pyflakes]
# Modules imported only for their side effect of defining absl flags.
allowed-unused-imports = ["common_flags", "config_flags"]