Skip to content

Commit

Permalink
Drop Python 3.7 support. (#323)
Browse files Browse the repository at this point in the history
* Remove Python 3.7 tests.
* Remove special-case code for old Python versions.
  • Loading branch information
jendrikseipp authored Aug 31, 2023
1 parent 8086121 commit 7d8580a
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11']

steps:
- name: Checkout code
Expand All @@ -30,7 +30,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade build coveralls setuptools tox==4.8.0 wheel
python -m pip install --upgrade build coveralls setuptools tox wheel
- name: Build Vulture wheel
run: python -m build
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2.10 (unreleased)

* Drop support for Python 3.7 (Jendrik Seipp).

# 2.9.1 (2023-08-21)

* Use exit code 0 for `--help` and `--version` again (Jendrik Seipp, #321).
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ tool for higher code quality.
* tested: tests itself and has complete test coverage
* complements pyflakes and has the same output syntax
* sorts unused classes and functions by size with `--sort-by-size`
* supports Python \>= 3.7

## Installation

Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def find_version(*parts):
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
Expand All @@ -49,7 +48,7 @@ def find_version(*parts):
],
install_requires=["toml"],
entry_points={"console_scripts": ["vulture = vulture.core:main"]},
python_requires=">=3.7",
python_requires=">=3.8",
packages=setuptools.find_packages(exclude=["tests"]),
package_data={"vulture": ["whitelists/*.py"]},
)
12 changes: 3 additions & 9 deletions tests/test_scavenging.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,11 +762,8 @@ def __init__(self):
"""
)

if sys.version_info < (3, 8):
check(v.unused_imports, ["Any", "Dict", "List", "Text", "Tuple"])
else:
check(v.unused_imports, [])
assert v.exit_code == ExitCode.NoDeadCode
check(v.unused_imports, [])
assert v.exit_code == ExitCode.NoDeadCode


def test_invalid_type_comment(v):
Expand All @@ -779,10 +776,7 @@ def bad():
"""
)

if sys.version_info < (3, 8):
assert v.exit_code == ExitCode.NoDeadCode
else:
assert v.exit_code == ExitCode.InvalidInput
assert v.exit_code == ExitCode.InvalidInput


def test_unused_args_with_del(v):
Expand Down
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = cleanup, py{37,38,310,311}, style # Skip py39 since it chokes on distutils.
envlist = cleanup, py{38,310,311}, style # Skip py39 since it chokes on distutils.
skip_missing_interpreters = true

# Erase old coverage results, then accumulate them during this tox run.
Expand Down Expand Up @@ -42,7 +42,7 @@ commands =
# B028: use !r conversion flag
# C408: unnecessary dict call
flake8 --extend-ignore=B028,C408 setup.py tests/ vulture/
bash -c "pyupgrade --py37-plus `find dev/ tests/ vulture/ -name '*.py'` setup.py"
bash -c "pyupgrade --py38-plus `find dev/ tests/ vulture/ -name '*.py'` setup.py"

[testenv:fix-style]
basepython = python3
Expand All @@ -53,4 +53,4 @@ allowlist_externals =
bash
commands =
black .
bash -c "pyupgrade --py37-plus --exit-zero `find dev/ tests/ vulture/ -name '*.py'` setup.py"
bash -c "pyupgrade --py38-plus --exit-zero `find dev/ tests/ vulture/ -name '*.py'` setup.py"
8 changes: 2 additions & 6 deletions vulture/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,8 @@ def handle_syntax_error(e):
self.exit_code = ExitCode.InvalidInput

try:
node = (
ast.parse(
code, filename=str(self.filename), type_comments=True
)
if sys.version_info >= (3, 8) # type_comments requires 3.8+
else ast.parse(code, filename=str(self.filename))
node = ast.parse(
code, filename=str(self.filename), type_comments=True
)
except SyntaxError as err:
handle_syntax_error(err)
Expand Down
8 changes: 3 additions & 5 deletions vulture/lines.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import ast
import sys


def _get_last_child_with_lineno(node):
Expand Down Expand Up @@ -76,8 +75,7 @@ def get_first_line_number(node):
also don't need it's decorators), we return the lineno of the first
decorator, if there are any.
"""
if sys.version_info >= (3, 8):
decorators = getattr(node, "decorator_list", [])
if decorators:
return decorators[0].lineno
decorators = getattr(node, "decorator_list", [])
if decorators:
return decorators[0].lineno
return node.lineno

0 comments on commit 7d8580a

Please sign in to comment.