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

Backward compatible Update to support Python 3.10 that Passes all unit tests #201

Open
wants to merge 7 commits into
base: develop
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
2 changes: 1 addition & 1 deletion pyswagger/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.8.39'
__version__ = '0.8.39.0001'

from .getter import Getter
from .core import App, Security
Expand Down
2 changes: 1 addition & 1 deletion pyswagger/getter.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __next__(self):
if obj.startswith('{'):
obj = json.loads(obj)
else:
obj = yaml.load(obj)
obj = yaml.safe_load(obj)
except ValueError:
raise Exception('Unknown format startswith {0} ...'.format(obj[:10]))

Expand Down
8 changes: 8 additions & 0 deletions pyswagger/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
import collections
import logging

# Mapping and Mutable Mapping moved to collections.abc in Python 3.10
try:
from collections import abc
collections.MutableMapping = abc.MutableMapping
collections.Mapping = abc.Mapping
except:
pass


logger = logging.getLogger(__name__)

Expand Down
8 changes: 5 additions & 3 deletions pyswagger/tests/contrib/client/test_flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,18 @@ def test_custom_headers_multiple_values_to_one_key(self):
headers = [('X-TEST-HEADER', 'aaa'), ('X-TEST-HEADER', 'bbb')]
resp = self.client.request(
sapp.op['updatePet'](body=dict(id=1, name='Tom1')),
headers=headers
headers=headers,
opt={'join_headers': False}
)
self.assertEqual(received_headers.get_all('X-TEST-HEADER'), ['bbb'])
self.assertEqual(received_headers.get_all('X-TEST-HEADER'), ['aaa, bbb'])


# with 'join_headers'
resp = self.client.request(
sapp.op['updatePet'](body=dict(id=1, name='Tom1')),
headers=headers,
opt={'join_headers': True}
)
self.assertEqual(received_headers.get_all('X-TEST-HEADER'), ['aaa,bbb'])

self.assertEqual(received_headers.get_all('X-TEST-HEADER'), ['aaa,bbb'])

10 changes: 10 additions & 0 deletions pyswagger/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,18 @@
import os
import operator
import functools

import collections

# Mapping and Mutable Mapping moved to collections.abc in Python 3.10
try:
from collections import abc
collections.MutableMapping = abc.MutableMapping
collections.Mapping = abc.Mapping
except:
pass


#TODO: accept varg
def scope_compose(scope, name, sep=private.SCOPE_SEPARATOR):
""" compose a new scope
Expand Down
10 changes: 8 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
six>=1.6.0
pyaml>=15.03.1
certifi>=2024.6.2
charset-normalizer>=3.3.2
idna>=3.7
pyaml>=24.4.0
PyYAML>=6.0.1
requests>=2.32.3
six>=1.16.0
urllib3>=2.2.2
validate_email>=1.3