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

Error on python>=3.10 #34

Open
PaoloAlbano opened this issue Mar 22, 2023 · 1 comment
Open

Error on python>=3.10 #34

PaoloAlbano opened this issue Mar 22, 2023 · 1 comment

Comments

@PaoloAlbano
Copy link

PaoloAlbano commented Mar 22, 2023

Description

error running target-csv on a python version >=3.10.

Screenshot 2023-03-22 at 10 43 12

Enviroment:
output of uname -a:
Linux 41bfd29a1839 5.15.49-linuxkit #1 SMP PREEMPT Tue Sep 13 07:51:32 UTC 2022 aarch64 GNU/Linux

output of python -V
Python 3.11.1

i'm working with docker hub image: python:3.11-slim

Problem

Starting from python 3.10, MutableMapping was moved under collections.abc .

See:
Deprecated since version 3.3, will be removed in version 3.10: Moved [Collections Abstract Base Classes](https://docs.python.org/3.9/library/collections.abc.html#collections-abstract-base-classes) to the [collections.abc](https://docs.python.org/3.9/library/collections.abc.html#module-collections.abc) module. For backwards compatibility, they continue to be visible in this module through Python 3.9.

Reference: https://docs.python.org/3.9/library/collections.html

PaoloAlbano added a commit to PaoloAlbano/target-csv that referenced this issue Mar 22, 2023
@frasermarlow
Copy link

I am running on Python 3.10.9. with a modified target_csv.py modified with

from collections.abc import MutableMapping

and the updated function

def flatten(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, MutableMapping):
            items.extend(flatten(v, new_key, sep=sep).items())
        else:
            items.append((new_key, str(v) if type(v) is list else v))
    return dict(items)

And it's working fine so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants