Fix for Collections change in 3.10

python 3.10 moved a module in the collections package
breaking backwards compatibility.  this patch puts a fix in
to account for it.
This commit is contained in:
Hemna 2022-12-12 20:45:19 -05:00
parent 40f23dcb48
commit 9d19502dd8
1 changed files with 8 additions and 2 deletions

View File

@ -1,9 +1,9 @@
"""Utilities and helper functions."""
import collections
import errno
import os
import re
import sys
import update_checker
@ -15,6 +15,12 @@ from .fuzzyclock import fuzzy # noqa: F401
from .ring_buffer import RingBuffer # noqa: F401
if sys.version_info.major == 3 and sys.version_info.minor >= 10:
from collections.abc import MutableMapping
else:
from collections import MutableMapping
def env(*vars, **kwargs):
"""This returns the first environment variable set.
if none are non-empty, defaults to '' or keyword arg default
@ -105,7 +111,7 @@ def flatten_dict(d, parent_key="", sep="."):
items = []
for k, v in d.items():
new_key = parent_key + sep + k if parent_key else k
if isinstance(v, collections.MutableMapping):
if isinstance(v, MutableMapping):
items.extend(flatten_dict(v, new_key, sep=sep).items())
else:
items.append((new_key, v))