diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index c6772e953..000000000 --- a/.coveragerc +++ /dev/null @@ -1,32 +0,0 @@ -[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 NETBSD - if OPENBSD - if MACOS - if ppid_map is None: - if PY3: - if SUNOS - if sys.platform.startswith - if WINDOWS - import enum - pragma: no cover - raise NotImplementedError diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4c0ef79bd..e572b0297 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 diff --git a/.isort.cfg b/.isort.cfg deleted file mode 100644 index 58f66946c..000000000 --- a/.isort.cfg +++ /dev/null @@ -1,7 +0,0 @@ -# See: https://pycqa.github.io/isort/docs/configuration/options - -[settings] -# one import per line -force_single_line = true -# blank spaces after import section -lines_after_imports = 2 diff --git a/MANIFEST.in b/MANIFEST.in index c9cd85e99..e19c7e2de 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1,5 @@ -include .coveragerc include .flake8 include .gitignore -include .isort.cfg include CONTRIBUTING.md include CREDITS include HISTORY.rst @@ -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 diff --git a/Makefile b/Makefile index caf4c9e9d..fb7f89ae0 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ TSCRIPT = psutil/tests/runner.py # Internal. DEPS = \ - git+https://github.com/PyCQA/autoflake.git \ + autoflake \ autopep8 \ check-manifest \ concurrencytest \ @@ -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 @@ -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 diff --git a/psutil/_psposix.py b/psutil/_psposix.py index 39912d97e..1d250bf75 100644 --- a/psutil/_psposix.py +++ b/psutil/_psposix.py @@ -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 @@ -23,6 +23,7 @@ from ._compat import ProcessLookupError from ._compat import unicode + if MACOS: from . import _psutil_osx diff --git a/pyproject.toml b/pyproject.toml index 47031d268..52d4c7286 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" diff --git a/scripts/internal/git_pre_commit.py b/scripts/internal/git_pre_commit.py index 46b3bc533..877836272 100755 --- a/scripts/internal/git_pre_commit.py +++ b/scripts/internal/git_pre_commit.py @@ -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: