From 1a1574bf12f8b07aff87e6ebeb9e881a00f104d5 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Thu, 6 Jun 2024 15:23:19 +1000 Subject: [PATCH 1/4] Enable ruff --- pants.toml | 1 + pyproject.toml | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/pants.toml b/pants.toml index 6b91bb1bbd9..ac5de7af584 100644 --- a/pants.toml +++ b/pants.toml @@ -13,6 +13,7 @@ backend_packages.add = [ "pants.backend.python.lint.docformatter", "pants.backend.python.lint.flake8", "pants.backend.python.lint.isort", + "pants.backend.experimental.python.lint.ruff.check", "pants.backend.python.typecheck.mypy", "pants.backend.python.lint.pyupgrade", "pants.backend.python.mixed_interpreter_constraints", diff --git a/pyproject.toml b/pyproject.toml index ed16aafd74c..f46a7e2820d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,3 +70,12 @@ module = [ "psutil", ] ignore_missing_imports = true + +[tool.ruff] +target-version = "py39" +# same as black +line-length = 100 + +[tool.ruff.lint] +select = [ +] From 5b2a56997f1b54d79747cddb86c6d68d6c45ee93 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Thu, 6 Jun 2024 15:43:37 +1000 Subject: [PATCH 2/4] Move move built-in linters from flake8 to ruff --- build-support/flake8/.flake8 | 17 +++++------------ pyproject.toml | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/build-support/flake8/.flake8 b/build-support/flake8/.flake8 index c3a8b6e1a9b..345c647171e 100644 --- a/build-support/flake8/.flake8 +++ b/build-support/flake8/.flake8 @@ -1,23 +1,16 @@ [flake8] extend-ignore: - # whitespace before ':' (conflicts with Black) - E203, - # Bad trailing comma (conflicts with Black) - E231, - # line too long (> 79 characters) - E501, - # Do not assign a lambda expression - E731, - # Ambiguous variable name (enable once fixed) - E741, - # line break before binary operator (conflicts with Black) - W503, # Implicitly concatenated string literals over multiple lines NIC002, # Implicitly concatenated bytes literals over multiple lines NIC102, # Unnecessary dict call - rewrite as a literal C408, + # Handled by ruff: + F, + E, + W, + C90, [flake8:local-plugins] extension = diff --git a/pyproject.toml b/pyproject.toml index f46a7e2820d..1ac4404d6e2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -78,4 +78,21 @@ line-length = 100 [tool.ruff.lint] select = [ + # flake8 defaults: + "F", + "E", + "W", +] + +ignore = [ + # whitespace before ':' (conflicts with Black) + "E203", + # Bad trailing comma (conflicts with Black) + "E231", + # line too long (> 79 characters) + "E501", + # Do not assign a lambda expression + "E731", + # Ambiguous variable name (enable once fixed) + "E741", ] From f330f2eca128d9ffbdb77b103845145a0af938d8 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Thu, 6 Jun 2024 15:47:09 +1000 Subject: [PATCH 3/4] Move flake8-2020, flake8-comprehensions --- 3rdparty/python/flake8-requirements.txt | 2 -- 3rdparty/python/flake8.lock | 45 ------------------------- build-support/flake8/.flake8 | 2 -- pyproject.toml | 6 ++++ 4 files changed, 6 insertions(+), 49 deletions(-) diff --git a/3rdparty/python/flake8-requirements.txt b/3rdparty/python/flake8-requirements.txt index 08530824817..36c8bdffbdd 100644 --- a/3rdparty/python/flake8-requirements.txt +++ b/3rdparty/python/flake8-requirements.txt @@ -1,4 +1,2 @@ flake8>=5.0.4,<7 -flake8-2020>=1.7.0,<2 flake8-no-implicit-concat -flake8-comprehensions>=3.10.0,<4.0 diff --git a/3rdparty/python/flake8.lock b/3rdparty/python/flake8.lock index b4f94d2c3b2..16e49421250 100644 --- a/3rdparty/python/flake8.lock +++ b/3rdparty/python/flake8.lock @@ -9,8 +9,6 @@ // "CPython==3.9.*" // ], // "generated_with_requirements": [ -// "flake8-2020<2,>=1.7.0", -// "flake8-comprehensions<4.0,>=3.10.0", // "flake8-no-implicit-concat", // "flake8<7,>=5.0.4" // ], @@ -52,47 +50,6 @@ "requires_python": ">=3.8.1", "version": "6.0.0" }, - { - "artifacts": [ - { - "algorithm": "sha256", - "hash": "1553b2b3638135b276f7a3252301e81376901e7b6a5eaccb07a969771f178375", - "url": "https://files.pythonhosted.org/packages/a5/6e/df5766df36c1280d0b96996e89e160cab2f1fa4ffd7434ff252c51025ca7/flake8_2020-1.8.0-py2.py3-none-any.whl" - }, - { - "algorithm": "sha256", - "hash": "f5312b3634266bd0f1957f64ecabeb62d67bbd9cee637e33a2651a80091f90aa", - "url": "https://files.pythonhosted.org/packages/3d/0e/29c1a6d15baa70865daa1ae6887742d5907fb75b92c4c1a8281915f8550d/flake8_2020-1.8.0.tar.gz" - } - ], - "project_name": "flake8-2020", - "requires_dists": [ - "flake8>=5" - ], - "requires_python": ">=3.8", - "version": "1.8.0" - }, - { - "artifacts": [ - { - "algorithm": "sha256", - "hash": "013234637ec7dfcb7cd2900578fb53c512f81db909cefe371c019232695c362d", - "url": "https://files.pythonhosted.org/packages/9b/8d/b70f791311a8c6975c0c6634dd44db8fd712d6ad9ed6a3fe888b9be7c89b/flake8_comprehensions-3.12.0-py3-none-any.whl" - }, - { - "algorithm": "sha256", - "hash": "419ef1a6e8de929203791a5e8ff5e3906caeba13eb3290eebdbf88a9078d502e", - "url": "https://files.pythonhosted.org/packages/65/b4/9a2cbbac095aaf1e8dbe3eac55a5155cb9f7860fbb0d9fa23443b5a3afd1/flake8_comprehensions-3.12.0.tar.gz" - } - ], - "project_name": "flake8-comprehensions", - "requires_dists": [ - "flake8!=3.2.0,>=3.0", - "importlib-metadata; python_version < \"3.8\"" - ], - "requires_python": ">=3.7", - "version": "3.12.0" - }, { "artifacts": [ { @@ -212,8 +169,6 @@ "pip_version": "23.1.2", "prefer_older_binary": false, "requirements": [ - "flake8-2020<2,>=1.7.0", - "flake8-comprehensions<4.0,>=3.10.0", "flake8-no-implicit-concat", "flake8<7,>=5.0.4" ], diff --git a/build-support/flake8/.flake8 b/build-support/flake8/.flake8 index 345c647171e..6ba52fcf1c1 100644 --- a/build-support/flake8/.flake8 +++ b/build-support/flake8/.flake8 @@ -4,8 +4,6 @@ extend-ignore: NIC002, # Implicitly concatenated bytes literals over multiple lines NIC102, - # Unnecessary dict call - rewrite as a literal - C408, # Handled by ruff: F, E, diff --git a/pyproject.toml b/pyproject.toml index 1ac4404d6e2..8dc3b306519 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -82,6 +82,10 @@ select = [ "F", "E", "W", + # flake8-comprehensions + "C4", + # flake8-2020 + "YTT", ] ignore = [ @@ -95,4 +99,6 @@ ignore = [ "E731", # Ambiguous variable name (enable once fixed) "E741", + # Unnecessary dict call - rewrite as a literal + "C408", ] From 9c270a3b50a20d9f13aa271bbb152dc7287e78e6 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Thu, 6 Jun 2024 15:56:57 +1000 Subject: [PATCH 4/4] flake8-no-implicit-concat -> ruff (flake8-implicit-str-concat) --- 3rdparty/python/flake8-requirements.txt | 1 - 3rdparty/python/flake8.lock | 58 ------------------------- build-support/flake8/.flake8 | 6 +-- pyproject.toml | 2 + 4 files changed, 3 insertions(+), 64 deletions(-) diff --git a/3rdparty/python/flake8-requirements.txt b/3rdparty/python/flake8-requirements.txt index 36c8bdffbdd..739a1d17f30 100644 --- a/3rdparty/python/flake8-requirements.txt +++ b/3rdparty/python/flake8-requirements.txt @@ -1,2 +1 @@ flake8>=5.0.4,<7 -flake8-no-implicit-concat diff --git a/3rdparty/python/flake8.lock b/3rdparty/python/flake8.lock index 16e49421250..49f57a841c6 100644 --- a/3rdparty/python/flake8.lock +++ b/3rdparty/python/flake8.lock @@ -9,7 +9,6 @@ // "CPython==3.9.*" // ], // "generated_with_requirements": [ -// "flake8-no-implicit-concat", // "flake8<7,>=5.0.4" // ], // "manylinux": "manylinux2014", @@ -50,44 +49,6 @@ "requires_python": ">=3.8.1", "version": "6.0.0" }, - { - "artifacts": [ - { - "algorithm": "sha256", - "hash": "5c056e06f22820865cb34962a1da80767fed5273920b0768e97739021d428de5", - "url": "https://files.pythonhosted.org/packages/87/04/983ec9268488911103bc3b30bcdef3936cb9ed55a53d8ad25f023e76243a/flake8_no_implicit_concat-0.3.4-py3-none-any.whl" - }, - { - "algorithm": "sha256", - "hash": "1b522becd7568ee2e288bc58e294ebd0d771996ee3138a5322a3cefb21c8464b", - "url": "https://files.pythonhosted.org/packages/00/f2/f7616a05059683e4e3970c21f7ed820b18eca08ab272e774dc5ed07aa9c6/flake8-no-implicit-concat-0.3.4.tar.gz" - } - ], - "project_name": "flake8-no-implicit-concat", - "requires_dists": [ - "black; extra == \"dev\"", - "codecov; extra == \"dev\"", - "coverage; extra == \"dev\"", - "darglint; extra == \"dev\"", - "flake8", - "flake8-2020; extra == \"dev\"", - "flake8-black; extra == \"dev\"", - "flake8-broken-line; extra == \"dev\"", - "flake8-builtins; extra == \"dev\"", - "flake8-docstrings; extra == \"dev\"", - "flake8-isort; extra == \"dev\"", - "flake8-rst-docstrings; extra == \"dev\"", - "flake8; extra == \"dev\"", - "hacking>=4; extra == \"dev\"", - "isort; extra == \"dev\"", - "more-itertools; python_version < \"3.10\"", - "mypy; extra == \"dev\"", - "pep8-naming; extra == \"dev\"", - "typing; python_version < \"3.5\"" - ], - "requires_python": ">=3.3", - "version": "0.3.4" - }, { "artifacts": [ { @@ -106,24 +67,6 @@ "requires_python": ">=3.6", "version": "0.7.0" }, - { - "artifacts": [ - { - "algorithm": "sha256", - "hash": "d2bc7f02446e86a68911e58ded76d6561eea00cddfb2a91e7019bbb586c799f3", - "url": "https://files.pythonhosted.org/packages/85/01/e2678ee4e0d7eed4fd6be9e5b043fff9d22d245d06c8c91def8ced664189/more_itertools-9.1.0-py3-none-any.whl" - }, - { - "algorithm": "sha256", - "hash": "cabaa341ad0389ea83c17a94566a53ae4c9d07349861ecb14dc6d0345cf9ac5d", - "url": "https://files.pythonhosted.org/packages/2e/d0/bea165535891bd1dcb5152263603e902c0ec1f4c9a2e152cc4adff6b3a38/more-itertools-9.1.0.tar.gz" - } - ], - "project_name": "more-itertools", - "requires_dists": [], - "requires_python": ">=3.7", - "version": "9.1.0" - }, { "artifacts": [ { @@ -169,7 +112,6 @@ "pip_version": "23.1.2", "prefer_older_binary": false, "requirements": [ - "flake8-no-implicit-concat", "flake8<7,>=5.0.4" ], "requires_python": [ diff --git a/build-support/flake8/.flake8 b/build-support/flake8/.flake8 index 6ba52fcf1c1..ca6e41d3f25 100644 --- a/build-support/flake8/.flake8 +++ b/build-support/flake8/.flake8 @@ -1,10 +1,6 @@ [flake8] extend-ignore: - # Implicitly concatenated string literals over multiple lines - NIC002, - # Implicitly concatenated bytes literals over multiple lines - NIC102, - # Handled by ruff: + # Defaults are all handled by ruff: F, E, W, diff --git a/pyproject.toml b/pyproject.toml index 8dc3b306519..f6ae8ca3071 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -86,6 +86,8 @@ select = [ "C4", # flake8-2020 "YTT", + # flake8-implicit-str-concat, but only on a single line (includes bytes) + "ISC001", ] ignore = [