Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
Fix MutableMapping for python 3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
Limess committed May 25, 2022
1 parent 80796b6 commit ba1e52f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions target_redshift/db_sync.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import collections

import sys
# pylint: disable=no-name-in-module
if sys.version_info.major == 3 and sys.version_info.minor >= 10:
from collections.abc import MutableMapping
else:
from collections import MutableMapping
# pylint: enable=no-name-in-module

import itertools
import json
import os
import re
import sys
import time

import boto3
Expand Down Expand Up @@ -161,7 +168,7 @@ def flatten_record(d, flatten_schema=None, parent_key=[], sep='__', level=0, max
items = []
for k, v in d.items():
new_key = flatten_key(k, parent_key, sep)
if isinstance(v, collections.MutableMapping) and level < max_level:
if isinstance(v, MutableMapping) and level < max_level:
items.extend(flatten_record(v, flatten_schema, parent_key + [k], sep=sep, level=level + 1, max_level=max_level).items())
else:
items.append((new_key, json.dumps(v) if _should_json_dump_value(k, v, flatten_schema) else v))
Expand Down

0 comments on commit ba1e52f

Please sign in to comment.