Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade configuration for Ruff v0.2.0 #19544

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion examples/docs_snippets/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ extend = "../pyproject.toml"
# Shorter line length for docs snippets for better browser formatting.
line-length = 88

[tool.ruff.lint]

# Use extend-ignore so that we ignore all the same codes ignored in root.
extend-ignore = [

Expand All @@ -26,7 +28,7 @@ extend-ignore = [
"TCH",
]

[tool.ruff.isort]
[tool.ruff.lint.isort]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linter settings are in general now under tool.ruff.lint, with settings that are shared between Ruff's linter and formatter at the top-level (tool.ruff). So this is all just moving settings around between those sections as appropriate.


# Ensures ruff classifies imports from `dagster` as first-party. Keeps snippet imports relatively
# compressed.
Expand Down
6 changes: 4 additions & 2 deletions examples/project_analytics/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ module_name = "dagster_pypi"
[tool.ruff]
# Extend root configuration.
extend = "../../pyproject.toml"

src = ["dagster_pypi"]

[tool.ruff.lint]
# Use extend-ignore so that we ignore all the same codes ignored in root.
extend-ignore = [
# (print found): Allow prints for demo purposes.
"T201",
]

src = ["dagster_pypi"]
2 changes: 1 addition & 1 deletion examples/project_dagster_university_start/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ module_name = "dagster_university"
[tool.ruff]
extend = "../../pyproject.toml"

[tool.ruff.lint]
extend-ignore = [

# (Unused import): We stub some files with just imports to help people get started
"F401",
# (Import block is un-sorted or un-formatted): It's more important that we introduce the imports in the order they're used rather than alphabetically.
Expand Down
26 changes: 14 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ extend-exclude = [
"*/snapshots/*",
]

# Codebase-wide default line length. Override in package-specific pyproject.toml where a different
# length is desired.
line-length = 100

# Fail if Ruff is not running this version.
required-version = "0.1.7"

[tool.ruff.lint]

ignore = [

# (missing public docstrings) These work off of the Python sense of "public", rather than our
Expand Down Expand Up @@ -165,10 +174,6 @@ ignore = [
"PERF402", # (manual-list-copy)
]

# Codebase-wide default line length. Override in package-specific pyproject.toml where a different
# length is desired.
line-length = 100

# By default, ruff only uses all "E" (pycodestyle) and "F" (pyflakes) rules.
# Here we append to the defaults.
select = [
Expand Down Expand Up @@ -230,19 +235,16 @@ select = [
"W605",
]

# Fail if Ruff is not running this version.
required-version = "0.1.7"

[tool.ruff.flake8-builtins]
[tool.ruff.lint.flake8-builtins]

# We use `id` in many places and almost never want to use the python builtin.
builtins-ignorelist = ["id"]

[tool.ruff.flake8-tidy-imports.banned-api]
[tool.ruff.lint.flake8-tidy-imports.banned-api]

"__future__.annotations".msg = "Directly quote annotations instead."

[tool.ruff.isort]
[tool.ruff.lint.isort]

# Combine multiple `from foo import bar as baz` statements with the same source
# (`foo`) into a single statement.
Expand All @@ -252,12 +254,12 @@ combine-as-imports = true
# per line. Useful for __init__.py files that just re-export symbols.
force-wrap-aliases = true

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]

# Don't format docstrings in alembic migrations.
"**/alembic/versions/*.py" = ["D"]

[tool.ruff.pydocstyle]
[tool.ruff.lint.pydocstyle]

# Enforce google-style docstrings. This is equivalent to ignoring a large number of pydocstyle (D)
# rules incompatible with google-style docstrings. See:
Expand Down
6 changes: 3 additions & 3 deletions python_modules/libraries/dagster-celery/dagster_celery/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,17 @@ def get_config_dir(config_yaml=None):

validated_config = get_validated_config(config_yaml)
with open(config_path, "w", encoding="utf8") as fd:
if "broker" in validated_config and validated_config["broker"]:
if validated_config.get("broker"):
fd.write(
"broker_url = '{broker_url}'\n".format(broker_url=str(validated_config["broker"]))
)
if "backend" in validated_config and validated_config["backend"]:
if validated_config.get("backend"):
fd.write(
"result_backend = '{result_backend}'\n".format(
result_backend=str(validated_config["backend"])
)
)
if "config_source" in validated_config and validated_config["config_source"]:
if validated_config.get("config_source"):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are violations for an existing rule that Dagster has enabled, but whose scope was extended in a later release. So this just avoids violations showing up after you upgrade.

for key, value in validated_config["config_source"].items():
fd.write(f"{key} = {value!r}\n")

Expand Down