Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 16, 2025
1 parent 5e085ec commit 8d9d452
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 14 deletions.
2 changes: 0 additions & 2 deletions prance/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ def _validate_openapi_spec_validator(
from openapi_spec_validator import validate
from jsonschema.exceptions import ValidationError as JSEValidationError
from referencing.exceptions import Unresolvable


# Validate according to detected version. Unsupported versions are
# already caught outside of this function.
Expand All @@ -254,7 +253,6 @@ def _validate_openapi_spec_validator(
except Unresolvable as ref_unres:
raise_from(ValidationError, ref_unres)


def _strict_warning(self):
"""Return a warning if strict mode is off."""
if self.options.get("strict", True):
Expand Down
3 changes: 1 addition & 2 deletions prance/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ def convert_str(spec_str, filename=None, **kwargs):

# Ok, parsing went fine, so let's convert.
data = spec_str


headers = {"accept": content_type,"content-type":content_type}
headers = {"accept": content_type, "content-type": content_type}

# Convert via API
import requests
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ license = MITNFA
packages = find:
include_package_data = True
install_requires =
setuptools>=75.8.0
setuptools>=75.8.0
chardet>=5.2
ruamel.yaml>=0.18.10
requests>=2.32.3
Expand Down
2 changes: 1 addition & 1 deletion tests/examples/v2.0/json/petstore.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/examples/v2.0/yaml/petstore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -714,4 +714,4 @@ definitions:
name: "User"
externalDocs:
description: "Find out more about Swagger"
url: "http://swagger.io"
url: "http://swagger.io"
8 changes: 6 additions & 2 deletions tests/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ def petstore_json():

@pytest.mark.requires_network()
def test_convert_petstore_yaml(petstore_yaml):
converted, content_type = convert.convert_str(petstore_yaml, content_type='application/yaml')
converted, content_type = convert.convert_str(
petstore_yaml, content_type="application/yaml"
)

# Check correct content type
assert "yaml" in content_type
Expand All @@ -45,7 +47,9 @@ def test_convert_petstore_yaml(petstore_yaml):

@pytest.mark.requires_network()
def test_convert_petstore_json(petstore_json):
converted, content_type = convert.convert_str(petstore_json, content_type='application/json')
converted, content_type = convert.convert_str(
petstore_json, content_type="application/json"
)

# Check correct content type
assert "json" in content_type
Expand Down
6 changes: 3 additions & 3 deletions tests/test_resolving_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def test_issue_65_partial_resolution_files():
parser = ResolvingParser(
spec_string=specs,
resolve_types=resolver.RESOLVE_FILES,
backend="openapi-spec-validator"
backend="openapi-spec-validator",
)

from prance.util.path import path_get
Expand Down Expand Up @@ -242,9 +242,9 @@ def test_value_not_converted_to_boolean():
from prance.util import resolver

parser = ResolvingParser(
spec_string=specs,
spec_string=specs,
resolve_types=resolver.RESOLVE_FILES,
backend="openapi-spec-validator"
backend="openapi-spec-validator",
)
specs = parser.specification
assert specs["components"]["schemas"]["SampleEnum"]["enum"] == ["NO", "OFF"]
12 changes: 10 additions & 2 deletions tests/test_translating_parser.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from os.path import join
from re import match


import pytest

from . import none_of

from prance import _TranslatingParser


Expand Down Expand Up @@ -81,20 +79,23 @@ def assert_schema_ref(self, key, ref, getter=lambda schema: schema):
schema = getter(schemas[key])
self._assert_ref(schema, ref)


@pytest.mark.skipif(
none_of("openapi-spec-validator"), reason="Missing openapi-spec-validator"
)
def test_local_reference_from_root(tester):
tester.assert_path_ref("PlainObject")
tester.assert_schemas({"PlainObject"})


@pytest.mark.skipif(
none_of("openapi-spec-validator"), reason="Missing openapi-spec-validator"
)
def test_file_reference_from_root(tester):
tester.assert_path_ref("file_reference_from_root_schemas.spec.yaml_PlainObject")
tester.assert_schemas({"file_reference_from_root_schemas.spec.yaml_PlainObject"})


@pytest.mark.skipif(
none_of("openapi-spec-validator"), reason="Missing openapi-spec-validator"
)
Expand All @@ -111,6 +112,7 @@ def test_local_reference_from_file(tester):
"local_reference_from_file_schemas.spec.yaml_PlainObject",
)


@pytest.mark.skipif(
none_of("openapi-spec-validator"), reason="Missing openapi-spec-validator"
)
Expand All @@ -127,6 +129,7 @@ def test_same_file_reference_from_file(tester):
"same_file_reference_from_file_schemas.spec.yaml_PlainObject",
)


@pytest.mark.skipif(
none_of("openapi-spec-validator"), reason="Missing openapi-spec-validator"
)
Expand All @@ -145,6 +148,7 @@ def test_different_file_reference_from_file(tester):
"different_file_reference_from_file_schemas2.spec.yaml_PlainObject",
)


@pytest.mark.skipif(
none_of("openapi-spec-validator"), reason="Missing openapi-spec-validator"
)
Expand All @@ -157,13 +161,15 @@ def test_root_file_reference_from_file(tester):
"root_file_reference_from_file_schemas.spec.yaml_RefObject", "PlainObject"
)


@pytest.mark.skipif(
none_of("openapi-spec-validator"), reason="Missing openapi-spec-validator"
)
def test_root_file_reference_from_root(tester):
tester.assert_path_ref("PlainObject")
tester.assert_schemas({"PlainObject"})


@pytest.mark.skipif(
none_of("openapi-spec-validator"), reason="Missing openapi-spec-validator"
)
Expand All @@ -174,6 +180,7 @@ def test_recursive_reference_in_root(tester):
lambda schema: schema["additionalProperties"],
)


@pytest.mark.skipif(
none_of("openapi-spec-validator"), reason="Missing openapi-spec-validator"
)
Expand All @@ -190,6 +197,7 @@ def test_recursive_reference_in_file(tester):
lambda schema: schema["additionalProperties"],
)


@pytest.mark.skipif(
none_of("openapi-spec-validator"), reason="Missing openapi-spec-validator"
)
Expand Down

0 comments on commit 8d9d452

Please # to comment.