Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop support for python 2.7, 3.4, and 3.5 #376

Merged
merged 16 commits into from
Feb 6, 2021
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 1 addition & 22 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ jobs:
fail-fast: false
matrix:
os: [Ubuntu, Windows, macOS]
# Python 3.4 is not available from actions/setup-python@v2.
python_version:
["2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "pypy2", "pypy3"]
["3.6", "3.7", "3.8", "3.9", "pypy3"]
exclude:
# This is failing due to pip not being in the virtual environment.
# https://github.com/pypa/packaging/runs/424785871#step:7:9
Expand All @@ -35,26 +34,6 @@ jobs:
with:
python-version: ${{ matrix.python_version }}

# Set `python` to a recent 3.x version if we're not testing Python 3.6+.
# Why? Nox needs Python 3.5+ and everyone likes f-strings.
- uses: actions/setup-python@v2
name: Install Python 3.x
with:
python-version: 3.x
if: >
(
matrix.python_version == '2.7' ||
matrix.python_version == 'pypy2' ||
matrix.python_version == '3.5'
)

# Workaround https://github.com/theacodes/nox/issues/250
- name: Workaround for Windows Python 2.7
# This is in PATH, so nox resolves to it - but then subsequent steps fail.
run: rm C:/ProgramData/Chocolatey/bin/python2.7.exe
shell: bash
if: runner.os == 'Windows' && matrix.python_version == '2.7'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
4 changes: 0 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ repos:
- id: mypy
exclude: '^(docs|tasks|tests)|setup\.py'
args: []
- id: mypy
name: mypy for Python 2
exclude: '^(docs|tasks|tests)|setup\.py|noxfile\.py'
args: ["--py2"]

- repo: https://github.com/psf/black
rev: 19.3b0
Expand Down
8 changes: 0 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,8 @@ python: 3.8

matrix:
include:
- python: 2.7
env: NOXSESSION=tests-2.7
- python: pypy
env: NOXSESSION=tests-pypy
- python: pypy3
env: NOXSESSION=tests-pypy3
- python: 3.4
env: NOXSESSION=tests-3.4
- python: 3.5
env: NOXSESSION=tests-3.5
- python: 3.6
env: NOXSESSION=tests-3.6
- python: 3.7
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Changelog
*unreleased*
~~~~~~~~~~~~

No unreleased changes.
* Drop support for python 2.7, 3.4, and 3.5.
jdufresne marked this conversation as resolved.
Show resolved Hide resolved

20.9 - 2021-01-29
~~~~~~~~~~~~~~~~~
Expand Down
2 changes: 0 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
# This file is dual licensed under the terms of the Apache License, Version
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
# for complete details.
from __future__ import absolute_import, division, print_function

import os
import sys
Expand Down
5 changes: 1 addition & 4 deletions docs/development/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,10 @@ each supported Python version and run the tests. For example:
$ nox -s tests
...
nox > Ran multiple sessions:
nox > * tests-2.7: success
nox > * tests-3.4: skipped
nox > * tests-3.5: success
nox > * tests-3.6: success
nox > * tests-3.7: success
nox > * tests-3.8: success
nox > * tests-pypy: skipped
nox > * tests-3.9: success
nox > * tests-pypy3: skipped

You may not have all the required Python versions installed, in which case you
Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
nox.options.reuse_existing_virtualenvs = True


@nox.session(python=["2.7", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "pypy", "pypy3"])
@nox.session(python=["3.6", "3.7", "3.8", "3.9", "pypy3"])
def tests(session):
def coverage(*args):
session.run("python", "-m", "coverage", *args)
Expand Down
1 change: 0 additions & 1 deletion packaging/__about__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# This file is dual licensed under the terms of the Apache License, Version
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
# for complete details.
from __future__ import absolute_import, division, print_function

__all__ = [
"__title__",
Expand Down
1 change: 0 additions & 1 deletion packaging/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# This file is dual licensed under the terms of the Apache License, Version
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
# for complete details.
from __future__ import absolute_import, division, print_function

from .__about__ import (
__author__,
Expand Down
38 changes: 0 additions & 38 deletions packaging/_compat.py

This file was deleted.

5 changes: 2 additions & 3 deletions packaging/_structures.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# This file is dual licensed under the terms of the Apache License, Version
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
# for complete details.
from __future__ import absolute_import, division, print_function


class InfinityType(object):
class InfinityType:
def __repr__(self):
# type: () -> str
return "Infinity"
Expand Down Expand Up @@ -45,7 +44,7 @@ def __neg__(self):
Infinity = InfinityType()


class NegativeInfinityType(object):
class NegativeInfinityType:
def __repr__(self):
# type: () -> str
return "-Infinity"
Expand Down
42 changes: 15 additions & 27 deletions packaging/markers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# This file is dual licensed under the terms of the Apache License, Version
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
# for complete details.
from __future__ import absolute_import, division, print_function

import operator
import os
Expand All @@ -20,7 +19,6 @@
stringStart,
)

from ._compat import string_types
from ._typing import TYPE_CHECKING
from .specifiers import InvalidSpecifier, Specifier

Expand Down Expand Up @@ -58,7 +56,7 @@ class UndefinedEnvironmentName(ValueError):
"""


class Node(object):
class Node:
def __init__(self, value):
# type: (Any) -> None
self.value = value
Expand All @@ -69,7 +67,7 @@ def __str__(self):

def __repr__(self):
# type: () -> str
return "<{0}({1!r})>".format(self.__class__.__name__, str(self))
return f"<{self.__class__.__name__}('{self}')>"

def serialize(self):
# type: () -> str
Expand All @@ -85,7 +83,7 @@ def serialize(self):
class Value(Node):
def serialize(self):
# type: () -> str
return '"{0}"'.format(self)
return f'"{self}"'


class Op(Node):
Expand Down Expand Up @@ -162,7 +160,7 @@ def _coerce_parse_result(results):
def _format_marker(marker, first=True):
# type: (Union[List[str], Tuple[Node, ...], str], Optional[bool]) -> str

assert isinstance(marker, (list, tuple, string_types))
assert isinstance(marker, (list, tuple, str))

# Sometimes we have a structure like [[...]] which is a single item list
# where the single item is itself it's own list. In that case we want skip
Expand Down Expand Up @@ -210,14 +208,12 @@ def _eval_op(lhs, op, rhs):

oper = _operators.get(op.serialize()) # type: Optional[Operator]
if oper is None:
raise UndefinedComparison(
"Undefined {0!r} on {1!r} and {2!r}.".format(op, lhs, rhs)
)
raise UndefinedComparison(f"Undefined {op!r} on {lhs!r} and {rhs!r}.")

return oper(lhs, rhs)


class Undefined(object):
class Undefined:
pass


Expand All @@ -230,7 +226,7 @@ def _get_env(environment, name):

if isinstance(value, Undefined):
raise UndefinedEnvironmentName(
"{0!r} does not exist in evaluation environment.".format(name)
f"{name!r} does not exist in evaluation environment."
)

return value
Expand All @@ -241,7 +237,7 @@ def _evaluate_markers(markers, environment):
groups = [[]] # type: List[List[bool]]

for marker in markers:
assert isinstance(marker, (list, tuple, string_types))
assert isinstance(marker, (list, tuple, str))

if isinstance(marker, list):
groups[-1].append(_evaluate_markers(marker, environment))
Expand Down Expand Up @@ -275,16 +271,8 @@ def format_full_version(info):

def default_environment():
# type: () -> Dict[str, str]
if hasattr(sys, "implementation"):
# Ignoring the `sys.implementation` reference for type checking due to
# mypy not liking that the attribute doesn't exist in Python 2.7 when
# run with the `--py27` flag.
iver = format_full_version(sys.implementation.version) # type: ignore
implementation_name = sys.implementation.name # type: ignore
else:
iver = "0"
implementation_name = ""

iver = format_full_version(sys.implementation.version)
implementation_name = sys.implementation.name
return {
"implementation_name": implementation_name,
"implementation_version": iver,
Expand All @@ -300,24 +288,24 @@ def default_environment():
}


class Marker(object):
class Marker:
def __init__(self, marker):
# type: (str) -> None
try:
self._markers = _coerce_parse_result(MARKER.parseString(marker))
except ParseException as e:
err_str = "Invalid marker: {0!r}, parse error at {1!r}".format(
marker, marker[e.loc : e.loc + 8]
raise InvalidMarker(
f"Invalid marker: {marker!r}, parse error at "
f"{marker[e.loc : e.loc + 8]!r}"
)
raise InvalidMarker(err_str)

def __str__(self):
# type: () -> str
return _format_marker(self._markers)

def __repr__(self):
# type: () -> str
return "<Marker({0!r})>".format(str(self))
return f"<Marker('{self}')>"

def evaluate(self, environment=None):
# type: (Optional[Dict[str, str]]) -> bool
Expand Down
Loading