Skip to content

Commit 2623f31

Browse files
authored
chore: Upgrade Ruff to 0.3.0 (#20249)
## Summary & Motivation Upgrades ruff to 0.3.0. Main change is ellipses now are formatted on a single line: astral-sh/ruff#5822 ## How I Tested These Changes bk
1 parent 06d4c19 commit 2623f31

File tree

329 files changed

+1055
-1784
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

329 files changed

+1055
-1784
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/charliermarsh/ruff-pre-commit
3-
rev: v0.2.0
3+
rev: v0.3.0
44
hooks:
55
- id: ruff
66
args: [--fix, --exit-non-zero-on-fix]

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ unannotated_pyright:
2525
python scripts/run-pyright.py --unannotated
2626

2727
ruff:
28-
-ruff --fix .
28+
-ruff check --fix .
2929
ruff format .
3030

3131
check_ruff:

docs/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
docs_ruff:
2-
-ruff --fix ../examples/docs_snippets
2+
-ruff check --fix ../examples/docs_snippets
33
ruff format ../examples/docs_snippets
44

55
apidoc-build:

docs/content/concepts/assets/asset-auto-execution.mdx

+11-22
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,11 @@ from dagster import AutoMaterializePolicy, asset
3939

4040

4141
@asset
42-
def asset1():
43-
...
42+
def asset1(): ...
4443

4544

4645
@asset(auto_materialize_policy=AutoMaterializePolicy.eager(), deps=[asset1])
47-
def asset2():
48-
...
46+
def asset2(): ...
4947
```
5048

5149
This example assumes that `asset1` will be materialized in some other way - e.g. manually, via a [sensor](/concepts/partitions-schedules-sensors/sensors), or via a [schedule](/concepts/partitions-schedules-sensors/schedules).
@@ -64,13 +62,11 @@ from dagster import (
6462

6563

6664
@asset
67-
def asset1():
68-
...
65+
def asset1(): ...
6966

7067

7168
@asset(deps=[asset1])
72-
def asset2():
73-
...
69+
def asset2(): ...
7470

7571

7672
defs = Definitions(
@@ -101,8 +97,7 @@ wait_for_all_parents_policy = AutoMaterializePolicy.eager().with_rules(
10197

10298

10399
@asset(auto_materialize_policy=wait_for_all_parents_policy)
104-
def asset1(upstream1, upstream2):
105-
...
100+
def asset1(upstream1, upstream2): ...
106101
```
107102

108103
#### Auto-materialize even if some parents are missing
@@ -118,8 +113,7 @@ allow_missing_parents_policy = AutoMaterializePolicy.eager().without_rules(
118113

119114

120115
@asset(auto_materialize_policy=allow_missing_parents_policy)
121-
def asset1(upstream1, upstream2):
122-
...
116+
def asset1(upstream1, upstream2): ...
123117
```
124118

125119
#### Auto-materialize root assets on a regular cadence
@@ -136,8 +130,7 @@ materialize_on_cron_policy = AutoMaterializePolicy.eager().with_rules(
136130

137131

138132
@asset(auto_materialize_policy=materialize_on_cron_policy)
139-
def root_asset():
140-
...
133+
def root_asset(): ...
141134
```
142135

143136
### Auto-materialization and partitions
@@ -152,17 +145,15 @@ from dagster import AutoMaterializePolicy, DailyPartitionsDefinition, asset
152145
partitions_def=DailyPartitionsDefinition(start_date="2020-10-10"),
153146
auto_materialize_policy=AutoMaterializePolicy.eager(),
154147
)
155-
def asset1():
156-
...
148+
def asset1(): ...
157149

158150

159151
@asset(
160152
partitions_def=DailyPartitionsDefinition(start_date="2020-10-10"),
161153
auto_materialize_policy=AutoMaterializePolicy.eager(),
162154
deps=[asset1],
163155
)
164-
def asset2():
165-
...
156+
def asset2(): ...
166157
```
167158

168159
If the last partition of `asset1` is re-materialized, e.g. manually from the UI, then the corresponding partition of `asset2` will be auto-materialized after.
@@ -181,8 +172,7 @@ from dagster import AutoMaterializePolicy, DailyPartitionsDefinition, asset
181172
max_materializations_per_minute=7
182173
),
183174
)
184-
def asset1():
185-
...
175+
def asset1(): ...
186176
```
187177

188178
For time-partitioned assets, the `N` most recent partitions will be selected from the set of candidates to be materialized. For other types of partitioned assets, the selection will be random.
@@ -208,6 +198,5 @@ def source_file():
208198
deps=[source_file],
209199
auto_materialize_policy=AutoMaterializePolicy.eager(),
210200
)
211-
def asset1():
212-
...
201+
def asset1(): ...
213202
```

docs/content/concepts/assets/asset-checks.mdx

+6-12
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ from dagster import (
113113

114114

115115
@asset
116-
def my_asset():
117-
...
116+
def my_asset(): ...
118117

119118

120119
@asset_check(asset=my_asset)
@@ -184,13 +183,11 @@ from dagster import (
184183

185184

186185
@asset
187-
def orders():
188-
...
186+
def orders(): ...
189187

190188

191189
@asset
192-
def items():
193-
...
190+
def items(): ...
194191

195192

196193
def make_check(check_blob: Mapping[str, str]) -> AssetChecksDefinition:
@@ -250,18 +247,15 @@ from dagster import (
250247

251248

252249
@asset
253-
def my_asset():
254-
...
250+
def my_asset(): ...
255251

256252

257253
@asset_check(asset=my_asset)
258-
def check_1():
259-
...
254+
def check_1(): ...
260255

261256

262257
@asset_check(asset=my_asset)
263-
def check_2():
264-
...
258+
def check_2(): ...
265259

266260

267261
# includes my_asset and both checks

docs/content/concepts/configuration/advanced-config-types.mdx

+2-4
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ class MyDataStructuresConfig(Config):
124124
user_scores: Dict[str, int]
125125

126126
@asset
127-
def scoreboard(config: MyDataStructuresConfig):
128-
...
127+
def scoreboard(config: MyDataStructuresConfig): ...
129128

130129
result = materialize(
131130
[scoreboard],
@@ -161,8 +160,7 @@ class MyNestedConfig(Config):
161160
user_data: Dict[str, UserData]
162161

163162
@asset
164-
def average_age(config: MyNestedConfig):
165-
...
163+
def average_age(config: MyNestedConfig): ...
166164

167165
result = materialize(
168166
[average_age],

docs/content/concepts/io-management/io-managers.mdx

+1-2
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,7 @@ class ExternalIOManager(IOManager):
405405
# setup stateful cache
406406
self._cache = {}
407407

408-
def handle_output(self, context: OutputContext, obj):
409-
...
408+
def handle_output(self, context: OutputContext, obj): ...
410409

411410
def load_input(self, context: InputContext):
412411
if context.asset_key in self._cache:

docs/content/concepts/logging/loggers.mdx

+1-2
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,7 @@ from dagster import Definitions, define_asset_job, asset
203203
204204
205205
@asset
206-
def some_asset():
207-
...
206+
def some_asset(): ...
208207
209208
210209
the_job = define_asset_job("the_job", selection="*")

docs/content/concepts/ops-jobs-graphs/graphs.mdx

+2-4
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,11 @@ from dagster import asset, job, op
272272

273273

274274
@asset
275-
def emails_to_send():
276-
...
275+
def emails_to_send(): ...
277276

278277

279278
@op
280-
def send_emails(emails) -> None:
281-
...
279+
def send_emails(emails) -> None: ...
282280

283281

284282
@job

docs/content/concepts/ops-jobs-graphs/job-execution.mdx

+1-2
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,7 @@ For example, the following job will execute at most two ops at once with the `da
220220
}
221221
}
222222
)
223-
def tag_concurrency_job():
224-
...
223+
def tag_concurrency_job(): ...
225224
```
226225

227226
**Note:** These limits are only applied on a per-run basis. You can apply op concurrency limits across multiple runs using the <PyObject module="dagster_celery" object="celery_executor" /> or <PyObject module="dagster_celery_k8s" object="celery_k8s_job_executor" />.

docs/content/concepts/ops-jobs-graphs/op-jobs.mdx

+2-4
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ from dagster import graph, op, ConfigurableResource
8787

8888

8989
class Server(ConfigurableResource):
90-
def ping_server(self):
91-
...
90+
def ping_server(self): ...
9291

9392

9493
@op
@@ -222,8 +221,7 @@ from dagster import Definitions, job
222221

223222

224223
@job
225-
def do_it_all():
226-
...
224+
def do_it_all(): ...
227225

228226

229227
defs = Definitions(jobs=[do_it_all])

docs/content/concepts/partitions-schedules-sensors/partitioning-assets.mdx

+7-14
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ images_partitions_def = DynamicPartitionsDefinition(name="images")
156156

157157

158158
@asset(partitions_def=images_partitions_def)
159-
def images(context: AssetExecutionContext):
160-
...
159+
def images(context: AssetExecutionContext): ...
161160
```
162161

163162
Partition keys can be added and removed for a given dynamic partition set. For example, the following code snippet demonstrates the usage of a [sensor](/concepts/partitions-schedules-sensors/sensors) to detect the presence of a new partition and then trigger a run for that partition:
@@ -256,8 +255,7 @@ partitions_def = DailyPartitionsDefinition(start_date="2023-01-21")
256255

257256

258257
@asset(partitions_def=partitions_def)
259-
def events():
260-
...
258+
def events(): ...
261259

262260

263261
@asset(
@@ -271,8 +269,7 @@ def events():
271269
)
272270
],
273271
)
274-
def yesterday_event_stats():
275-
...
272+
def yesterday_event_stats(): ...
276273
```
277274

278275
</TabItem>
@@ -296,8 +293,7 @@ partitions_def = DailyPartitionsDefinition(start_date="2023-01-21")
296293

297294

298295
@asset(partitions_def=partitions_def)
299-
def events():
300-
...
296+
def events(): ...
301297

302298

303299
@asset(
@@ -310,8 +306,7 @@ def events():
310306
)
311307
},
312308
)
313-
def yesterday_event_stats(events):
314-
...
309+
def yesterday_event_stats(events): ...
315310
```
316311

317312
</TabItem>
@@ -340,13 +335,11 @@ hourly_partitions_def = HourlyPartitionsDefinition(start_date="2022-05-31-00:00"
340335

341336

342337
@asset(partitions_def=hourly_partitions_def)
343-
def asset1():
344-
...
338+
def asset1(): ...
345339

346340

347341
@asset(partitions_def=hourly_partitions_def)
348-
def asset2():
349-
...
342+
def asset2(): ...
350343

351344

352345
partitioned_asset_job = define_asset_job(

docs/content/concepts/partitions-schedules-sensors/partitioning-ops.mdx

+1-2
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,7 @@ from dagster import build_schedule_from_partitioned_job, job
164164

165165

166166
@job(config=my_partitioned_config)
167-
def do_stuff_partitioned():
168-
...
167+
def do_stuff_partitioned(): ...
169168

170169

171170
do_stuff_partitioned_schedule = build_schedule_from_partitioned_job(

docs/content/concepts/partitions-schedules-sensors/schedules.mdx

+4-8
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ Here's a simple schedule that runs a job every day, at midnight:
4545

4646
```python file=concepts/partitions_schedules_sensors/schedules/schedules.py startafter=start_basic_schedule endbefore=end_basic_schedule
4747
@job
48-
def my_job():
49-
...
48+
def my_job(): ...
5049

5150

5251
basic_schedule = ScheduleDefinition(job=my_job, cron_schedule="0 0 * * *")
@@ -109,8 +108,7 @@ from dagster import build_schedule_from_partitioned_job, job
109108

110109

111110
@job(config=my_partitioned_config)
112-
def do_stuff_partitioned():
113-
...
111+
def do_stuff_partitioned(): ...
114112

115113

116114
do_stuff_partitioned_schedule = build_schedule_from_partitioned_job(
@@ -130,8 +128,7 @@ from dagster import (
130128

131129

132130
@asset(partitions_def=HourlyPartitionsDefinition(start_date="2020-01-01-00:00"))
133-
def hourly_asset():
134-
...
131+
def hourly_asset(): ...
135132

136133

137134
partitioned_asset_job = define_asset_job("partitioned_job", selection=[hourly_asset])
@@ -264,8 +261,7 @@ class DateFormatter(ConfigurableResource):
264261
return dt.strftime(self.format)
265262

266263
@job
267-
def process_data():
268-
...
264+
def process_data(): ...
269265

270266
@schedule(job=process_data, cron_schedule="* * * * *")
271267
def process_data_schedule(

docs/content/concepts/partitions-schedules-sensors/sensors.mdx

+2-4
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ Once a sensor is added to a <PyObject object="Definitions" /> object with the jo
9797

9898
```python file=concepts/partitions_schedules_sensors/sensors/sensors.py startafter=start_running_in_code endbefore=end_running_in_code
9999
@sensor(job=asset_job, default_status=DefaultSensorStatus.RUNNING)
100-
def my_running_sensor():
101-
...
100+
def my_running_sensor(): ...
102101
```
103102

104103
If you manually start or stop a sensor in the UI, that will override any default status that is set in code.
@@ -250,8 +249,7 @@ class UsersAPI(ConfigurableResource):
250249
return requests.get(self.url).json()
251250

252251
@job
253-
def process_user():
254-
...
252+
def process_user(): ...
255253

256254
@sensor(job=process_user)
257255
def process_new_users_sensor(

0 commit comments

Comments
 (0)