From 817cfaaaff731b7d5c17c2433661fce63c7dff8d Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Sun, 4 Feb 2024 08:26:13 -0500 Subject: [PATCH] chore: bump ruff and move config to `ruff.toml` --- poetry.lock | 38 ++++++++------- pyproject.toml | 110 ------------------------------------------- requirements-dev.txt | 2 +- ruff.toml | 110 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 131 insertions(+), 129 deletions(-) create mode 100644 ruff.toml diff --git a/poetry.lock b/poetry.lock index 4ac53bf31def5..27fbf96d84b72 100644 --- a/poetry.lock +++ b/poetry.lock @@ -4361,6 +4361,8 @@ files = [ {file = "psycopg2-2.9.9-cp310-cp310-win_amd64.whl", hash = "sha256:426f9f29bde126913a20a96ff8ce7d73fd8a216cfb323b1f04da402d452853c3"}, {file = "psycopg2-2.9.9-cp311-cp311-win32.whl", hash = "sha256:ade01303ccf7ae12c356a5e10911c9e1c51136003a9a1d92f7aa9d010fb98372"}, {file = "psycopg2-2.9.9-cp311-cp311-win_amd64.whl", hash = "sha256:121081ea2e76729acfb0673ff33755e8703d45e926e416cb59bae3a86c6a4981"}, + {file = "psycopg2-2.9.9-cp312-cp312-win32.whl", hash = "sha256:d735786acc7dd25815e89cc4ad529a43af779db2e25aa7c626de864127e5a024"}, + {file = "psycopg2-2.9.9-cp312-cp312-win_amd64.whl", hash = "sha256:a7653d00b732afb6fc597e29c50ad28087dcb4fbfb28e86092277a559ae4e693"}, {file = "psycopg2-2.9.9-cp37-cp37m-win32.whl", hash = "sha256:5e0d98cade4f0e0304d7d6f25bbfbc5bd186e07b38eac65379309c4ca3193efa"}, {file = "psycopg2-2.9.9-cp37-cp37m-win_amd64.whl", hash = "sha256:7e2dacf8b009a1c1e843b5213a87f7c544b2b042476ed7755be813eaf4e8347a"}, {file = "psycopg2-2.9.9-cp38-cp38-win32.whl", hash = "sha256:ff432630e510709564c01dafdbe996cb552e0b9f3f065eb89bdce5bd31fabf4c"}, @@ -5983,28 +5985,28 @@ pyasn1 = ">=0.1.3" [[package]] name = "ruff" -version = "0.1.13" +version = "0.2.0" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.1.13-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:e3fd36e0d48aeac672aa850045e784673449ce619afc12823ea7868fcc41d8ba"}, - {file = "ruff-0.1.13-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:9fb6b3b86450d4ec6a6732f9f60c4406061b6851c4b29f944f8c9d91c3611c7a"}, - {file = "ruff-0.1.13-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b13ba5d7156daaf3fd08b6b993360a96060500aca7e307d95ecbc5bb47a69296"}, - {file = "ruff-0.1.13-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:9ebb40442f7b531e136d334ef0851412410061e65d61ca8ce90d894a094feb22"}, - {file = "ruff-0.1.13-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:226b517f42d59a543d6383cfe03cccf0091e3e0ed1b856c6824be03d2a75d3b6"}, - {file = "ruff-0.1.13-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:5f0312ba1061e9b8c724e9a702d3c8621e3c6e6c2c9bd862550ab2951ac75c16"}, - {file = "ruff-0.1.13-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:2f59bcf5217c661254bd6bc42d65a6fd1a8b80c48763cb5c2293295babd945dd"}, - {file = "ruff-0.1.13-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e6894b00495e00c27b6ba61af1fc666f17de6140345e5ef27dd6e08fb987259d"}, - {file = "ruff-0.1.13-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9a1600942485c6e66119da294c6294856b5c86fd6df591ce293e4a4cc8e72989"}, - {file = "ruff-0.1.13-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:ee3febce7863e231a467f90e681d3d89210b900d49ce88723ce052c8761be8c7"}, - {file = "ruff-0.1.13-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:dcaab50e278ff497ee4d1fe69b29ca0a9a47cd954bb17963628fa417933c6eb1"}, - {file = "ruff-0.1.13-py3-none-musllinux_1_2_i686.whl", hash = "sha256:f57de973de4edef3ad3044d6a50c02ad9fc2dff0d88587f25f1a48e3f72edf5e"}, - {file = "ruff-0.1.13-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:7a36fa90eb12208272a858475ec43ac811ac37e91ef868759770b71bdabe27b6"}, - {file = "ruff-0.1.13-py3-none-win32.whl", hash = "sha256:a623349a505ff768dad6bd57087e2461be8db58305ebd5577bd0e98631f9ae69"}, - {file = "ruff-0.1.13-py3-none-win_amd64.whl", hash = "sha256:f988746e3c3982bea7f824c8fa318ce7f538c4dfefec99cd09c8770bd33e6539"}, - {file = "ruff-0.1.13-py3-none-win_arm64.whl", hash = "sha256:6bbbc3042075871ec17f28864808540a26f0f79a4478c357d3e3d2284e832998"}, - {file = "ruff-0.1.13.tar.gz", hash = "sha256:e261f1baed6291f434ffb1d5c6bd8051d1c2a26958072d38dfbec39b3dda7352"}, + {file = "ruff-0.2.0-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:638ea3294f800d18bae84a492cb5a245c8d29c90d19a91d8e338937a4c27fca0"}, + {file = "ruff-0.2.0-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:3ff35433fcf4dff6d610738712152df6b7d92351a1bde8e00bd405b08b3d5759"}, + {file = "ruff-0.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bf9faafbdcf4f53917019f2c230766da437d4fd5caecd12ddb68bb6a17d74399"}, + {file = "ruff-0.2.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:8153a3e4128ed770871c47545f1ae7b055023e0c222ff72a759f5a341ee06483"}, + {file = "ruff-0.2.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:e8a75a98ae989a27090e9c51f763990ad5bbc92d20626d54e9701c7fe597f399"}, + {file = "ruff-0.2.0-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:87057dd2fdde297130ff99553be8549ca38a2965871462a97394c22ed2dfc19d"}, + {file = "ruff-0.2.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6d232f99d3ab00094ebaf88e0fb7a8ccacaa54cc7fa3b8993d9627a11e6aed7a"}, + {file = "ruff-0.2.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3d3c641f95f435fc6754b05591774a17df41648f0daf3de0d75ad3d9f099ab92"}, + {file = "ruff-0.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3826fb34c144ef1e171b323ed6ae9146ab76d109960addca730756dc19dc7b22"}, + {file = "ruff-0.2.0-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:eceab7d85d09321b4de18b62d38710cf296cb49e98979960a59c6b9307c18cfe"}, + {file = "ruff-0.2.0-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:30ad74687e1f4a9ff8e513b20b82ccadb6bd796fe5697f1e417189c5cde6be3e"}, + {file = "ruff-0.2.0-py3-none-musllinux_1_2_i686.whl", hash = "sha256:a7e3818698f8460bd0f8d4322bbe99db8327e9bc2c93c789d3159f5b335f47da"}, + {file = "ruff-0.2.0-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:edf23041242c48b0d8295214783ef543847ef29e8226d9f69bf96592dba82a83"}, + {file = "ruff-0.2.0-py3-none-win32.whl", hash = "sha256:e155147199c2714ff52385b760fe242bb99ea64b240a9ffbd6a5918eb1268843"}, + {file = "ruff-0.2.0-py3-none-win_amd64.whl", hash = "sha256:ba918e01cdd21e81b07555564f40d307b0caafa9a7a65742e98ff244f5035c59"}, + {file = "ruff-0.2.0-py3-none-win_arm64.whl", hash = "sha256:3fbaff1ba9564a2c5943f8f38bc221f04bac687cc7485e45237579fee7ccda79"}, + {file = "ruff-0.2.0.tar.gz", hash = "sha256:63856b91837606c673537d2889989733d7dffde553828d3b0f0bacfa6def54be"}, ] [[package]] diff --git a/pyproject.toml b/pyproject.toml index 300360d3c27ef..b16d67404a912 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -399,116 +399,6 @@ skip = "*.lock,.direnv,.git,./docs/_freeze,docs/_freeze/**,*.svg,*.css,*.html,*. ignore-regex = '\b(i[if]f|I[IF]F|AFE)\b' builtin = "clear,rare,names" -[tool.ruff] -line-length = 88 -select = [ - "B", # flake8-bugbear - "BLE", # flake8-blind-except - "C4", # comprehensions - "D", # pydocstyle - "E", # pycodestyle - "EXE", # flake8-executable - "F", # pyflakes - "FA", # flake8-future-annotations - "G", # flake8-logging-format - "FLY", # flynt (format string conversion) - "I", # isort - "ICN", # flake8-import-conventions - "INP", # flake8-no-pep420 (implicit namespace packages) - "ISC", # flake8-implicit-str-concat - "PGH", # pygrep-hooks - "PIE", # flake8-pie - "PL", # pylint - "RET", # flake8-return - "RUF", # ruff-specific rules - "SIM", # flake8-simplify - "T10", # flake8-debugger - "T20", # flake8-print - "TCH", # flake8-type-checking - "TID", # flake8-tidy-imports - "UP", # pyupgrade - "W", # pycodestyle - "YTT", # flake8-2020 -] -respect-gitignore = true -ignore = [ - "B028", # required stacklevel argument to warn - "B904", # raise from e or raise from None in exception handlers - "C408", # dict(...) as literal - "D100", # public module - "D101", # public class - "D102", # public method - "D103", # public function - "D104", # public package - "D105", # magic methods - "D106", # nested class - "D107", # init - "D202", # blank lines after function docstring - "D203", # blank line before class docstring - "D213", # Multi-line docstring summary should start at the second line - "D401", # Imperative mood - "D402", # First line should not be the function's signature - "D413", # Blank line required after last section - "E501", # line-too-long, this is automatically enforced by ruff format - "E731", # lambda-assignment - "ISC001", # single line implicit string concat, handled by ruff format - "PGH003", # blanket-type-ignore - "PLC0105", # covariant type parameters should have a _co suffix - "PLR0124", # name compared with self, e.g., a == a - "PLR0911", # too many return statements - "PLR0912", # too many branches - "PLR0913", # too many arguments - "PLR0915", # too many statements - "PLR2004", # forces everything to be a constant - "PLW2901", # overwriting loop variable - "RET504", # unnecessary-assign, these are useful for debugging - "RET505", # superfluous-else-return, stylistic choice - "RET506", # superfluous-else-raise, stylistic choice - "RET507", # superfluous-else-continue, stylistic choice - "RET508", # superfluous-else-break, stylistic choice - "RUF005", # splat instead of concat - "RUF012", # Mutable class attributes should be annotated with `typing.ClassVar` - "SIM102", # nested ifs - "SIM108", # convert everything to ternary operator - "SIM114", # combine `if` branches using logical `or` operator - "SIM116", # dictionary instead of `if` statements - "SIM117", # nested with statements - "SIM118", # remove .keys() calls from dictionaries - "SIM300", # yoda conditions - "UP007", # Optional[str] -> str | None -] -exclude = ["*_py310.py"] -target-version = "py39" -# none of these codes will be automatically fixed by ruff -unfixable = [ - "T201", # print statements - "F401", # unused imports - "RUF100", # unused noqa comments - "F841", # unused variables -] - -[tool.ruff.pyupgrade] -keep-runtime-typing = true - -[tool.ruff.isort] -required-imports = ["from __future__ import annotations"] - -[tool.ruff.per-file-ignores] -"*test*.py" = [ - "D", # ignore all docstring lints in tests -] -"{docs,ci}/**/*.py" = ["INP001"] -"*/decompiled.py" = ["ALL"] -"{ci/release/verify_release,docs/**/*_impl}.py" = [ - "T201", -] # prints output using `print` -"docs/**/{datafusion,polars}_*.py" = ["T201"] # prints output using `print` - -[tool.ruff.format] -exclude = [".direnv", "result-*", "_py310.py", "decompiled.py"] -docstring-code-format = true -docstring-code-line-length = 88 - [tool.conda-lock] channels = ["conda-forge"] diff --git a/requirements-dev.txt b/requirements-dev.txt index ab9141b826d6b..0cb17917c8d76 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -223,7 +223,7 @@ requests[socks]==2.31.0 ; python_version >= "3.10" and python_version < "3.13" rich==13.7.0 ; python_version >= "3.9" and python_version < "4.0" rpds-py==0.17.1 ; python_version >= "3.10" and python_version < "3.13" rsa==4.9 ; python_version >= "3.9" and python_version < "4" -ruff==0.1.13 ; python_version >= "3.9" and python_version < "4.0" +ruff==0.2.0 ; python_version >= "3.9" and python_version < "4.0" scikit-learn==1.3.2 ; python_version >= "3.10" and python_version < "3.13" scipy==1.11.4 ; python_version >= "3.10" and python_version < "3.13" scooby==0.9.2 ; python_version >= "3.10" and python_version < "3.13" diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 0000000000000..1bcb3d89e7d2f --- /dev/null +++ b/ruff.toml @@ -0,0 +1,110 @@ +line-length = 88 +respect-gitignore = true +exclude = ["*_py310.py"] +target-version = "py39" + +[lint] +select = [ + "B", # flake8-bugbear + "BLE", # flake8-blind-except + "C4", # comprehensions + "D", # pydocstyle + "E", # pycodestyle + "EXE", # flake8-executable + "F", # pyflakes + "FA", # flake8-future-annotations + "G", # flake8-logging-format + "FLY", # flynt (format string conversion) + "I", # isort + "ICN", # flake8-import-conventions + "INP", # flake8-no-pep420 (implicit namespace packages) + "ISC", # flake8-implicit-str-concat + "PGH", # pygrep-hooks + "PIE", # flake8-pie + "PL", # pylint + "RET", # flake8-return + "RUF", # ruff-specific rules + "SIM", # flake8-simplify + "T10", # flake8-debugger + "T20", # flake8-print + "TCH", # flake8-type-checking + "TID", # flake8-tidy-imports + "UP", # pyupgrade + "W", # pycodestyle + "YTT", # flake8-2020 +] +ignore = [ + "B028", # required stacklevel argument to warn + "B904", # raise from e or raise from None in exception handlers + "C408", # dict(...) as literal + "D100", # public module + "D101", # public class + "D102", # public method + "D103", # public function + "D104", # public package + "D105", # magic methods + "D106", # nested class + "D107", # init + "D202", # blank lines after function docstring + "D203", # blank line before class docstring + "D213", # Multi-line docstring summary should start at the second line + "D401", # Imperative mood + "D402", # First line should not be the function's signature + "D413", # Blank line required after last section + "E501", # line-too-long, this is automatically enforced by ruff format + "E731", # lambda-assignment + "ISC001", # single line implicit string concat, handled by ruff format + "PGH003", # blanket-type-ignore + "PLC0105", # covariant type parameters should have a _co suffix + "PLR0124", # name compared with self, e.g., a == a + "PLR0911", # too many return statements + "PLR0912", # too many branches + "PLR0913", # too many arguments + "PLR0915", # too many statements + "PLR2004", # forces everything to be a constant + "PLW2901", # overwriting loop variable + "RET504", # unnecessary-assign, these are useful for debugging + "RET505", # superfluous-else-return, stylistic choice + "RET506", # superfluous-else-raise, stylistic choice + "RET507", # superfluous-else-continue, stylistic choice + "RET508", # superfluous-else-break, stylistic choice + "RUF005", # splat instead of concat + "RUF012", # Mutable class attributes should be annotated with `typing.ClassVar` + "SIM102", # nested ifs + "SIM108", # convert everything to ternary operator + "SIM114", # combine `if` branches using logical `or` operator + "SIM116", # dictionary instead of `if` statements + "SIM117", # nested with statements + "SIM118", # remove .keys() calls from dictionaries + "SIM300", # yoda conditions + "UP007", # Optional[str] -> str | None +] +# none of these codes will be automatically fixed by ruff +unfixable = [ + "T201", # print statements + "F401", # unused imports + "RUF100", # unused noqa comments + "F841", # unused variables +] + +[lint.pyupgrade] +keep-runtime-typing = true + +[lint.isort] +required-imports = ["from __future__ import annotations"] + +[lint.per-file-ignores] +"*test*.py" = [ + "D", # ignore all docstring lints in tests +] +"{docs,ci}/**/*.py" = ["INP001"] +"*/decompiled.py" = ["ALL"] +"{ci/release/verify_release,docs/**/*_impl}.py" = [ + "T201", +] # prints output using `print` +"docs/**/{datafusion,polars}_*.py" = ["T201"] # prints output using `print` + +[format] +exclude = [".direnv", "result-*", "_py310.py", "decompiled.py"] +docstring-code-format = true +docstring-code-line-length = 88