Skip to content

Commit

Permalink
move isort and coverage config into pyproject.toml
Browse files Browse the repository at this point in the history
...since pyproject.toml was introduced in #2040. CC @mayeut

Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
  • Loading branch information
giampaolo committed Oct 18, 2022
1 parent 4354b4e commit 8ad2d5b
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 48 deletions.
32 changes: 0 additions & 32 deletions .coveragerc

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,6 @@ jobs:
# py3
python3 -m pip install flake8 isort
python3 -m flake8 .
python3 -m isort --settings=.isort.cfg .
python3 -m isort .
# clinter
find . -type f \( -iname "*.c" -o -iname "*.h" \) | xargs python3 scripts/internal/clinter.py
7 changes: 0 additions & 7 deletions .isort.cfg

This file was deleted.

3 changes: 1 addition & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
include .coveragerc
include .flake8
include .gitignore
include .isort.cfg
include CONTRIBUTING.md
include CREDITS
include HISTORY.rst
Expand Down Expand Up @@ -123,6 +121,7 @@ include psutil/tests/test_system.py
include psutil/tests/test_testutils.py
include psutil/tests/test_unicode.py
include psutil/tests/test_windows.py
include pyproject.toml
include scripts/battery.py
include scripts/cpu_distribution.py
include scripts/disk_usage.py
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ TSCRIPT = psutil/tests/runner.py

# Internal.
DEPS = \
git+https://github.com/PyCQA/autoflake.git \
autoflake \
autopep8 \
check-manifest \
concurrencytest \
Expand Down Expand Up @@ -195,7 +195,7 @@ flake8: ## Run flake8 linter.
@git ls-files '*.py' | xargs $(PYTHON) -m flake8 --config=.flake8

isort: ## Run isort linter.
@git ls-files '*.py' | xargs $(PYTHON) -m isort --settings=.isort.cfg --check-only
@git ls-files '*.py' | xargs $(PYTHON) -m isort --check-only

c-linter: ## Run C linter.
@git ls-files '*.c' '*.h' | xargs $(PYTHON) scripts/internal/clinter.py
Expand All @@ -214,7 +214,7 @@ fix-flake8: ## Run autopep8, fix some Python flake8 / pep8 issues.
@git ls-files '*.py' | xargs $(PYTHON) -m autoflake --in-place --jobs 0 --remove-all-unused-imports --remove-unused-variables --remove-duplicate-keys

fix-imports: ## Fix imports with isort.
@git ls-files '*.py' | xargs $(PYTHON) -m isort --settings=.isort.cfg
@git ls-files '*.py' | xargs $(PYTHON) -m isort

fix-all: ## Run all code fixers.
${MAKE} fix-flake8
Expand Down
3 changes: 2 additions & 1 deletion psutil/_psposix.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
import sys
import time

from ._common import MACOS
from ._common import TimeoutExpired
from ._common import memoize
from ._common import sdiskusage
from ._common import usage_percent
from ._common import MACOS
from ._compat import PY3
from ._compat import ChildProcessError
from ._compat import FileNotFoundError
Expand All @@ -23,6 +23,7 @@
from ._compat import ProcessLookupError
from ._compat import unicode


if MACOS:
from . import _psutil_osx

Expand Down
39 changes: 39 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,42 @@
[tool.isort]
force_single_line = true # one import per line
lines_after_imports = 2 # blank spaces after import section

[tool.coverage.report]
include = [
"*psutil*"
]
omit = [
"psutil/_compat.py",
"psutil/tests/*",
"setup.py",
]
exclude_lines = [
"enum.IntEnum",
"except ImportError:",
"globals().update",
"if __name__ == .__main__.:",
"if _WINDOWS:",
"if BSD",
"if enum is None:",
"if enum is not None:",
"if FREEBSD",
"if has_enums:",
"if LINUX",
"if LITTLE_ENDIAN:",
"if MACOS",
"if NETBSD",
"if OPENBSD",
"if ppid_map is None:",
"if PY3:",
"if SUNOS",
"if sys.platform.startswith",
"if WINDOWS",
"import enum",
"pragma: no cover",
"raise NotImplementedError",
]

[build-system]
requires = ["setuptools>=43"]
build-backend = "setuptools.build_meta"
Expand Down
3 changes: 1 addition & 2 deletions scripts/internal/git_pre_commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ def main():
return exit("python code didn't pass 'flake8' style check; "
"try running 'make fix-flake8'")
# isort
assert os.path.exists('.isort.cfg')
cmd = "%s -m isort --settings=.isort.cfg --check-only %s" % (
cmd = "%s -m isort --check-only %s" % (
PYTHON, " ".join(py_files))
ret = subprocess.call(shlex.split(cmd))
if ret != 0:
Expand Down

0 comments on commit 8ad2d5b

Please sign in to comment.