From 730b9f22700e2f39677e3c6041a180f319f9d5be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Barrois?= Date: Thu, 1 Sep 2016 13:48:40 +0200 Subject: Linting --- semantic_version/__init__.py | 6 +++--- semantic_version/base.py | 21 ++++++++++++++------- semantic_version/django_fields.py | 2 +- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/semantic_version/__init__.py b/semantic_version/__init__.py index 6daf567..f92187a 100644 --- a/semantic_version/__init__.py +++ b/semantic_version/__init__.py @@ -3,8 +3,8 @@ # This code is distributed under the two-clause BSD License. -__author__ = "Raphaël Barrois " -__version__ = '2.5.0' +from .base import compare, match, validate, Spec, SpecItem, Version -from .base import compare, match, validate, Spec, SpecItem, Version +__author__ = "Raphaël Barrois " +__version__ = '2.5.0' diff --git a/semantic_version/base.py b/semantic_version/base.py index 0f4e11b..61d0f6a 100644 --- a/semantic_version/base.py +++ b/semantic_version/base.py @@ -10,12 +10,14 @@ import re from .compat import base_cmp + def _to_int(value): try: return int(value), True except ValueError: return value, False + def _has_leading_zero(value): return (value and value[0] == '0' @@ -133,8 +135,10 @@ class Version(object): match = base_re.match(version_string) if not match: - raise ValueError("Version string lacks a numerical component: %r" - % version_string) + raise ValueError( + "Version string lacks a numerical component: %r" + % version_string + ) version = version_string[:match.end()] if not partial: @@ -242,8 +246,11 @@ class Version(object): def _validate_identifiers(cls, identifiers, allow_leading_zeroes=False): for item in identifiers: if not item: - raise ValueError("Invalid empty identifier %r in %r" - % (item, '.'.join(identifiers))) + raise ValueError( + "Invalid empty identifier %r in %r" + % (item, '.'.join(identifiers)) + ) + if item[0] == '0' and item.isdigit() and item != '0' and not allow_leading_zeroes: raise ValueError("Invalid leading zero in identifier %r" % item) @@ -336,7 +343,6 @@ class Version(object): ] def __compare(self, other): - field_pairs = zip(self, other) comparison_functions = self._comparison_functions(partial=self.partial or other.partial) comparisons = zip(comparison_functions, self, other) @@ -440,8 +446,9 @@ class SpecItem(object): spec = Version(version, partial=True) if spec.build is not None and kind not in (cls.KIND_EQUAL, cls.KIND_NEQ): raise ValueError( - "Invalid requirement specification %r: build numbers have no ordering." - % requirement_string) + "Invalid requirement specification %r: build numbers have no ordering." + % requirement_string + ) return (kind, spec) def match(self, version): diff --git a/semantic_version/django_fields.py b/semantic_version/django_fields.py index c50297e..599929a 100644 --- a/semantic_version/django_fields.py +++ b/semantic_version/django_fields.py @@ -102,7 +102,7 @@ def add_south_rules(): try: # pragma: no cover import south -except ImportError: # pragma: no cover +except ImportError: # pragma: no cover south = None if south: # pragma: no cover -- cgit v1.2.1