Skip to content

Commit

Permalink
get rid of isort
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Oct 4, 2023
1 parent c90bbd4 commit 4407cb6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 1 addition & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ PY3_DEPS = \
check-manifest \
concurrencytest \
coverage \
isort \
pep8-naming \
pylint \
pyperf \
pypinfo \
Expand Down Expand Up @@ -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}

Expand All @@ -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
Expand All @@ -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

Expand All @@ -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

Expand Down
13 changes: 5 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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",
Expand Down
28 changes: 4 additions & 24 deletions scripts/internal/git_pre_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down
1 change: 0 additions & 1 deletion scripts/internal/winmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
PYPY = '__pypy__' in sys.builtin_module_names
DEPS = [
"coverage",
"nose",
"pdbpp",
"pip",
"pyperf",
Expand Down

0 comments on commit 4407cb6

Please sign in to comment.