From 4407cb64926a0bb6f30066f00e60e75970a28cb1 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Wed, 4 Oct 2023 14:21:48 +0200 Subject: [PATCH] get rid of isort --- .github/workflows/build.yml | 2 +- Makefile | 11 +---------- pyproject.toml | 13 +++++-------- scripts/internal/git_pre_commit.py | 28 ++++------------------------ scripts/internal/winmake.py | 1 - 5 files changed, 11 insertions(+), 44 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0171e8a43..4bb8d108b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -115,7 +115,7 @@ jobs: python-version: 3.x - name: 'Run linters' run: | - python3 -m pip install isort rstcheck toml-sort sphinx + python3 -m pip install ruff rstcheck toml-sort sphinx make lint-all # Check sanity of .tar.gz + wheel files diff --git a/Makefile b/Makefile index dfacfb60e..06dd2a5d5 100644 --- a/Makefile +++ b/Makefile @@ -12,8 +12,6 @@ PY3_DEPS = \ check-manifest \ concurrencytest \ coverage \ - isort \ - pep8-naming \ pylint \ pyperf \ pypinfo \ @@ -195,9 +193,6 @@ test-coverage: ## Run test coverage. ruff: ## Run ruff linter. @git ls-files '*.py' | xargs $(PYTHON) -m ruff check --config=pyproject.toml --no-cache -isort: ## Run isort linter. - @git ls-files '*.py' | xargs $(PYTHON) -m isort --check-only --jobs=${NUM_WORKERS} - _pylint: ## Python pylint (not mandatory, just run it from time to time) @git ls-files '*.py' | xargs $(PYTHON) -m pylint --rcfile=pyproject.toml --jobs=${NUM_WORKERS} @@ -211,7 +206,7 @@ lint-toml: ## Linter for pyproject.toml @git ls-files '*.toml' | xargs toml-sort --check lint-all: ## Run all linters - ${MAKE} isort + ${MAKE} ruff ${MAKE} lint-c ${MAKE} lint-rst ${MAKE} lint-toml @@ -223,9 +218,6 @@ lint-all: ## Run all linters fix-ruff: @git ls-files '*.py' | xargs $(PYTHON) -m ruff --config=pyproject.toml --no-cache --fix -fix-imports: ## Fix imports with isort. - @git ls-files '*.py' | xargs $(PYTHON) -m isort --jobs=${NUM_WORKERS} - fix-unittests: ## Fix unittest idioms. @git ls-files '*test_*.py' | xargs $(PYTHON) -m teyit --show-stats @@ -234,7 +226,6 @@ fix-toml: ## Fix pyproject.toml fix-all: ## Run all code fixers. ${MAKE} fix-ruff - ${MAKE} fix-imports ${MAKE} fix-unittests ${MAKE} fix-toml diff --git a/pyproject.toml b/pyproject.toml index b5875657b..d99de4271 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,9 +3,10 @@ target-version = "py37" line-length = 79 select = [ - "ALL", # to get a list of all values: `python3 -m ruff linter` - "D200", # [*] One-line docstring should fit on one line (pydocstyle) - "D204", # [*] 1 blank line required after class docstring (pydocstyle) + # To get a list of all values: `python3 -m ruff linter`. + "ALL", + "D200", # [*] One-line docstring should fit on one line + "D204", # [*] 1 blank line required after class docstring "D209", # [*] Multi-line docstring closing quotes should be on a separate line "D212", # [*] Multi-line docstring summary should start at the first line "D301", # Use `r"""` if any backslashes in a docstring @@ -22,7 +23,7 @@ ignore = [ "B904", # Within an `except` clause, raise exceptions with `raise ... from err` (PYTHON2.7 COMPAT) "BLE001", # Do not catch blind exception: `Exception` "C4", # flake8-comprehensions (PYTHON2.7 COMPAT) - # "C408", # Unnecessary `dict` call (rewrite as a literal) + "C408", # Unnecessary `dict` call (rewrite as a literal) "C90", # mccabe (function `X` is too complex) "COM812", # Trailing comma missing "D", # pydocstyle @@ -80,10 +81,6 @@ ignore = [ force-single-line = true # one import per line lines-after-imports = 2 -[tool.isort] -force_single_line = true # one import per line -lines_after_imports = 2 # blank spaces after import section - [tool.coverage.report] exclude_lines = [ "enum.IntEnum", diff --git a/scripts/internal/git_pre_commit.py b/scripts/internal/git_pre_commit.py index 5fefac8b6..92852f836 100755 --- a/scripts/internal/git_pre_commit.py +++ b/scripts/internal/git_pre_commit.py @@ -4,20 +4,10 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -"""This gets executed on 'git commit' and rejects the commit in case the -submitted code does not pass validation. Validation is run only against -the files which were modified in the commit. Checks: - -- assert no space at EOLs -- assert not pdb.set_trace in code -- assert no bare except clause ("except:") in code -- assert "isort" checks pass -- assert C linter checks pass -- assert RsT checks pass -- assert TOML checks pass -- abort if files were added/renamed/removed and MANIFEST.in was not updated - -Install this with "make install-git-hooks". +"""This gets executed on 'git commit' and rejects the commit in case +the submitted code does not pass validation. Validation is run only +against the files which were modified in the commit. Install this with +"make install-git-hooks". """ from __future__ import print_function @@ -116,15 +106,6 @@ def ruff(files): ) -def isort(files): - print("running isort (%s)" % len(files)) - cmd = [PYTHON, "-m", "isort", "--check-only"] + files - if subprocess.call(cmd) != 0: - msg = "python code didn't pass 'isort' style check; " - msg += "try running 'make fix-imports'" - return sys.exit(msg) - - def c_linter(files): print("running clinter (%s)" % len(files)) # XXX: we should escape spaces and possibly other amenities here @@ -151,7 +132,6 @@ def main(): py_files, c_files, rst_files, toml_files, new_rm_mv = git_commit_files() if py_files: ruff(py_files) - isort(py_files) if c_files: c_linter(c_files) if rst_files: diff --git a/scripts/internal/winmake.py b/scripts/internal/winmake.py index c2c20bc0a..cb039d02d 100755 --- a/scripts/internal/winmake.py +++ b/scripts/internal/winmake.py @@ -38,7 +38,6 @@ PYPY = '__pypy__' in sys.builtin_module_names DEPS = [ "coverage", - "nose", "pdbpp", "pip", "pyperf",