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 obsolete python versions #273

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
8 changes: 2 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ language: python

jobs:
include:
- env: TOXENV=py27
python: 2.7
- env: TOXENV=py34
python: 3.4
- env: TOXENV=py35
python: 3.5
- env: TOXENV=py36
python: 3.6
- env: TOXENV=py37
Expand All @@ -18,6 +12,8 @@ jobs:
python: 3.8
- env: TOXENV=py39
python: 3.9
- env: TOXENV=py310
python: '3.10'
- env: TOXENV=coverage
python: 3.8
- env: TOXENV=checks
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include README.rst requirements.txt LICENSE-MIT *.py
include README.rst LICENSE-MIT *.py
1 change: 0 additions & 1 deletion requirements.txt

This file was deleted.

9 changes: 2 additions & 7 deletions schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@

import inspect
import re

try:
from contextlib import ExitStack
except ImportError:
from contextlib2 import ExitStack

from contextlib import ExitStack

__version__ = "0.7.5"
__all__ = [
Expand Down Expand Up @@ -252,7 +247,7 @@ def validate(self, data, **kwargs):
raise SchemaError("%s(%r) raised %r" % (f, data, x), self._error.format(data) if self._error else None)


COMPARABLE, CALLABLE, VALIDATOR, TYPE, DICT, ITERABLE = range(6)
COMPARABLE, CALLABLE, VALIDATOR, TYPE, DICT, ITERABLE = list(range(6))


def _priority(s):
Expand Down
8 changes: 1 addition & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,14 @@
py_modules=["schema"],
long_description=codecs.open("README.rst", "r", "utf-8").read(),
long_description_content_type="text/x-rst",
install_requires=open("requirements.txt", "r").read().split("\n"),
classifiers=[
"Development Status :: 3 - Alpha",
"Topic :: Utilities",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: Implementation :: PyPy",
"License :: OSI Approved :: MIT License",
],
Expand Down
21 changes: 7 additions & 14 deletions test_schema.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import with_statement

import copy
import json
import os
Expand All @@ -9,8 +7,8 @@
from collections import defaultdict, namedtuple
from functools import partial
from operator import methodcaller
from unittest.mock import Mock

from mock import Mock
from pytest import mark, raises

from schema import (
Expand All @@ -31,11 +29,6 @@
Use,
)

if sys.version_info[0] == 3:
basestring = str # Python 3 does not have basestring
unicode = str # Python 3 does not have unicode


SE = raises(SchemaError)


Expand Down Expand Up @@ -150,7 +143,7 @@ def unique_list(_list):
return len(_list) == len(set(_list))

def dict_keys(key, _list):
return list(map(lambda d: d[key], _list))
return list([d[key] for d in _list])

schema = Schema(Const(And(Use(partial(dict_keys, "index")), unique_list)))
data = [{"index": 1, "value": "foo"}, {"index": 2, "value": "bar"}]
Expand Down Expand Up @@ -194,7 +187,7 @@ def test_regex():

# Validate that the pattern has a buffer interface
assert Regex(re.compile(r"foo")).validate("foo") == "foo"
assert Regex(unicode("foo")).validate("foo") == "foo"
assert Regex(str("foo")).validate("foo") == "foo"
with raises(TypeError):
Regex(1).validate("bar")
with raises(TypeError):
Expand Down Expand Up @@ -353,7 +346,7 @@ def test_dict_optional_keys():
assert Schema({"a": 1, Optional("b"): 2}).validate({"a": 1}) == {"a": 1}
assert Schema({"a": 1, Optional("b"): 2}).validate({"a": 1, "b": 2}) == {"a": 1, "b": 2}
# Make sure Optionals are favored over types:
assert Schema({basestring: 1, Optional("b"): 2}).validate({"a": 1, "b": 2}) == {"a": 1, "b": 2}
assert Schema({str: 1, Optional("b"): 2}).validate({"a": 1, "b": 2}) == {"a": 1, "b": 2}
# Make sure Optionals hash based on their key:
assert len({Optional("a"): 1, Optional("a"): 1, Optional("b"): 2}) == 2

Expand All @@ -364,7 +357,7 @@ def test_dict_optional_defaults():

# Optionals take precedence over types. Here, the "a" is served by the
# Optional:
assert Schema({Optional("a", default=1): 11, basestring: 22}).validate({"b": 22}) == {"a": 1, "b": 22}
assert Schema({Optional("a", default=1): 11, str: 22}).validate({"b": 22}) == {"a": 1, "b": 22}

with raises(TypeError):
Optional(And(str, Use(int)), default=7)
Expand Down Expand Up @@ -529,7 +522,7 @@ def test_use_json():
gist_schema = Schema(
And(
Use(json.loads), # first convert from JSON
{Optional("description"): basestring, "public": bool, "files": {basestring: {"content": basestring}}},
{Optional("description"): str, "public": bool, "files": {str: {"content": str}}},
)
)
gist = """{"description": "the description for this gist",
Expand Down Expand Up @@ -667,7 +660,7 @@ def test_optional_key_convert_failed_randomly_while_with_another_optional_object
Optional("created_at"): _datetime_validator,
Optional("updated_at"): _datetime_validator,
Optional("birth"): _datetime_validator,
Optional(basestring): object,
Optional(str): object,
}
)
data = {"created_at": "2015-10-10 00:00:00"}
Expand Down
5 changes: 1 addition & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@
# install tox" and then run "tox" from this directory.

[tox]
envlist = py26, py27, py32, py33, py34, py35, py36, py37, py38, py39, pypy3, coverage, checks
envlist = py36, py37, py38, py39, py310, pypy3, coverage, checks

[testenv]
commands = py.test
recreate = true
deps = pytest
mock


[testenv:py38]
commands = py.test --doctest-glob=README.rst # test documentation
deps = pytest
mock

[testenv:checks]
basepython=python3
Expand All @@ -31,4 +29,3 @@ commands = coverage erase
deps = pytest
pytest-cov
coverage
mock