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

Mapping import in yaml.py #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
11 changes: 9 additions & 2 deletions sphinxcontrib/dd/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
from copy import deepcopy
from yaml import load as load_yaml

try:
# Import for modern python
from collections.abc import Mapping
except ImportError:
# Required for Python 2
# Deprecated in 3.3 and removed in 3.8
from collections import Mapping

# This is taken from sphinxcontrib-openapi

Expand Down Expand Up @@ -45,14 +52,14 @@ def resolve_refs(uri, spec):
resolver = jsonschema.RefResolver(uri, spec)

def _do_resolve(node):
if isinstance(node, collections.Mapping) and '$ref' in node:
if isinstance(node, Mapping) and '$ref' in node:
with resolver.resolving(node['$ref']) as resolved:
result = deepcopy(resolved)
for key in resolved:
if key in node:
merge(result[key], node[key])
return result
elif isinstance(node, collections.Mapping):
elif isinstance(node, Mapping):
for k, v in node.items():
node[k] = _do_resolve(v)
elif isinstance(node, (list, tuple)):
Expand Down