summaryrefslogtreecommitdiff
path: root/semantic_version
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 /semantic_version
parent65d76a46cb1898d9a0dc5c20baf9e014fe974fd8 (diff)
downloadsemantic-version-ea98f9fb7c76264df5e600ed597b79713e6cb2ce.tar.gz
Drop support for Python<3.4.
Diffstat (limited to 'semantic_version')
-rw-r--r--semantic_version/base.py25
-rw-r--r--semantic_version/compat.py15
-rw-r--r--semantic_version/django_fields.py9
3 files changed, 19 insertions, 30 deletions
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