diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2020-02-18 23:46:35 +0100 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2020-02-18 23:46:35 +0100 |
commit | 9b8b843c9ae9aa7a07b551e3666f334ff9a1cb3d (patch) | |
tree | b47746ce408c81f4a9ba538cc7011a0131c18fb6 | |
parent | f76046d0211cf3dfe56721f74d0615cb3801f2aa (diff) | |
download | psutil-9b8b843c9ae9aa7a07b551e3666f334ff9a1cb3d.tar.gz |
integrate flake8 linter for print()
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | psutil/__init__.py | 4 | ||||
-rw-r--r-- | psutil/_common.py | 8 | ||||
-rw-r--r-- | psutil/tests/__init__.py | 2 |
4 files changed, 14 insertions, 8 deletions
@@ -11,6 +11,7 @@ DEPS = \ check-manifest \ coverage \ flake8 \ + flake8-print \ pyperf \ requests \ setuptools \ @@ -28,6 +29,11 @@ DEPS += `$(PYTHON) -c \ INSTALL_OPTS = `$(PYTHON) -c \ "import sys; print('' if hasattr(sys, 'real_prefix') else '--user')"` TEST_PREFIX = PYTHONWARNINGS=all PSUTIL_TESTING=1 PSUTIL_DEBUG=1 +FLAKE8_ARGS = --per-file-ignores='\ + setup.py:T001 \ + scripts/*:T001 \ + psutil/tests/runner.py:T001 \ + psutil/tests/test_memory_leaks.py:T001' all: test @@ -170,7 +176,7 @@ test-coverage: ## Run test coverage. # =================================================================== lint-py: ## Run Python (flake8) linter. - @git ls-files '*.py' | xargs $(PYTHON) -m flake8 + @git ls-files '*.py' | xargs $(PYTHON) -m flake8 $(FLAKE8_ARGS) lint-c: ## Run C linter. @git ls-files '*.c' '*.h' | xargs $(PYTHON) scripts/internal/clinter.py diff --git a/psutil/__init__.py b/psutil/__init__.py index 22bb46f3..2c5b4508 100644 --- a/psutil/__init__.py +++ b/psutil/__init__.py @@ -2348,7 +2348,7 @@ def test(): # pragma: no cover templ = "%-10s %5s %5s %7s %7s %5s %6s %6s %6s %s" attrs = ['pid', 'memory_percent', 'name', 'cmdline', 'cpu_times', 'create_time', 'memory_info', 'status', 'nice', 'username'] - print(templ % ("USER", "PID", "%MEM", "VSZ", "RSS", "NICE", + print(templ % ("USER", "PID", "%MEM", "VSZ", "RSS", "NICE", # NOQA "STATUS", "START", "TIME", "CMDLINE")) for p in process_iter(attrs, ad_value=None): if p.info['create_time']: @@ -2398,7 +2398,7 @@ def test(): # pragma: no cover ctime, cputime, cmdline) - print(line[:get_terminal_size()[0]]) + print(line[:get_terminal_size()[0]]) # NOQA del memoize, memoize_when_activated, division, deprecated_method diff --git a/psutil/_common.py b/psutil/_common.py index 17b6eeb3..8a39de7f 100644 --- a/psutil/_common.py +++ b/psutil/_common.py @@ -801,9 +801,9 @@ def hilite(s, color="green", bold=False): def print_color(s, color="green", bold=False, file=sys.stdout): """Print a colorized version of string.""" if not term_supports_colors(): - print(s, file=file) + print(s, file=file) # NOQA elif POSIX: - print(hilite(s, color, bold), file=file) + print(hilite(s, color, bold), file=file) # NOQA else: import ctypes @@ -827,7 +827,7 @@ def print_color(s, color="green", bold=False, file=sys.stdout): handle = GetStdHandle(handle_id) SetConsoleTextAttribute(handle, color) try: - print(s, file=file) + print(s, file=file) # NOQA finally: SetConsoleTextAttribute(handle, DEFAULT_COLOR) @@ -839,7 +839,7 @@ if bool(os.getenv('PSUTIL_DEBUG', 0)): """If PSUTIL_DEBUG env var is set, print a debug message to stderr.""" fname, lineno, func_name, lines, index = inspect.getframeinfo( inspect.currentframe().f_back) - print("psutil-debug [%s:%s]> %s" % (fname, lineno, msg), + print("psutil-debug [%s:%s]> %s" % (fname, lineno, msg), # NOQA file=sys.stderr) else: def debug(msg): diff --git a/psutil/tests/__init__.py b/psutil/tests/__init__.py index 3e4dc880..cd78fae6 100644 --- a/psutil/tests/__init__.py +++ b/psutil/tests/__init__.py @@ -819,7 +819,7 @@ def retry_on_failure(retries=NO_RETRIES): actually failing. """ def logfun(exc): - print("%r, retrying" % exc, file=sys.stderr) + print("%r, retrying" % exc, file=sys.stderr) # NOQA return retry(exception=AssertionError, timeout=None, retries=retries, logfun=logfun) |