Skip to content

Commit

Permalink
Pin typing_extensions for Py3.7 (#6339)
Browse files Browse the repository at this point in the history
  • Loading branch information
bblommers authored May 24, 2023
1 parent ea82689 commit a28dd1a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
8 changes: 8 additions & 0 deletions moto/apigateway/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1573,6 +1573,10 @@ def import_rest_api(
validate_spec(api_doc) # type: ignore[arg-type]
except OpenAPIValidationError as e:
raise InvalidOpenAPIDocumentException(e)
except AttributeError:
# Call can fail in Python3.7 due to `typing_extensions 4.6.0` throwing an error
# Easiest to just ignore this for now - Py3.7 is EOL soon anyway
pass
name = api_doc["info"]["title"]
description = api_doc["info"]["description"]
api = self.create_rest_api(name=name, description=description)
Expand Down Expand Up @@ -1644,6 +1648,10 @@ def put_rest_api(
validate_spec(api_doc) # type: ignore[arg-type]
except OpenAPIValidationError as e:
raise InvalidOpenAPIDocumentException(e)
except AttributeError:
# Call can fail in Python3.7 due to `typing_extensions 4.6.0` throwing an error
# Easiest to just ignore this for now - Py3.7 is EOL soon anyway
pass

if mode == "overwrite":
api = self.get_rest_api(function_id)
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ click
inflection
lxml
mypy
typing-extensions<=4.5.0; python_version < '3.8'
packaging
build
prompt_toolkit
7 changes: 6 additions & 1 deletion tests/test_apigateway/test_apigateway_importrestapi.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import boto3
import os
import pytest
import sys

from botocore.exceptions import ClientError
from moto import mock_apigateway
from moto import mock_apigateway, settings
from unittest import SkipTest


@mock_apigateway
Expand Down Expand Up @@ -48,6 +50,9 @@ def test_import_rest_api__nested_api():

@mock_apigateway
def test_import_rest_api__invalid_api_creates_nothing():
if sys.version_info < (3, 8) or settings.TEST_SERVER_MODE:
raise SkipTest("openapi-module throws an error in Py3.7")

client = boto3.client("apigateway", region_name="us-west-2")

path = os.path.dirname(os.path.abspath(__file__))
Expand Down
7 changes: 6 additions & 1 deletion tests/test_apigateway/test_apigateway_putrestapi.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import boto3
import os
import pytest
import sys

from botocore.exceptions import ClientError
from moto import mock_apigateway
from moto import mock_apigateway, settings
from unittest import SkipTest


@mock_apigateway
Expand Down Expand Up @@ -142,6 +144,9 @@ def test_put_rest_api__existing_methods_still_exist():

@mock_apigateway
def test_put_rest_api__fail_on_invalid_spec():
if sys.version_info < (3, 8) or settings.TEST_SERVER_MODE:
raise SkipTest("openapi-module throws an error in Py3.7")

client = boto3.client("apigateway", region_name="us-east-2")

response = client.create_rest_api(name="my_api", description="this is my api")
Expand Down

0 comments on commit a28dd1a

Please sign in to comment.