Repository navigation
Expand file tree
/
Copy pathpyproject.toml
More file actions
182 lines (163 loc) · 5.92 KB
/
Copy pathpyproject.toml
File metadata and controls
182 lines (163 loc) · 5.92 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
[project]
name = "cloud-resource-cleanup"
version = "0.1.0"
description = "Delete and stop leftover cloud resources across AWS, Azure, GCP and OCI."
readme = "README.md"
requires-python = ">=3.12"
license = { file = "LICENSE.md" }
[tool.pytest.ini_options]
pythonpath = ["."]
testpaths = ["tests"]
# ---------------------------------------------------------------------------
# LEGACY RATCHET: this list may only shrink. It names, file by file, the
# modules that existed before the refactor and are therefore exempt from ruff
# and mypy. Any file not listed (new code under crc/core, crc/notify, new
# tests) is checked. Each rung removes the modules it refactors, in the same
# change that refactors them. Never add an entry and never use a directory or
# glob. The mypy override below must list the same modules.
# ---------------------------------------------------------------------------
[tool.ruff]
target-version = "py312"
line-length = 100
extend-exclude = []
[tool.ruff.format]
exclude = ["*.md"]
[tool.ruff.lint]
select = [
"E", "F", "W", "I", "B", "UP", "FURB", "SIM", "PERF", "C901", "PLR", "RUF",
"DTZ", "BLE", "G", "LOG", "C4", "RET", "N",
]
# LOG015: the code and the frozen oracles log through the root logger, and the parity tests
# compare logger names; module loggers would change the records.
ignore = ["LOG015"]
[tool.ruff.lint.per-file-ignores]
# N802/N803: these names mirror boto3 keyword arguments and resource attributes (`Filters=`,
# `VpcId=`, `DhcpOptions`); renaming them would break the SDK call.
"crc/aws/*/client.py" = ["N802", "N803"]
# Test fakes that reproduce the same boto3 / frozen oracle signatures.
"tests/helpers_cl2_aws.py" = ["N802"]
"tests/helpers_cl2_azu.py" = ["N802"]
"tests/helpers_cl2_crc.py" = ["N802"]
"tests/helpers_cl2_gcp_oracle.py" = ["N802"]
"tests/helpers_gcp_bridge.py" = ["N802"]
"tests/test_aws_disk_cleaner.py" = ["N803"]
"tests/test_aws_disk_engine.py" = ["N803"]
"tests/test_aws_disk_fix.py" = ["N803"]
"tests/test_aws_disk_parity.py" = ["N803"]
"tests/test_aws_elastic_ips_fix.py" = ["N803"]
"tests/test_aws_elastic_ips.py" = ["N803"]
"tests/test_aws_ip_parity.py" = ["N803"]
"tests/test_aws_keypair_parity.py" = ["N803"]
"tests/test_aws_keypairs.py" = ["N803"]
"tests/test_aws_kms_fix.py" = ["N803"]
"tests/test_aws_kms_parity.py" = ["N803"]
"tests/test_aws_kms.py" = ["N803"]
"tests/test_aws_misc_logger.py" = ["N803"]
"tests/test_aws_snapshot_fix.py" = ["N803"]
"tests/test_aws_snapshot_parity.py" = ["N803"]
"tests/test_aws_snapshot.py" = ["N803"]
"tests/test_aws_spot_instance_requests_engine.py" = ["N803"]
"tests/test_aws_spot_instance_requests_parity.py" = ["N803"]
"tests/test_aws_vm_parity.py" = ["N803"]
"tests/test_aws_vm.py" = ["N803"]
"tests/test_aws_vpc_fix.py" = ["N803"]
"tests/test_aws_vpc_parity.py" = ["N802", "N803"]
"tests/test_core_engine.py" = ["N802"]
"tests/test_gcp_base_parity.py" = ["N802"]
"tests/test_gcp_disk_parity.py" = ["N802"]
"tests/test_gcp_vm_parity.py" = ["N802"]
"tests/test_own1_saf_gaps.py" = ["N803"]
# Hash-locked safety tests (tests/archtest/safety_lock.json): not editable, so ruff skips the rule.
"tests/test_aws_vpc.py" = ["DTZ001"]
"tests/test_core_age.py" = ["DTZ001"]
"tests/test_core_age_fix.py" = ["DTZ001"]
"tests/test_cli_logger.py" = ["C420"]
"tests/test_gcp_spot_vm_engine.py" = ["C408"]
[tool.ruff.lint.mccabe]
max-complexity = 10
[tool.ruff.lint.pylint]
max-statements = 40
max-args = 6
[tool.mypy]
python_version = "3.12"
strict = true
# `mypy` with no arguments checks these paths. crc.py is not listed: as a top-level module it
# is also named `crc` and clashes with the crc/ package. tests/test_crc_entry_types.py
# type-checks a copy of it under another module name with the same strict settings.
files = ["crc", "tests", "scripts"]
# LEGACY RATCHET: this list may only shrink. It is empty now; keep it in sync with ruff
# `extend-exclude` above (crc.py is not listed here: tests/test_crc_entry_types.py checks it).
# SDKs without stubs or py.typed: only the SDK, never a repository module.
[[tool.mypy.overrides]]
module = ["boto3", "boto3.*", "botocore", "botocore.*"]
ignore_missing_imports = true
[[tool.mypy.overrides]]
module = ["oci", "oci.*"]
ignore_missing_imports = true
[[tool.mypy.overrides]]
module = ["googleapiclient", "googleapiclient.*"]
ignore_missing_imports = true
# Cloud SDK namespace packages whose typing differs between releases: the gate must not depend
# on the resolved version (constraints.txt pins one, these overrides make mypy indifferent to a
# release that ships no stubs or no `py.typed`). `follow_imports = "skip"` is not used: it would
# turn the SDK types into `Any` and make the existing `type: ignore` comments unused.
[[tool.mypy.overrides]]
module = [
"google",
"google.*",
"azure",
"azure.*",
"msrestazure",
"msrestazure.*",
"msrest",
"msrest.*",
]
ignore_missing_imports = true
[tool.importlinter]
root_package = "crc"
include_external_packages = true
[[tool.importlinter.contracts]]
name = "Cloud packages are independent"
type = "independence"
modules = ["crc.aws", "crc.azu", "crc.gcp", "crc.oci"]
[[tool.importlinter.contracts]]
name = "Core never imports cloud packages or services"
type = "forbidden"
source_modules = ["crc.core"]
forbidden_modules = [
"crc.aws",
"crc.azu",
"crc.gcp",
"crc.oci",
"crc.notifications",
"crc.service",
]
[[tool.importlinter.contracts]]
name = "Core never imports cloud or telemetry SDKs"
type = "forbidden"
source_modules = ["crc.core"]
forbidden_modules = [
"boto3",
"botocore",
"azure",
"google",
"oci",
"slack_sdk",
"influxdb_client",
]
[[tool.importlinter.contracts]]
name = "Notify never imports cloud packages or services"
type = "forbidden"
source_modules = ["crc.notify"]
forbidden_modules = [
"crc.aws",
"crc.azu",
"crc.gcp",
"crc.oci",
"crc.service",
]
[[tool.importlinter.contracts]]
name = "Core never imports notify"
type = "forbidden"
source_modules = ["crc.core"]
forbidden_modules = ["crc.notify"]