Skip to content

Commit d5e6340

Browse files
smackeseyDagster Devtools
authored andcommitted
chore(ruff): bump ruff to 0.16.2 and clear surfaced lint (#26359)
## Summary & Motivation Bumps `ruff` from `0.15.15` to `0.16.2` and clears the lint/format diff the new version surfaces. This is a bigger bump than usual because 0.16.0 made two significant default-behavior changes: the default lint rule set expanded from 59 to 413 rules, and the formatter now formats Python code blocks in Markdown files. ## Pin sites and lockfiles All six pin sites updated: root `pyproject.toml`, `dagster-oss/python_modules/dagster/pyproject.toml` (×2: `test` and `ruff` extras), `python_modules/purina/pyproject.toml`, `public/skills/dagster-skills-evals/pyproject.toml`, and `required-version` in `dagster-oss/config/ruff.toml`. Beyond the usual two lockfiles (root `uv.lock` via `just rebuild_uv_lock_file`, dagster's via `update_lockfiles.py`), seven more dagster-oss lockfiles pinned the old ruff through their path dependency on dagster's extras and were relocked with `update_lockfiles.py`: `docs`, `examples/docs_snippets`, `examples/with_great_expectations`, `examples/assets_pandas_type_metadata`, `examples/docs_projects/project_components_pdf_extraction`, `libraries/dagster-ge`, and `libraries/dagster-dg-cli`. These would otherwise fail lockfile-staleness checks in CI. ## Lint changes `just ruff` at 0.16.2 found 178 diagnostics; 108 auto-fixed at default safety and 48 more with `--unsafe-fixes`. The autofix diff is dominated by RUF036 (`None` moved to the end of unions, newly stabilized) plus assorted comprehension cleanups, stale-`noqa` removals, and typing modernization. One explanatory comment dropped by the union-reordering fix in `dagster_shared/serdes/serdes.py` was restored by hand. Hand fixes for the non-autofixable residue: - **UP035** in `_core/types/{config_schema,dagster_type,decorator}.py`: replaced deprecated `typing.AbstractSet` with `collections.abc.Set as AbstractSet` (existing repo convention) and `typing.Type` with builtin `type`. - **B020/PLR1704** in `_core/types/python_dict.py`: renamed a loop variable that shadowed the `value` argument it iterates. - **DTZ005** in `project_multi_tenant` schedules and the `databricks-delta` lakehouse component: `datetime.now()` → `datetime.now(timezone.utc)` (demo-data timestamps and schedule-tag fallbacks are now tz-aware). Config-level ignores where the newly-defaulted rules are wrong for the context: - `project_dspy`: `BLE001` (example code deliberately catches broad exceptions when scoring LLM output) and `RUF012` (same class-attribute false-positive class the shared config ignores globally). These files are embedded in docs via snippet markers, so `noqa` comments would leak into rendered docs. - `dagster-skills-evals`: `PLR0917` (too-many-positional-arguments, newly stabilized) alongside the existing `PLR0913` ignore — typer CLI commands legitimately take many parameters. - `project_multi_tenant`: `UP017` — the project targets py311 so ruff wants `datetime.UTC`, but the ty master env type-checks examples at Python 3.10 (dagster's minimum) where that symbol doesn't exist. ## Markdown formatting 102 `.md` files had their Python code fences reformatted (~1,700 lines) by the new default Markdown formatting. Kept rather than excluded via `format.exclude`: CI's `ruff format --check` enforces it, and the repo precedent (0.15.0 bump) was to adopt new formatter defaults wholesale. Spot-checked the largest diffs (`MIGRATION.md`, `CHANGES.md`, docs guides) — all benign style normalization inside valid-Python fences. ## Test Plan - [x] `just ruff` clean (`All checks passed!`, formatter no-op on second run). - [x] `just ty` clean (`Found 0 errors / Found 0 warnings`, 7257 files) across all three ty environments — confirms the unsafe-fix import deletions and the `typing.AbstractSet`/`typing.Type` replacements don't break annotation resolution. - [x] `rg` confirms no lockfile anywhere still references `ruff==0.15.15`. Internal-RevId: 56253058f2358df14a7a0ea4345dbf4eca23f75c
1 parent 4ced10d commit d5e6340

116 files changed

Lines changed: 869 additions & 830 deletions

File tree

Some content is hidden

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

.claude/coding_conventions.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ from contextlib import contextmanager
3939
from dagster._core.definitions import JobDefinition
4040
from dagster._utils.error import DagsterError
4141

42+
4243
@contextmanager
4344
def my_function():
4445
job = JobDefinition(...)
@@ -51,6 +52,7 @@ def my_function():
5152
def my_function():
5253
from dagster._core.definitions import JobDefinition
5354
from dagster._utils.error import DagsterError
55+
5456
job = JobDefinition(...)
5557
```
5658

@@ -68,6 +70,7 @@ if TYPE_CHECKING:
6870
def create_job():
6971
# Import here to avoid circular dependency
7072
from dagster._core.definitions import JobDefinition
73+
7174
return JobDefinition(...)
7275
```
7376

@@ -154,13 +157,16 @@ def my_command():
154157
```python
155158
_service: Optional[MyService] = None
156159

160+
157161
def get_service() -> Optional[MyService]:
158162
return _service
159163

164+
160165
def initialize_service():
161166
global _service
162167
_service = MyService()
163168

169+
164170
def some_function():
165171
service = get_service() # Hidden dependency
166172
```
@@ -171,6 +177,7 @@ def some_function():
171177
def create_service() -> MyService:
172178
return MyService()
173179

180+
174181
def some_function(service: MyService): # Explicit dependency
175182
service.do_something()
176183
```
@@ -187,6 +194,7 @@ from typing import Literal
187194

188195
DiagnosticsLevel = Literal["off", "error", "info", "debug"]
189196

197+
190198
def create_service(level: DiagnosticsLevel = "off") -> MyService:
191199
return MyService(level=level)
192200
```
@@ -330,13 +338,18 @@ def _get_asset_value_with_fallback(context, asset_key, default_value):
330338
so we use exception handling to detect this case.
331339
"""
332340
try:
333-
return context.instance.get_latest_materialization_event(asset_key).asset_materialization.metadata
341+
return context.instance.get_latest_materialization_event(
342+
asset_key
343+
).asset_materialization.metadata
334344
except Exception:
335345
return default_value
336346

347+
337348
# BAD: Exception control flow exposed in main logic
338349
try:
339-
metadata = context.instance.get_latest_materialization_event(asset_key).asset_materialization.metadata
350+
metadata = context.instance.get_latest_materialization_event(
351+
asset_key
352+
).asset_materialization.metadata
340353
except Exception:
341354
metadata = default_value
342355
```
@@ -457,11 +470,13 @@ return parse_asset_key_from_string(key_str)
457470
# ✅ GOOD: Using click.echo for CLI output
458471
import click
459472

473+
460474
@click.command()
461475
def my_command():
462476
click.echo("Processing started...")
463477
click.echo(f"Found {count} items")
464478

479+
465480
# ❌ BAD: Using print in CLI code
466481
@click.command()
467482
def my_command():

CHANGES.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,7 @@ This version of Dagster inadvertently did not include the webapp code in the pub
12471247
```python
12481248
@dg.asset(deps=[the_asset])
12491249
def the_downstream_asset(context: dg.AssetExecutionContext):
1250-
return context.load_asset_value(dg.AssetKey("the_asset"))
1250+
return context.load_asset_value(dg.AssetKey("the_asset"))
12511251
```
12521252
- Expose asset_selection parameter for `submit_job_execution` function in DagsterGraphQLClient, thanks [@brunobbaraujo](https://github.com/brunobbaraujo)!
12531253
- Large error stack traces from Dagster events will be automatically truncated if the message or stack trace exceeds 500kb. The exact value of the truncation can be overridden by setting the `DAGSTER_EVENT_ERROR_FIELD_SIZE_LIMIT` environment variable.
@@ -3148,10 +3148,12 @@ This version of Dagster resulted in errors when trying to launch runs that targe
31483148
```python
31493149
from dagster import asset, Definitions
31503150

3151+
31513152
@asset
31523153
def my_asset(): ...
31533154

3154-
defs = Definitions(assets=[my_asset, my_asset]) # Deduped into just one AssetsDefinition.
3155+
3156+
defs = Definitions(assets=[my_asset, my_asset]) # Deduped into just one AssetsDefinition.
31553157
```
31563158

31573159
- [dagster-embedded-elt] Adds translator options for dlt integration to override auto materialize policy, group name, owners, and tags
@@ -4855,8 +4857,8 @@ meta:
48554857
- `AssetExecutionContext` is now a subclass of `OpExecutionContext`, not a type alias. The code
48564858

48574859
```python
4858-
def my_helper_function(context: AssetExecutionContext):
4859-
...
4860+
def my_helper_function(context: AssetExecutionContext): ...
4861+
48604862

48614863
@op
48624864
def my_op(context: OpExecutionContext):
@@ -4870,13 +4872,12 @@ will cause type checking errors. To migrate, update type hints to respect the ne
48704872
```python
48714873
## old
48724874
@op
4873-
def my_op(context: AssetExecutionContext):
4874-
...
4875+
def my_op(context: AssetExecutionContext): ...
4876+
48754877

48764878
## correct
48774879
@op
4878-
def my_op(context: OpExecutionContext):
4879-
...
4880+
def my_op(context: OpExecutionContext): ...
48804881
```
48814882

48824883
- [ui] We have removed the option to launch an asset backfill as a single run. To achieve this behavior, add `backfill_policy=BackfillPolicy.single_run()` to your assets.
@@ -5078,8 +5079,7 @@ def my_op(context: OpExecutionContext):
50785079

50795080
```python
50805081
@asset_check(asset=my_asset)
5081-
def my_check(my_asset) -> AssetCheckResult:
5082-
...
5082+
def my_check(my_asset) -> AssetCheckResult: ...
50835083
```
50845084

50855085
- [Breaking] `AssetCheckSpec` now takes `asset=` instead of `asset_key=`, and can accept either a key or an asset definition.
@@ -5453,9 +5453,7 @@ def my_op(context: OpExecutionContext):
54535453

54545454
```python
54555455
dbt_manifest.build_schedule(
5456-
job_name="materialize_dbt_models",
5457-
cron_schedule="0 0 * * *",
5458-
dbt_select="fqn:*"
5456+
job_name="materialize_dbt_models", cron_schedule="0 0 * * *", dbt_select="fqn:*"
54595457
)
54605458
```
54615459

@@ -5663,13 +5661,16 @@ models:
56635661
class GreetingConfig(Config):
56645662
message: str
56655663

5664+
56665665
@op
56675666
def greeting_op(config: GreetingConfig):
56685667
print(config.message)
56695668

5669+
56705670
class HelloConfig(Config):
56715671
name: str
56725672

5673+
56735674
@configured(greeting_op)
56745675
def hello_op(config: HelloConfig):
56755676
return GreetingConfig(message=f"Hello, {config.name}!")
@@ -6230,10 +6231,12 @@ models:
62306231
class MyResource(ConfigurableResource):
62316232
pass
62326233

6234+
62336235
@op
62346236
def my_op(x: int, y: int, my_resource: MyResource) -> int:
62356237
return x + y
62366238

6239+
62376240
my_op(4, 5, my_resource=MyResource())
62386241
```
62396242

@@ -6608,13 +6611,14 @@ Stay tuned, as this is only the first part of the overhaul. We’ll be adding mo
66086611
```python
66096612
from dagster import asset, job, op
66106613

6614+
66116615
@asset
6612-
def emails_to_send():
6613-
...
6616+
def emails_to_send(): ...
6617+
66146618

66156619
@op
6616-
def send_emails(emails) -> None:
6617-
...
6620+
def send_emails(emails) -> None: ...
6621+
66186622

66196623
@job
66206624
def send_emails_job():

0 commit comments

Comments
 (0)