From ab977e36c9763a62da012b8a88a6e4ea15cf896b Mon Sep 17 00:00:00 2001 From: Florian Maas Date: Thu, 18 Jul 2024 09:54:23 +0200 Subject: [PATCH] chore: enable `RUF` ruleset for `ruff` (#2677) # Description This PR proposes to enable the [`RUF`](https://docs.astral.sh/ruff/rules/#ruff-specific-rules-ruf) ruleset. ``` ruff check . ``` returned: ``` warning: The top-level linter settings are deprecated in favour of their counterparts in the `lint` section. Please update the following options in `pyproject.toml`: - 'ignore' -> 'lint.ignore' - 'select' -> 'lint.select' - 'isort' -> 'lint.isort' deltalake/table.py:52:26: RUF100 [*] Unused `noqa` directive (unused: `F811`) deltalake/writer.py:63:26: RUF100 [*] Unused `noqa` directive (unused: `F811`) tests/pyspark_integration/test_write_to_pyspark.py:109:37: RUF010 [*] Use explicit conversion flag Found 3 errors. [*] 3 fixable with the `--fix` option. ``` So these were simply fixed with `ruff check . --fix`. https://github.com/delta-io/delta-rs/pull/2673 handles the fixing of the outdated config. --------- Co-authored-by: R. Tyler Croy --- python/deltalake/table.py | 2 +- python/deltalake/writer.py | 2 +- python/pyproject.toml | 4 +++- python/tests/pyspark_integration/test_write_to_pyspark.py | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/python/deltalake/table.py b/python/deltalake/table.py index 14ffd3f6f9..a85a31bf0b 100644 --- a/python/deltalake/table.py +++ b/python/deltalake/table.py @@ -49,7 +49,7 @@ from deltalake.schema import Schema as DeltaSchema try: - import pandas as pd # noqa: F811 + import pandas as pd except ModuleNotFoundError: _has_pandas = False else: diff --git a/python/deltalake/writer.py b/python/deltalake/writer.py index b5b26cf8f5..1718b5764b 100644 --- a/python/deltalake/writer.py +++ b/python/deltalake/writer.py @@ -61,7 +61,7 @@ ) try: - import pandas as pd # noqa: F811 + import pandas as pd except ModuleNotFoundError: _has_pandas = False else: diff --git a/python/pyproject.toml b/python/pyproject.toml index dd69669335..c02b341dba 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -83,7 +83,9 @@ select = [ # pyflakes "F", # isort - "I" + "I", + # ruff-specific rules + "RUF" ] ignore = ["E501"] diff --git a/python/tests/pyspark_integration/test_write_to_pyspark.py b/python/tests/pyspark_integration/test_write_to_pyspark.py index 3e4bb9d7f0..81cda71883 100644 --- a/python/tests/pyspark_integration/test_write_to_pyspark.py +++ b/python/tests/pyspark_integration/test_write_to_pyspark.py @@ -106,7 +106,7 @@ def test_checks_min_writer_version(tmp_path: pathlib.Path): ) # Add a constraint upgrades the minWriterProtocol - spark.sql(f"ALTER TABLE delta.`{str(tmp_path)}` ADD CONSTRAINT x CHECK (c1 > 2)") + spark.sql(f"ALTER TABLE delta.`{tmp_path!s}` ADD CONSTRAINT x CHECK (c1 > 2)") with pytest.raises( DeltaProtocolError, match="This table's min_writer_version is 3, but"