From cb5d69d205db79f7b71b79f21edf449bb2d9806d Mon Sep 17 00:00:00 2001 From: johndoknjas Date: Sun, 21 Jul 2024 19:29:07 -0700 Subject: [PATCH 01/22] Add type hints for the `get_unused_code` function and `Item` fields. --- vulture/core.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/vulture/core.py b/vulture/core.py index b3c845cd..72e694a9 100644 --- a/vulture/core.py +++ b/vulture/core.py @@ -5,6 +5,7 @@ import re import string import sys +from typing import List from vulture import lines from vulture import noqa @@ -139,13 +140,13 @@ def __init__( message="", confidence=DEFAULT_CONFIDENCE, ): - self.name = name - self.typ = typ - self.filename = filename - self.first_lineno = first_lineno - self.last_lineno = last_lineno - self.message = message or f"unused {typ} '{name}'" - self.confidence = confidence + self.name: str = name + self.typ: str = typ + self.filename: Path = filename + self.first_lineno: int = first_lineno + self.last_lineno: int = last_lineno + self.message: str = message or f"unused {typ} '{name}'" + self.confidence: int = confidence @property def size(self): @@ -303,7 +304,9 @@ def exclude_path(path): module_string = module_data.decode("utf-8") self.scan(module_string, filename=path) - def get_unused_code(self, min_confidence=0, sort_by_size=False): + def get_unused_code( + self, min_confidence=0, sort_by_size=False + ) -> List[Item]: """ Return ordered list of unused Item objects. """ From f13f3becc9e8391afcd2bce2bcbab93d0895d662 Mon Sep 17 00:00:00 2001 From: johndoknjas Date: Mon, 22 Jul 2024 04:22:11 -0700 Subject: [PATCH 02/22] Add type tests for `Item`. --- tests/test_item.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/test_item.py b/tests/test_item.py index badba8a4..9648d739 100644 --- a/tests/test_item.py +++ b/tests/test_item.py @@ -1,4 +1,7 @@ +from pathlib import Path + from . import v +from vulture.core import Item assert v # Silence pyflakes @@ -99,3 +102,29 @@ def test_item_variable(v): assert var.name == "v" assert var.first_lineno == 1 assert var.last_lineno == 1 + + +def test_item_types(v): + v.scan( + """\ +import os + +message = "foobar" + +class Foo: + def bar(): + pass +""" + ) + for item in (unused_code := v.get_unused_code()): + assert isinstance(item, Item) + assert isinstance(item.filename, Path) + assert all( + isinstance(field, str) + for field in (item.name, item.typ, item.message) + ) + assert all( + isinstance(field, int) + for field in (item.first_lineno, item.last_lineno, item.confidence) + ) + assert isinstance(unused_code, list) From b67c8e59b8b4e0468c02fbf1bea3ed64a88803b1 Mon Sep 17 00:00:00 2001 From: johndoknjas Date: Mon, 22 Jul 2024 06:14:12 -0700 Subject: [PATCH 03/22] Add a test that runs mypy with some error codes disabled. --- tests/test_item.py | 29 ----------------------------- tests/test_mypy.py | 21 +++++++++++++++++++++ tox.ini | 1 + vulture/core.py | 1 + 4 files changed, 23 insertions(+), 29 deletions(-) create mode 100644 tests/test_mypy.py diff --git a/tests/test_item.py b/tests/test_item.py index 9648d739..badba8a4 100644 --- a/tests/test_item.py +++ b/tests/test_item.py @@ -1,7 +1,4 @@ -from pathlib import Path - from . import v -from vulture.core import Item assert v # Silence pyflakes @@ -102,29 +99,3 @@ def test_item_variable(v): assert var.name == "v" assert var.first_lineno == 1 assert var.last_lineno == 1 - - -def test_item_types(v): - v.scan( - """\ -import os - -message = "foobar" - -class Foo: - def bar(): - pass -""" - ) - for item in (unused_code := v.get_unused_code()): - assert isinstance(item, Item) - assert isinstance(item.filename, Path) - assert all( - isinstance(field, str) - for field in (item.name, item.typ, item.message) - ) - assert all( - isinstance(field, int) - for field in (item.first_lineno, item.last_lineno, item.confidence) - ) - assert isinstance(unused_code, list) diff --git a/tests/test_mypy.py b/tests/test_mypy.py new file mode 100644 index 00000000..ee1d49f5 --- /dev/null +++ b/tests/test_mypy.py @@ -0,0 +1,21 @@ +import mypy.api + + +def test_mypy(): + result = mypy.api.run( + [ + "--check-untyped-defs", + "--ignore-missing-imports", + "--disable-error-code", + "truthy-function", + "--disable-error-code", + "no-redef", + "--disable-error-code", + "attr-defined", + "--disable-error-code", + "misc", + "./vulture", + ] + ) + assert result[0].startswith("Success: no issues found in ") + assert result[1:] == ("", 0) diff --git a/tox.ini b/tox.ini index 4ca649a9..04b1a2b1 100644 --- a/tox.ini +++ b/tox.ini @@ -15,6 +15,7 @@ deps = pint # Use latest version to catch API changes. pytest==7.4.2 pytest-cov==4.0.0 + mypy==1.11.0 commands = pytest {posargs} # Install package as wheel in all envs (https://hynek.me/articles/turbo-charge-tox/). diff --git a/vulture/core.py b/vulture/core.py index 72e694a9..58bf1b34 100644 --- a/vulture/core.py +++ b/vulture/core.py @@ -301,6 +301,7 @@ def exclude_path(path): except OSError: # Most imported modules don't have a whitelist. continue + assert module_data is not None module_string = module_data.decode("utf-8") self.scan(module_string, filename=path) From 2906201c8b8d10283fe5a333bb0a3ca8b3a9e5a4 Mon Sep 17 00:00:00 2001 From: johndoknjas Date: Wed, 2 Oct 2024 05:29:45 -0700 Subject: [PATCH 04/22] Replace mypy with pytype. --- tests/test_mypy.py | 21 --------------------- tests/test_pytype.py | 9 +++++++++ tox.ini | 2 +- 3 files changed, 10 insertions(+), 22 deletions(-) delete mode 100644 tests/test_mypy.py create mode 100644 tests/test_pytype.py diff --git a/tests/test_mypy.py b/tests/test_mypy.py deleted file mode 100644 index ee1d49f5..00000000 --- a/tests/test_mypy.py +++ /dev/null @@ -1,21 +0,0 @@ -import mypy.api - - -def test_mypy(): - result = mypy.api.run( - [ - "--check-untyped-defs", - "--ignore-missing-imports", - "--disable-error-code", - "truthy-function", - "--disable-error-code", - "no-redef", - "--disable-error-code", - "attr-defined", - "--disable-error-code", - "misc", - "./vulture", - ] - ) - assert result[0].startswith("Success: no issues found in ") - assert result[1:] == ("", 0) diff --git a/tests/test_pytype.py b/tests/test_pytype.py new file mode 100644 index 00000000..6c38b8f6 --- /dev/null +++ b/tests/test_pytype.py @@ -0,0 +1,9 @@ +import subprocess +from subprocess import PIPE + +def test_pytype(): + result = subprocess.run( + ['pytype', 'vulture/core.py', '--disable=attribute-error'], + stdout=PIPE, stderr=PIPE, universal_newlines=True + ) + assert result.stdout.strip().endswith('Success: no errors found') \ No newline at end of file diff --git a/tox.ini b/tox.ini index 04b1a2b1..ff16a568 100644 --- a/tox.ini +++ b/tox.ini @@ -15,7 +15,7 @@ deps = pint # Use latest version to catch API changes. pytest==7.4.2 pytest-cov==4.0.0 - mypy==1.11.0 + pytype==2024.9.13 commands = pytest {posargs} # Install package as wheel in all envs (https://hynek.me/articles/turbo-charge-tox/). From 1e1cdcea5abc94aee0b9c7791448a4c770394535 Mon Sep 17 00:00:00 2001 From: johndoknjas Date: Wed, 2 Oct 2024 05:59:04 -0700 Subject: [PATCH 05/22] Satisfy black and ruff. --- tests/test_pytype.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/test_pytype.py b/tests/test_pytype.py index 6c38b8f6..5ac86a78 100644 --- a/tests/test_pytype.py +++ b/tests/test_pytype.py @@ -1,9 +1,10 @@ import subprocess -from subprocess import PIPE + def test_pytype(): result = subprocess.run( - ['pytype', 'vulture/core.py', '--disable=attribute-error'], - stdout=PIPE, stderr=PIPE, universal_newlines=True + ["pytype", "vulture/core.py", "--disable=attribute-error"], + capture_output=True, + text=True, ) - assert result.stdout.strip().endswith('Success: no errors found') \ No newline at end of file + assert result.stdout.strip().endswith("Success: no errors found") From 7a0498c26bb9a3d8853adbabe70cb800cbd79884 Mon Sep 17 00:00:00 2001 From: johndoknjas Date: Wed, 2 Oct 2024 06:11:29 -0700 Subject: [PATCH 06/22] Add version number back in for pytype. --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 9318ed13..5b84ae87 100644 --- a/tox.ini +++ b/tox.ini @@ -15,7 +15,7 @@ deps = pint # Use latest version to catch API changes. pytest pytest-cov - pytype + pytype==2024.9.13 commands = pytest {posargs} # Install package as wheel in all envs (https://hynek.me/articles/turbo-charge-tox/). From 6ce5dbf4c1287404ca97627457b964c52db39699 Mon Sep 17 00:00:00 2001 From: johndoknjas Date: Thu, 3 Oct 2024 03:31:00 -0700 Subject: [PATCH 07/22] Remove version number for pytype. --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 5b84ae87..9318ed13 100644 --- a/tox.ini +++ b/tox.ini @@ -15,7 +15,7 @@ deps = pint # Use latest version to catch API changes. pytest pytest-cov - pytype==2024.9.13 + pytype commands = pytest {posargs} # Install package as wheel in all envs (https://hynek.me/articles/turbo-charge-tox/). From 6bc297f480f28bc8da13dad8d25a74fb471ed200 Mon Sep 17 00:00:00 2001 From: johndoknjas Date: Thu, 3 Oct 2024 04:07:16 -0700 Subject: [PATCH 08/22] Only run pytype for python < 3.13. --- tests/test_pytype.py | 5 +++++ tox.ini | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_pytype.py b/tests/test_pytype.py index 5ac86a78..727bf74b 100644 --- a/tests/test_pytype.py +++ b/tests/test_pytype.py @@ -1,6 +1,11 @@ import subprocess +import sys +import pytest +@pytest.mark.skipif( + sys.version_info >= (3, 13), reason="Need python < 3.13 for pytype" +) def test_pytype(): result = subprocess.run( ["pytype", "vulture/core.py", "--disable=attribute-error"], diff --git a/tox.ini b/tox.ini index 9318ed13..357c410b 100644 --- a/tox.ini +++ b/tox.ini @@ -15,7 +15,7 @@ deps = pint # Use latest version to catch API changes. pytest pytest-cov - pytype + pytype ; python_version < '3.13' commands = pytest {posargs} # Install package as wheel in all envs (https://hynek.me/articles/turbo-charge-tox/). From ac165f02a516397450d86c4fe1652830c0638bd6 Mon Sep 17 00:00:00 2001 From: johndoknjas Date: Thu, 3 Oct 2024 20:21:24 -0700 Subject: [PATCH 09/22] Run pytype directly in tox.ini. --- tests/test_pytype.py | 15 --------------- tox.ini | 1 + 2 files changed, 1 insertion(+), 15 deletions(-) delete mode 100644 tests/test_pytype.py diff --git a/tests/test_pytype.py b/tests/test_pytype.py deleted file mode 100644 index 727bf74b..00000000 --- a/tests/test_pytype.py +++ /dev/null @@ -1,15 +0,0 @@ -import subprocess -import sys -import pytest - - -@pytest.mark.skipif( - sys.version_info >= (3, 13), reason="Need python < 3.13 for pytype" -) -def test_pytype(): - result = subprocess.run( - ["pytype", "vulture/core.py", "--disable=attribute-error"], - capture_output=True, - text=True, - ) - assert result.stdout.strip().endswith("Success: no errors found") diff --git a/tox.ini b/tox.ini index 357c410b..c22c6c05 100644 --- a/tox.ini +++ b/tox.ini @@ -18,6 +18,7 @@ deps = pytype ; python_version < '3.13' commands = pytest {posargs} + pytype vulture/core.py ; python_version < '3.13' # Install package as wheel in all envs (https://hynek.me/articles/turbo-charge-tox/). package = wheel wheel_build_env = .pkg From ce6aed18daf226d55aea6a0eb230f68dc055e460 Mon Sep 17 00:00:00 2001 From: johndoknjas Date: Thu, 3 Oct 2024 20:26:32 -0700 Subject: [PATCH 10/22] Initialize the `noqa_lines` field in the constructor. --- vulture/core.py | 1 + 1 file changed, 1 insertion(+) diff --git a/vulture/core.py b/vulture/core.py index 58bf1b34..2cadabb6 100644 --- a/vulture/core.py +++ b/vulture/core.py @@ -220,6 +220,7 @@ def get_list(typ): self.filename = Path() self.code = [] self.exit_code = ExitCode.NoDeadCode + self.noqa_lines = {} def scan(self, code, filename=""): filename = Path(filename) From 89477ed3b3603ed178a41ec7eaf0cf94c51b68a8 Mon Sep 17 00:00:00 2001 From: johndoknjas Date: Thu, 3 Oct 2024 20:47:37 -0700 Subject: [PATCH 11/22] Try a different syntax for conditional statements in commands. --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index c22c6c05..ed582b3d 100644 --- a/tox.ini +++ b/tox.ini @@ -18,7 +18,7 @@ deps = pytype ; python_version < '3.13' commands = pytest {posargs} - pytype vulture/core.py ; python_version < '3.13' + ["$PYTHON_VERSION" -lt "3.13"] && pytype vulture/core.py # Install package as wheel in all envs (https://hynek.me/articles/turbo-charge-tox/). package = wheel wheel_build_env = .pkg From a8dcb91702fbbaa3a9665790236658216c7adc81 Mon Sep 17 00:00:00 2001 From: johndoknjas Date: Thu, 3 Oct 2024 21:24:52 -0700 Subject: [PATCH 12/22] Try a different syntax. --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index ed582b3d..76c19b37 100644 --- a/tox.ini +++ b/tox.ini @@ -18,7 +18,7 @@ deps = pytype ; python_version < '3.13' commands = pytest {posargs} - ["$PYTHON_VERSION" -lt "3.13"] && pytype vulture/core.py + py{38,310,311,312}: pytype vulture/core.py # Install package as wheel in all envs (https://hynek.me/articles/turbo-charge-tox/). package = wheel wheel_build_env = .pkg From 54ef88c22f0c1ad9fcc00cb8a08a1e21aaab2033 Mon Sep 17 00:00:00 2001 From: johndoknjas Date: Thu, 3 Oct 2024 21:28:47 -0700 Subject: [PATCH 13/22] test --- vulture/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vulture/core.py b/vulture/core.py index 2cadabb6..ec4a422f 100644 --- a/vulture/core.py +++ b/vulture/core.py @@ -140,7 +140,7 @@ def __init__( message="", confidence=DEFAULT_CONFIDENCE, ): - self.name: str = name + self.name: int = name self.typ: str = typ self.filename: Path = filename self.first_lineno: int = first_lineno From cfac81624189c5919b1d7d9bbf2494cf057c8f07 Mon Sep 17 00:00:00 2001 From: johndoknjas Date: Thu, 3 Oct 2024 21:44:08 -0700 Subject: [PATCH 14/22] See if adding `postargs` helps. --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 76c19b37..c268f579 100644 --- a/tox.ini +++ b/tox.ini @@ -18,7 +18,7 @@ deps = pytype ; python_version < '3.13' commands = pytest {posargs} - py{38,310,311,312}: pytype vulture/core.py + py{38,310,311,312}: pytype vulture/core.py {posargs} # Install package as wheel in all envs (https://hynek.me/articles/turbo-charge-tox/). package = wheel wheel_build_env = .pkg From 3344912439ac9d1a5f1d3d7d10ac8b87138eb248 Mon Sep 17 00:00:00 2001 From: johndoknjas Date: Thu, 3 Oct 2024 21:47:13 -0700 Subject: [PATCH 15/22] Test just py311 --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index c268f579..4aaec165 100644 --- a/tox.ini +++ b/tox.ini @@ -18,7 +18,7 @@ deps = pytype ; python_version < '3.13' commands = pytest {posargs} - py{38,310,311,312}: pytype vulture/core.py {posargs} + py311: pytype vulture/core.py {posargs} # Install package as wheel in all envs (https://hynek.me/articles/turbo-charge-tox/). package = wheel wheel_build_env = .pkg From dcf4b87f853fb776ddf697ae1a05bca6f42a5463 Mon Sep 17 00:00:00 2001 From: johndoknjas Date: Thu, 3 Oct 2024 21:55:49 -0700 Subject: [PATCH 16/22] remove py311 --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 4aaec165..e421f386 100644 --- a/tox.ini +++ b/tox.ini @@ -18,7 +18,7 @@ deps = pytype ; python_version < '3.13' commands = pytest {posargs} - py311: pytype vulture/core.py {posargs} + pytype vulture/core.py {posargs} # Install package as wheel in all envs (https://hynek.me/articles/turbo-charge-tox/). package = wheel wheel_build_env = .pkg From 6e8735eb2a88fec22e0175835168b3ffed621f3c Mon Sep 17 00:00:00 2001 From: johndoknjas Date: Thu, 3 Oct 2024 22:02:54 -0700 Subject: [PATCH 17/22] different syntax mentioned in docs --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index e421f386..c57c20ef 100644 --- a/tox.ini +++ b/tox.ini @@ -15,10 +15,10 @@ deps = pint # Use latest version to catch API changes. pytest pytest-cov - pytype ; python_version < '3.13' + py38,py310,py311,py312: pytype commands = - pytest {posargs} pytype vulture/core.py {posargs} + pytest {posargs} # Install package as wheel in all envs (https://hynek.me/articles/turbo-charge-tox/). package = wheel wheel_build_env = .pkg From 3074a3a46123483334b17902dc513a091ce06bfb Mon Sep 17 00:00:00 2001 From: johndoknjas Date: Thu, 3 Oct 2024 22:11:34 -0700 Subject: [PATCH 18/22] Revert attempted changes to call `pytype` directly. --- tests/test_pytype.py | 15 +++++++++++++++ tox.ini | 3 +-- vulture/core.py | 3 +-- 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 tests/test_pytype.py diff --git a/tests/test_pytype.py b/tests/test_pytype.py new file mode 100644 index 00000000..727bf74b --- /dev/null +++ b/tests/test_pytype.py @@ -0,0 +1,15 @@ +import subprocess +import sys +import pytest + + +@pytest.mark.skipif( + sys.version_info >= (3, 13), reason="Need python < 3.13 for pytype" +) +def test_pytype(): + result = subprocess.run( + ["pytype", "vulture/core.py", "--disable=attribute-error"], + capture_output=True, + text=True, + ) + assert result.stdout.strip().endswith("Success: no errors found") diff --git a/tox.ini b/tox.ini index c57c20ef..357c410b 100644 --- a/tox.ini +++ b/tox.ini @@ -15,9 +15,8 @@ deps = pint # Use latest version to catch API changes. pytest pytest-cov - py38,py310,py311,py312: pytype + pytype ; python_version < '3.13' commands = - pytype vulture/core.py {posargs} pytest {posargs} # Install package as wheel in all envs (https://hynek.me/articles/turbo-charge-tox/). package = wheel diff --git a/vulture/core.py b/vulture/core.py index ec4a422f..58bf1b34 100644 --- a/vulture/core.py +++ b/vulture/core.py @@ -140,7 +140,7 @@ def __init__( message="", confidence=DEFAULT_CONFIDENCE, ): - self.name: int = name + self.name: str = name self.typ: str = typ self.filename: Path = filename self.first_lineno: int = first_lineno @@ -220,7 +220,6 @@ def get_list(typ): self.filename = Path() self.code = [] self.exit_code = ExitCode.NoDeadCode - self.noqa_lines = {} def scan(self, code, filename=""): filename = Path(filename) From 9415be75a98de75df9d47db2874ce7490e1e396e Mon Sep 17 00:00:00 2001 From: johndoknjas Date: Fri, 4 Oct 2024 00:30:54 -0700 Subject: [PATCH 19/22] Apply PR feedback (includes defining `self.noqa_lines` in the constructor and checking whether the pytype exit code is 0). --- tests/test_pytype.py | 6 ++++-- vulture/core.py | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/test_pytype.py b/tests/test_pytype.py index 727bf74b..eb6490d5 100644 --- a/tests/test_pytype.py +++ b/tests/test_pytype.py @@ -1,15 +1,17 @@ import subprocess import sys + import pytest @pytest.mark.skipif( - sys.version_info >= (3, 13), reason="Need python < 3.13 for pytype" + sys.version_info >= (3, 13), reason="needs Python < 3.13 for pytype" ) def test_pytype(): result = subprocess.run( - ["pytype", "vulture/core.py", "--disable=attribute-error"], + ["pytype", "vulture/core.py"], capture_output=True, text=True, + check=True, ) assert result.stdout.strip().endswith("Success: no errors found") diff --git a/vulture/core.py b/vulture/core.py index 58bf1b34..2cadabb6 100644 --- a/vulture/core.py +++ b/vulture/core.py @@ -220,6 +220,7 @@ def get_list(typ): self.filename = Path() self.code = [] self.exit_code = ExitCode.NoDeadCode + self.noqa_lines = {} def scan(self, code, filename=""): filename = Path(filename) From 4334ca67d48209e89671119958f6ad9a0a088fed Mon Sep 17 00:00:00 2001 From: johndoknjas Date: Tue, 8 Oct 2024 08:20:20 -0700 Subject: [PATCH 20/22] Update changelog. --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a944eb1..eef612b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# next (unreleased) + +* Add typehints for `get_unused_code` and the fields of the `Item` class (John Doknjas, #361). + # 2.13 (2024-10-02) * Add support for Python 3.13 (Jendrik Seipp, #369). From c27055db0adade0392d438f38b1a19f1533498f2 Mon Sep 17 00:00:00 2001 From: johndoknjas Date: Tue, 8 Oct 2024 08:33:21 -0700 Subject: [PATCH 21/22] Update the readme. --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 45bb3c44..9746153b 100644 --- a/README.md +++ b/README.md @@ -191,6 +191,16 @@ Vulture will automatically look for a `pyproject.toml` in the current working di To use a `pyproject.toml` in another directory, you can use the `--config path/to/pyproject.toml` flag. +It's also possible to use vulture programatically. For example: + +``` python +import vulture + +v = vulture.Vulture() +v.scavenge(['.']) +unused_code = v.get_unused_code() # returns a list of `Item` objects +``` + ## Integrations You can use a [pre-commit](https://pre-commit.com/#install) hook to run From b7c0f8981d714bca22cf794a22bfdb0c0479e228 Mon Sep 17 00:00:00 2001 From: johndoknjas Date: Tue, 8 Oct 2024 10:19:21 -0700 Subject: [PATCH 22/22] For the pytype test, just check that the return code is 0. --- tests/test_pytype.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/tests/test_pytype.py b/tests/test_pytype.py index eb6490d5..8ee01c0b 100644 --- a/tests/test_pytype.py +++ b/tests/test_pytype.py @@ -8,10 +8,4 @@ sys.version_info >= (3, 13), reason="needs Python < 3.13 for pytype" ) def test_pytype(): - result = subprocess.run( - ["pytype", "vulture/core.py"], - capture_output=True, - text=True, - check=True, - ) - assert result.stdout.strip().endswith("Success: no errors found") + assert subprocess.run(["pytype", "vulture/core.py"]).returncode == 0