diff --git a/pydantic/types.py b/pydantic/types.py index fb5fa39..8918b7d 100644 --- a/pydantic/types.py +++ b/pydantic/types.py @@ -56,14 +56,14 @@ class ConstrainedStr(str): if value is None: raise TypeError('None is not an allow value') - l = len(value) - if cls.min_length is not None and l < cls.min_length: + v_len = len(value) + if cls.min_length is not None and v_len < cls.min_length: raise ValueError(f'length less than minimum allowed: {cls.min_length}') if cls.curtail_length: - if l > cls.curtail_length: + if v_len > cls.curtail_length: value = value[:cls.curtail_length] - elif cls.max_length is not None and l > cls.max_length: + elif cls.max_length is not None and v_len > cls.max_length: raise ValueError(f'length greater than maximum allowed: {cls.max_length}') if cls.regex: diff --git a/tests/requirements.txt b/tests/requirements.txt index 2153cff..44ca562 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,5 +1,5 @@ coverage==4.4.1 -flake8==3.4.1 +flake8==3.5.0 isort==4.2.15 mypy==0.540 pycodestyle==2.3.1