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

Fix MutableMapping for python 3.10 #298

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
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
Loading