summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2019-08-18 18:45:16 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2019-08-24 15:13:09 +0200
commitea98f9fb7c76264df5e600ed597b79713e6cb2ce (patch)
tree22f774aa4b31d97554d550b4ac40dd7c4b7b12f8
parent65d76a46cb1898d9a0dc5c20baf9e014fe974fd8 (diff)
downloadsemantic-version-ea98f9fb7c76264df5e600ed597b79713e6cb2ce.tar.gz
Drop support for Python<3.4.
-rw-r--r--.travis.yml12
-rw-r--r--ChangeLog4
-rw-r--r--semantic_version/base.py25
-rw-r--r--semantic_version/compat.py15
-rw-r--r--semantic_version/django_fields.py9
-rwxr-xr-xsetup.py3
-rw-r--r--tests/compat.py14
-rw-r--r--tests/django_test_app/__init__.py19
-rw-r--r--tests/setup_django.py13
-rwxr-xr-xtests/test_base.py3
-rw-r--r--tests/test_django.py2
-rw-r--r--tests/test_spec.py2
-rw-r--r--tox.ini8
13 files changed, 45 insertions, 84 deletions
diff --git a/.travis.yml b/.travis.yml
index 04e672f..735e554 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,21 +9,17 @@ install:
matrix:
include:
- - python: "2.7"
- env: TOXENV=py27-django111
- python: "3.4"
- env: TOXENV=py34-django20
+ env: TOXENV=py34-django111
- python: "3.5"
- env: TOXENV=py35-django20
+ env: TOXENV=py35-django22
- python: "3.6"
env: TOXENV=py36-django111
- env: TOXENV=py36-django20
+ env: TOXENV=py36-django22
# Pypy
- - python: "pypy"
- env: TOXENV=pypy27-django111
- python: "pypy3"
- env: TOXENV=pypy3-django20
+ env: TOXENV=pypy3-django22
# Linting
- python: "3.6"
diff --git a/ChangeLog b/ChangeLog
index ca4f3af..7a7128c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,10 @@ ChangeLog
* Allow creation of a ``Version`` directly from parsed components, as keyword arguments
(``Version(major=1, minor=2, patch=3)``)
+*Removed:*
+
+ * Remove support for Python2 (End of life 4 months after this release)
+
2.6.0 (2016-09-25)
------------------
diff --git a/semantic_version/base.py b/semantic_version/base.py
index 8d9098d..93291e7 100644
--- a/semantic_version/base.py
+++ b/semantic_version/base.py
@@ -2,15 +2,10 @@
# Copyright (c) The python-semanticversion project
# This code is distributed under the two-clause BSD License.
-from __future__ import unicode_literals
-
import functools
import re
-from .compat import base_cmp
-
-
def _to_int(value):
try:
return int(value), True
@@ -25,6 +20,17 @@ def _has_leading_zero(value):
and value != '0')
+def base_cmp(x, y):
+ if x == y:
+ return 0
+ elif x > y:
+ return 1
+ elif x < y:
+ return -1
+ else:
+ return NotImplemented
+
+
def identifier_cmp(a, b):
"""Compare two identifier (for pre-release/build components)."""
@@ -68,7 +74,7 @@ def identifier_list_cmp(a, b):
return base_cmp(len(a), len(b))
-class Version(object):
+class Version:
version_re = re.compile(r'^(\d+)\.(\d+)\.(\d+)(?:-([0-9a-zA-Z.-]+))?(?:\+([0-9a-zA-Z.-]+))?$')
partial_version_re = re.compile(r'^(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:-([0-9a-zA-Z.-]*))?(?:\+([0-9a-zA-Z.-]*))?$')
@@ -82,8 +88,7 @@ class Version(object):
patch=None,
prerelease=None,
build=None,
- partial=False,
- ):
+ partial=False):
has_text = version_string is not None
has_parts = not (major is minor is patch is prerelease is build is None)
if not has_text ^ has_parts:
@@ -467,7 +472,7 @@ class Version(object):
return self.__compare_helper(other, lambda x: x >= 0, notimpl_target=False)
-class SpecItem(object):
+class SpecItem:
"""A requirement specification."""
KIND_ANY = '*'
@@ -570,7 +575,7 @@ class SpecItem(object):
return hash((self.kind, self.spec))
-class Spec(object):
+class Spec:
def __init__(self, *specs_strings):
subspecs = [self.parse(spec) for spec in specs_strings]
self.specs = sum(subspecs, ())
diff --git a/semantic_version/compat.py b/semantic_version/compat.py
deleted file mode 100644
index b17468f..0000000
--- a/semantic_version/compat.py
+++ /dev/null
@@ -1,15 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright (c) The python-semanticversion project
-# This code is distributed under the two-clause BSD License.
-
-
-def base_cmp(x, y):
- if x == y:
- return 0
- elif x > y:
- return 1
- elif x < y:
- return -1
- else:
- # Fix Py2's behavior: cmp(x, y) returns -1 for unorderable types
- return NotImplemented
diff --git a/semantic_version/django_fields.py b/semantic_version/django_fields.py
index 39a6c4b..2e9be69 100644
--- a/semantic_version/django_fields.py
+++ b/semantic_version/django_fields.py
@@ -2,7 +2,6 @@
# Copyright (c) The python-semanticversion project
# This code is distributed under the two-clause BSD License.
-from __future__ import unicode_literals
from django.db import models
from django.utils.translation import ugettext_lazy as _
@@ -14,7 +13,7 @@ class SemVerField(models.CharField):
def __init__(self, *args, **kwargs):
kwargs.setdefault('max_length', 200)
- super(SemVerField, self).__init__(*args, **kwargs)
+ super().__init__(*args, **kwargs)
def from_db_value(self, value, expression, connection, context):
"""Convert from the database format.
@@ -36,7 +35,7 @@ class SemVerField(models.CharField):
return str(value)
def run_validators(self, value):
- return super(SemVerField, self).run_validators(str(value))
+ return super().run_validators(str(value))
class VersionField(SemVerField):
@@ -48,11 +47,11 @@ class VersionField(SemVerField):
def __init__(self, *args, **kwargs):
self.partial = kwargs.pop('partial', False)
self.coerce = kwargs.pop('coerce', False)
- super(VersionField, self).__init__(*args, **kwargs)
+ super().__init__(*args, **kwargs)
def deconstruct(self):
"""Handle django.db.migrations."""
- name, path, args, kwargs = super(VersionField, self).deconstruct()
+ name, path, args, kwargs = super().deconstruct()
kwargs['partial'] = self.partial
kwargs['coerce'] = self.coerce
return name, path, args, kwargs
diff --git a/setup.py b/setup.py
index 812bf76..f936701 100755
--- a/setup.py
+++ b/setup.py
@@ -60,12 +60,11 @@ setup(
'Topic :: Software Development :: Libraries :: Python Modules',
'Operating System :: OS Independent',
'Programming Language :: Python',
- 'Programming Language :: Python :: 2',
- 'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
+ 'Programming Language :: Python :: 3.7',
'Topic :: Software Development :: Libraries :: Python Modules'
],
test_suite='tests',
diff --git a/tests/compat.py b/tests/compat.py
deleted file mode 100644
index f3ef508..0000000
--- a/tests/compat.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright (c) The python-semanticversion project
-# This code is distributed under the two-clause BSD License.
-
-import sys
-
-is_python2 = (sys.version_info[0] == 2)
-
-
-try: # pragma: no cover
- import unittest2 as unittest
-except ImportError: # pragma: no cover
- import unittest
-
diff --git a/tests/django_test_app/__init__.py b/tests/django_test_app/__init__.py
index 0f94470..4506810 100644
--- a/tests/django_test_app/__init__.py
+++ b/tests/django_test_app/__init__.py
@@ -9,22 +9,3 @@ try: # pragma: no cover
except ImportError: # pragma: no cover
django_loaded = False
-
-if django_loaded: # pragma: no cover
- if not settings.configured:
- settings.configure(
- DATABASES={
- 'default': {
- 'ENGINE': 'django.db.backends.sqlite3',
- 'NAME': 'tests/db/test.sqlite',
- }
- },
- INSTALLED_APPS=[
- 'tests.django_test_app',
- ],
- MIDDLEWARE_CLASSES=[],
- )
- # https://docs.djangoproject.com/en/dev/releases/1.7/#app-loading-changes
- if django.VERSION >= (1, 7):
- from django.apps import apps
- apps.populate(settings.INSTALLED_APPS)
diff --git a/tests/setup_django.py b/tests/setup_django.py
index e0469bc..6a220df 100644
--- a/tests/setup_django.py
+++ b/tests/setup_django.py
@@ -13,9 +13,18 @@ if django_loaded:
from django.conf import settings
if not settings.configured:
settings.configure(
- DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3'}},
- INSTALLED_APPS=['tests.django_test_app'],
+ DATABASES={
+ 'default': {
+ 'ENGINE': 'django.db.backends.sqlite3',
+ 'NAME': 'tests/db/test.sqlite',
+ }
+ },
+ INSTALLED_APPS=[
+ 'tests.django_test_app',
+ ],
MIDDLEWARE_CLASSES=[],
)
django.setup()
+ from django.apps import apps
+ apps.populate(settings.INSTALLED_APPS)
diff --git a/tests/test_base.py b/tests/test_base.py
index a1255c3..7ab3fba 100755
--- a/tests/test_base.py
+++ b/tests/test_base.py
@@ -5,7 +5,7 @@
"""Test the various functions from 'base'."""
-from .compat import unittest, is_python2
+import unittest
from semantic_version import base
@@ -226,7 +226,6 @@ class VersionTestCase(unittest.TestCase):
]))
)
- @unittest.skipIf(is_python2, "Comparisons to other objects are broken in Py2.")
def test_invalid_comparisons(self):
v = base.Version('0.1.0')
with self.assertRaises(TypeError):
diff --git a/tests/test_django.py b/tests/test_django.py
index d9afd8f..b61b64e 100644
--- a/tests/test_django.py
+++ b/tests/test_django.py
@@ -2,8 +2,6 @@
# Copyright (c) The python-semanticversion project
# This code is distributed under the two-clause BSD License.
-from __future__ import unicode_literals
-
import unittest
import sys
diff --git a/tests/test_spec.py b/tests/test_spec.py
index 43c9d6a..cd5d2ce 100644
--- a/tests/test_spec.py
+++ b/tests/test_spec.py
@@ -5,7 +5,7 @@
"""Test conformance to the specs."""
-from .compat import unittest, is_python2
+import unittest
import semantic_version
diff --git a/tox.ini b/tox.ini
index ead2bf6..9ec0fb3 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,8 +1,8 @@
[tox]
envlist =
- py{27,34,35,36}-django{111,20}
- pypy27-django111
- pypy3-django{111,20}
+ py{34,35,36,37}-django111
+ py{35,36,37}-django22
+ pypy3-django{111,22}
lint
toxworkdir = {env:TOX_WORKDIR:.tox}
@@ -11,7 +11,7 @@ toxworkdir = {env:TOX_WORKDIR:.tox}
deps =
-rrequirements_test.txt
django111: Django>=1.11,<1.12
- django20: Django>=2.0,<2.1
+ django22: Django>=2.2,<2.3
whitelist_externals = make
commands = make test