Skip to content

Remove six #28

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

Merged
merged 1 commit into from
Dec 29, 2021
Merged
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
21 changes: 10 additions & 11 deletions openapi_schema_validator/_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from jsonschema._format import FormatChecker
from jsonschema.exceptions import FormatError
from six import binary_type, text_type, integer_types

DATETIME_HAS_RFC3339_VALIDATOR = False
DATETIME_HAS_STRICT_RFC3339 = False
Expand Down Expand Up @@ -38,11 +37,11 @@


def is_int32(instance):
return isinstance(instance, integer_types)
return isinstance(instance, int)


def is_int64(instance):
return isinstance(instance, integer_types)
return isinstance(instance, int)


def is_float(instance):
Expand All @@ -56,11 +55,11 @@ def is_double(instance):


def is_binary(instance):
return isinstance(instance, binary_type)
return isinstance(instance, bytes)


def is_byte(instance):
if isinstance(instance, text_type):
if isinstance(instance, str):
instance = instance.encode()

try:
Expand All @@ -70,7 +69,7 @@ def is_byte(instance):


def is_datetime(instance):
if not isinstance(instance, (binary_type, text_type)):
if not isinstance(instance, (bytes, str)):
return False

if DATETIME_HAS_RFC3339_VALIDATOR:
Expand All @@ -86,23 +85,23 @@ def is_datetime(instance):


def is_date(instance):
if not isinstance(instance, (binary_type, text_type)):
if not isinstance(instance, (bytes, str)):
return False

if isinstance(instance, binary_type):
if isinstance(instance, bytes):
instance = instance.decode()

return datetime.strptime(instance, "%Y-%m-%d")


def is_uuid(instance):
if not isinstance(instance, (binary_type, text_type)):
if not isinstance(instance, (bytes, str)):
return False

if isinstance(instance, binary_type):
if isinstance(instance, bytes):
instance = instance.decode()

return text_type(UUID(instance)).lower() == instance.lower()
return str(UUID(instance)).lower() == instance.lower()


def is_password(instance):
Expand Down
3 changes: 1 addition & 2 deletions openapi_schema_validator/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
TypeChecker, is_array, is_bool, is_integer,
is_object, is_number,
)
from six import text_type, binary_type


def is_string(checker, instance):
return isinstance(instance, (text_type, binary_type))
return isinstance(instance, (str, bytes))


oas30_type_checker = TypeChecker(
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ classifiers = [

[tool.poetry.dependencies]
python = "^3.6.2"
six = "*"
jsonschema = "*"
rfc3339-validator = {version = "*", optional = true}
strict-rfc3339 = {version = "*", optional = true}
Expand Down
17 changes: 8 additions & 9 deletions tests/integration/test_validators.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from jsonschema import ValidationError
import pytest
from six import u

from openapi_schema_validator import OAS30Validator, oas30_format_checker

Expand Down Expand Up @@ -36,8 +35,8 @@ def test_nullable(self, schema_type):
assert result is None

@pytest.mark.parametrize('value', [
u('1989-01-02T00:00:00Z'),
u('2018-01-02T23:59:59Z'),
u'1989-01-02T00:00:00Z',
u'2018-01-02T23:59:59Z',
])
@mock.patch(
'openapi_schema_validator._format.'
Expand All @@ -61,8 +60,8 @@ def test_string_format_no_datetime_validator(self, value):
assert result is None

@pytest.mark.parametrize('value', [
u('1989-01-02T00:00:00Z'),
u('2018-01-02T23:59:59Z'),
u'1989-01-02T00:00:00Z',
u'2018-01-02T23:59:59Z',
])
@mock.patch(
'openapi_schema_validator._format.'
Expand All @@ -86,8 +85,8 @@ def test_string_format_datetime_rfc3339_validator(self, value):
assert result is None

@pytest.mark.parametrize('value', [
u('1989-01-02T00:00:00Z'),
u('2018-01-02T23:59:59Z'),
u'1989-01-02T00:00:00Z',
u'2018-01-02T23:59:59Z',
])
@mock.patch(
'openapi_schema_validator._format.'
Expand All @@ -111,8 +110,8 @@ def test_string_format_datetime_strict_rfc3339(self, value):
assert result is None

@pytest.mark.parametrize('value', [
u('1989-01-02T00:00:00Z'),
u('2018-01-02T23:59:59Z'),
u'1989-01-02T00:00:00Z',
u'2018-01-02T23:59:59Z',
])
@mock.patch(
'openapi_schema_validator._format.'
Expand Down