Skip to content

Commit

Permalink
Bump minimum Python version to 3.6 (jendrikseipp#218).
Browse files Browse the repository at this point in the history
  • Loading branch information
jendrikseipp authored Aug 7, 2020
1 parent b37d852 commit fe7d4a0
Show file tree
Hide file tree
Showing 21 changed files with 39 additions and 164 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,8 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [pypy3, 2.7, 3.5, 3.6, 3.7, 3.8]
python-version: [pypy3, 3.6, 3.7, 3.8]
os: [macos-10.15, ubuntu-18.04, ubuntu-20.04, windows-2019]
include:
- os: ubuntu-18.04
python-version: pypy2
- os: ubuntu-20.04
python-version: pypy2

steps:
- name: Checkout Code
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# unreleased

* Bump minimum Python version to 3.6 (Jendrik Seipp, #218).

# 1.6 (2020-07-28)

* Differentiate between functions and methods (Jendrik Seipp, #112, #209).
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ 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 2.7 and Python \>= 3.5
* supports Python \>= 3.6

## Installation

Expand Down
1 change: 0 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
disable=unused-import): unused-import, unused-variable, unused-argument
and possibly-unused-variable. See
https://github.com/janjur/readable-pylint-messages#unused-import.
* Drop Python 2.7 support.
* Parse type hints in comments.

# Non-TODOs
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[tool.black]
line-length = 79
# target-version = ['py27', 'py35', 'py36', 'py37', 'py38']
# target-version = ['py36', 'py37', 'py38']
include = '\.pyi?$'
exclude = '''
/(
Expand Down
5 changes: 1 addition & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ def find_version(*file_parts):
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
Expand All @@ -55,7 +52,7 @@ def find_version(*file_parts):
"Topic :: Software Development :: Quality Assurance",
],
entry_points={"console_scripts": ["vulture = vulture.core:main"]},
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*",
python_requires=">=3.6",
packages=setuptools.find_packages(exclude=["tests"]),
package_data={"vulture": ["whitelists/*.py"]},
)
6 changes: 0 additions & 6 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import ast
import glob
import os.path
import subprocess
Expand All @@ -12,11 +11,6 @@
REPO = os.path.dirname(DIR)
WHITELISTS = glob.glob(os.path.join(REPO, "vulture", "whitelists", "*.py"))

skip_if_not_has_async = pytest.mark.skipif(
not hasattr(ast, "AsyncFunctionDef"),
reason="needs async support (added in Python 3.5)",
)


def call_vulture(args, **kwargs):
return subprocess.call(
Expand Down
17 changes: 3 additions & 14 deletions tests/test_confidence.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import sys

from vulture import core
from . import skip_if_not_has_async

dc = core.DEFAULT_CONFIDENCE

Expand Down Expand Up @@ -43,16 +40,9 @@ def foo(a):
foo(5)
"""
if sys.version_info < (3, 0):
# Python 2
check_min_confidence(code, 50, {"a": dc, "b": dc})
check_min_confidence(code, dc, {"a": dc, "b": dc})
check_min_confidence(code, 100, {})
else:
# Python 3
check_min_confidence(code, 50, {"a": 100, "b": dc})
check_min_confidence(code, dc, {"a": 100, "b": dc})
check_min_confidence(code, 100, {"a": 100})
check_min_confidence(code, 50, {"a": 100, "b": dc})
check_min_confidence(code, dc, {"a": 100, "b": dc})
check_min_confidence(code, 100, {"a": 100})


def test_confidence_class():
Expand Down Expand Up @@ -83,7 +73,6 @@ def some_prop():
check_min_confidence(code, 100, {})


@skip_if_not_has_async
def test_confidence_async_def():
code = """\
async def foo():
Expand Down
9 changes: 4 additions & 5 deletions tests/test_encoding.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import codecs
import io

from . import v

Expand All @@ -8,7 +7,7 @@

def test_encoding1(v):
v.scan(
u"""\
"""\
# -*- coding: utf-8 -*-
pass
"""
Expand All @@ -18,7 +17,7 @@ def test_encoding1(v):

def test_encoding2(v):
v.scan(
u"""\
"""\
#! /usr/bin/env python
# -*- coding: utf-8 -*-
pass
Expand All @@ -42,7 +41,7 @@ def test_utf8_with_bom(v, tmpdir):
name = "utf8_bom"
filename = str(tmpdir.mkdir(name).join(name + ".py"))
# utf8_sig prepends the BOM to the file.
with io.open(filename, mode="w", encoding="utf-8-sig") as f:
f.write(u"")
with open(filename, mode="w", encoding="utf-8-sig") as f:
f.write("")
v.scavenge([f.name])
assert not v.found_dead_code_or_error
8 changes: 0 additions & 8 deletions tests/test_format_strings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import sys

import pytest

from . import check, v

assert v # Silence pyflakes.
Expand All @@ -17,10 +13,6 @@ def test_new_format_string(v):
check(v.used_names, ["a", "b", "c", "d", "locals"])


@pytest.mark.skipif(
sys.version_info < (3, 6),
reason="needs f-string support (added in Python 3.6)",
)
def test_f_string(v):
v.scan(
"""\
Expand Down
4 changes: 1 addition & 3 deletions tests/test_ignore.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from vulture import core

from . import check, skip_if_not_has_async
from . import check


def check_ignore(code, ignore_names, ignore_decorators, expected):
Expand Down Expand Up @@ -39,7 +39,6 @@ def bar():
check_ignore(code, ["foo*"], [], ["bar"])


@skip_if_not_has_async
def test_async_function():
code = """\
async def foobar():
Expand Down Expand Up @@ -130,7 +129,6 @@ def barfoo():
check_ignore(code, [], ["*decor", "@*f.foobar"], ["prop_one"])


@skip_if_not_has_async
def test_decorated_async_functions():
code = """\
@app.route('something')
Expand Down
2 changes: 1 addition & 1 deletion tests/test_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def bar():
"""
)
for item in v.get_unused_code():
assert repr(item) == "'{}'".format(item.name)
assert repr(item) == f"'{item.name}'"


def test_item_attr(v):
Expand Down
12 changes: 1 addition & 11 deletions tests/test_scavenging.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import sys

import pytest

from . import check, skip_if_not_has_async, v
from . import check, v

assert v # Silence pyflakes.

Expand Down Expand Up @@ -73,7 +69,6 @@ def foo(a):
check(v.defined_funcs, ["foo"])


@skip_if_not_has_async
def test_async_function(v):
v.scan(
"""\
Expand All @@ -85,7 +80,6 @@ async def foo():
check(v.unused_funcs, ["foo"])


@skip_if_not_has_async
def test_async_method(v):
v.scan(
"""\
Expand Down Expand Up @@ -451,7 +445,6 @@ class OtherClass:
check(v.unused_funcs, ["other_func"])


@skip_if_not_has_async
def test_async_function_name_in_test_file(v):
v.scan(
"""\
Expand All @@ -467,7 +460,6 @@ async def other_func():
check(v.unused_funcs, ["other_func"])


@skip_if_not_has_async
def test_async_function_name_in_normal_file(v):
v.scan(
"""\
Expand Down Expand Up @@ -620,7 +612,6 @@ def test_multiple_definition(v):
check(v.unused_vars, ["a", "a"])


@pytest.mark.skipif(sys.version_info < (3, 5), reason="requires Python 3.5+")
def test_arg_type_annotation(v):
v.scan(
"""\
Expand All @@ -636,7 +627,6 @@ def f(n: int) -> Iterable[int]:
check(v.unused_imports, [])


@pytest.mark.skipif(sys.version_info < (3, 6), reason="requires Python 3.6+")
def test_var_type_annotation(v):
v.scan(
"""\
Expand Down
13 changes: 1 addition & 12 deletions tests/test_size.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import ast
import sys

from vulture import lines

from . import skip_if_not_has_async


def get_last_line_number_slow(node):
"""
Expand Down Expand Up @@ -308,18 +305,13 @@ class Foo:
check_size(example, 2)


# We currently cannot handle code ending with an ellipsis on Python 2.
def test_size_ellipsis():
example = """
class Foo:
bar[1:2,
...]
"""
if sys.version_info < (3, 0):
check_size(example, 2)
else:
# ast.Ellipsis is a subclass of ast.expr in Python 3.
check_size(example, 3)
check_size(example, 3)


def test_size_starargs():
Expand All @@ -343,7 +335,6 @@ class Foo:
check_size(example, 2)


@skip_if_not_has_async
def test_size_async_function_def():
example = """
class Foo:
Expand All @@ -353,7 +344,6 @@ async def foo(some_attr):
check_size(example, 3)


@skip_if_not_has_async
def test_size_async_with():
example = """
class Foo:
Expand All @@ -364,7 +354,6 @@ async def bar():
check_size(example, 4)


@skip_if_not_has_async
def test_size_async_for():
example = """
class Foo:
Expand Down
3 changes: 0 additions & 3 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from vulture import utils

from . import skip_if_not_has_async


def check_decorator_names(code, expected_names):
decorator_names = []
Expand Down Expand Up @@ -38,7 +36,6 @@ def bar():
check_decorator_names(code, ["@xyz"])


@skip_if_not_has_async
def test_get_decorator_name_async():
code = """\
@foo.bar.route('/foobar')
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{27,35,36,37,38}, style
envlist = cleanup, py{36,37,38}, style
skip_missing_interpreters = true

# Erase old coverage results, then accumulate them during this tox run.
Expand Down Expand Up @@ -31,7 +31,7 @@ whitelist_externals =
commands =
black --check --diff .
flake8 setup.py tests/ vulture/
bash -c "pyupgrade `find dev/ tests/ vulture/ -name '*.py'` setup.py"
bash -c "pyupgrade --py36-plus `find dev/ tests/ vulture/ -name '*.py'` setup.py"

[testenv:fix-style]
basepython = python3
Expand All @@ -42,4 +42,4 @@ whitelist_externals =
bash
commands =
black .
bash -c "pyupgrade `find dev/ tests/ vulture/ -name '*.py'` setup.py"
bash -c "pyupgrade --py36-plus --exit-zero `find dev/ tests/ vulture/ -name '*.py'` setup.py"
Loading

0 comments on commit fe7d4a0

Please sign in to comment.