Repository navigation
Expand file tree
/
Copy pathruff.toml
More file actions
140 lines (136 loc) · 6.73 KB
/
Copy pathruff.toml
File metadata and controls
140 lines (136 loc) · 6.73 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
# Every ruff rule applies, with no ratchet, apart from the ignores in [lint] and
# the per-file ignores below (sim.quality.ruff-lint). See
# docs/engineering/skills/rules-registry.md and rules/registry.toml.
# There is no root pyproject.toml, and ruff doesn't read the projects' own
# requires-python, so a file not listed here is linted with ruff's default
# target version, whatever its project requires. scripts/rules supports
# Python 3.11+ (and is shared byte-for-byte with policyengine-api, which
# targets 3.11). The executor requires Python 3.13.
per-file-target-version = { "scripts/**" = "py311", "projects/policyengine-simulation-executor/**" = "py313" }
# Directories that are not regular packages on purpose, so they have no
# __init__.py: standalone scripts, the implicit namespace package that holds
# scripts.rules, and proof fixtures. Ruff resolves modules as if each listed
# directory, and every directory under it, had an __init__.py. This is a
# top-level setting: ruff rejects it in [lint]. The executor's src/modal/utils
# scripts are not listed, because ruff would then treat them as part of a
# first-party "modal" package and regroup their Modal SDK imports; each keeps
# an inline INP001 suppression instead.
namespace-packages = [
".github/scripts",
"projects/policyengine-simulation-executor/scripts",
"rules/fixtures",
"scripts",
]
[lint]
select = ["ALL"]
ignore = [
# These conflict with ruff format; ruff's documentation says to disable
# them when using the formatter.
"COM812", "ISC001",
# Mutually exclusive pydocstyle pairs: keep D211 (no blank line before a
# class docstring) and D212 (summary on the first line).
"D203", "D213",
]
[lint.per-file-ignores]
# File-level exceptions are allowed only for tests, CI/CD scripts and
# command-line scripts; the rules guard rejects any other pattern. See
# docs/engineering/skills/rules-registry.md#file-level-exceptions.
#
# Tests may use pytest's bare assert, and need no docstrings, annotations or
# named constants for magic numbers. They may also reach into private members,
# live in directories that aren't packages, and import inside a test (often
# after patching the environment). They also run repository scripts and use
# fake credentials, temporary paths, naive datetimes, pickle and exec on
# purpose, may import the lazily loaded packages at module level, and may
# leave arguments unused in fakes and stubs that mirror a real signature.
# Every other rule applies to tests.
"**/tests/**" = [
"ANN", "ARG001", "ARG002", "ARG005", "D1", "DTZ001", "DTZ007", "INP001",
"PLC0415", "PLR2004", "S101", "S102", "S105", "S106", "S108", "S301",
"S603", "S607", "SLF001", "TID253",
]
# The deployed-service test suite (pytest, run against a live candidate) gets
# the same test exemptions.
"**/authenticated_tests/**" = [
"ANN", "ARG001", "ARG002", "ARG005", "D1", "DTZ001", "DTZ007", "INP001",
"PLC0415", "PLR2004", "S101", "S102", "S105", "S106", "S108", "S301",
"S603", "S607", "SLF001", "TID253",
]
# CI/CD scripts report on stdout.
".github/**" = ["T201"]
# Command-line scripts report on stdout, run other programs and use today's
# date.
"**/scripts/**" = ["DTZ011", "S603", "S607", "T201"]
# Programs under src: the Modal deployment utilities, and the OpenAPI and
# Stage 12 infrastructure commands. They report on stdout, and the release
# sentinel opens URLs from its arguments. The Modal utilities run with
# python -m from a directory that isn't a package.
"projects/*/src/{modal/utils/*,policyengine_simulation_entry/generate_openapi,policyengine_simulation_entry/stage12_infrastructure,policyengine_simulation_gateway/generate_openapi}.py" = ["INP001", "S310", "T201"]
# The shared rules tool needs only the standard library, so its tests use
# unittest on purpose; pytest-style rules don't apply to them.
"scripts/rules/tests/**" = ["PT"]
[lint.flake8-tidy-imports]
# Heavy or optional packages that load only inside the function that needs
# them, never at module level (TID253 enforces it; TYPE_CHECKING imports are
# fine). Ruff's PLC0415 accepts in-function imports of these without a
# suppression. A package belongs here only if no application module imports it
# at module level.
banned-module-level-imports = [
"google.cloud",
"google.oauth2",
"h5py",
"opentelemetry.exporter.cloud_monitoring",
"opentelemetry.exporter.cloud_trace",
"opentelemetry.instrumentation.logging",
"policyengine.bundle",
"policyengine.countries",
"policyengine.provenance",
"policyengine.tax_benefit_models",
"policyengine_simulation_executor.baseline_artifacts",
"policyengine_simulation_executor.spm",
"policyengine_uk",
"policyengine_us",
"pythonjsonlogger",
"spm_calculator",
]
[lint.flake8-type-checking]
# Classes whose annotations Pydantic evaluates at runtime, so their imports must
# stay at runtime. Ruff reads each base through the imports of the subclass's
# own module and follows inheritance only through classes in that module, never
# through a re-export, so a base is listed by the path its subclasses import it
# from: the defining module for project bases, the public path for third-party
# ones. See docs/engineering/skills/typing-only-imports.md; the
# sim.quality.runtime-evaluated-models-resolve tests check every model.
runtime-evaluated-base-classes = [
"policyengine.core.Simulation",
"policyengine_fastapi.observability.contracts.CorrelatedRunFields",
"policyengine_fastapi.observability.contracts.ObservabilityModel",
"policyengine_simulation_contract.gateway_models.GatewayRequestBase",
"policyengine_simulation_contract.macro_output.MacroOutputModel",
"policyengine_simulation_contract.macro_output.MacroRootModel",
"policyengine_simulation_contract.macro_output.SingleYearMacroOutput",
"policyengine_simulation_contract.stage12_bundle.StrictBundleModel",
"policyengine_simulation_contract.stage12_execution.SimulationExecutionInput",
"policyengine_simulation_contract.stage12_execution.StrictContractModel",
"policyengine_simulation_contract.stage12_manifest.StrictManifestModel",
"policyengine_simulation_executor.precompute_models._StrictModel",
"policyengine_simulation_executor.stage_reporting_simulation.StageReportingSimulation",
"pydantic.BaseModel",
"pydantic.RootModel",
"pydantic_settings.BaseSettings",
]
# FastAPI evaluates endpoint annotations when routes are registered.
runtime-evaluated-decorators = [
"fastapi.APIRouter.api_route",
"fastapi.APIRouter.delete",
"fastapi.APIRouter.get",
"fastapi.APIRouter.patch",
"fastapi.APIRouter.post",
"fastapi.APIRouter.put",
"fastapi.FastAPI.api_route",
"fastapi.FastAPI.delete",
"fastapi.FastAPI.get",
"fastapi.FastAPI.patch",
"fastapi.FastAPI.post",
"fastapi.FastAPI.put",
]