crowemi / target-s3

singer.io target for S3 built with @meltano SDK
https://hub.meltano.com/loaders/target-s3
9 stars 24 forks source link

collections.Mutable python3.10 support #22

Closed mun-akkio closed 11 months ago

mun-akkio commented 1 year ago

Currently imports for collections.Mutable is not updated for Python 3.10. I'm more than happy to put forth a PR, or someone could just apply the import changes in formats/format_base.py

--- a/target_s3/formats/format_base.py                                                                                                                                                                                 
+++ b/target_s3/formats/format_base.py               
@@ -1,7 +1,6 @@
 import re
 import inflection
 import json
-import collections
 import logging
 from datetime import datetime
 from abc import ABCMeta, abstractmethod             
@@ -9,6 +8,11 @@ from abc import ABCMeta, abstractmethod
 from boto3 import Session
 from smart_open import open

+try:
+    from collections.abc import MutableMapping      
+except ImportError
+    from collections import MutableMapping
+

 LOGGER = logging.getLogger("target-s3")                                                                                                                                                                               
 DATE_GRAIN = {                                                                                                                                                                                                                                                                                                                             
@@ -175,7 +179,7 @@ class FormatBase(metaclass=ABCMeta):                                                                                                                                                               
         for k in sorted(d.keys()):                                                                                                                                                                                    
             v = d[k]                                                                                                                                                                                                  
             new_key = self.flatten_key(k, parent_key, sep)                                                                                                                                                            
-            if isinstance(v, collections.MutableMapping):                                                                                                                                                             
+            if isinstance(v, MutableMapping):                                                                                                                                                                         
                 items.extend(self.flatten_record(v, parent_key + [k], sep=sep).items())                                                                                                                               
             else:                                                                                                                                                                                                     
                 items.append((new_key, json.dumps(v) if type(v) is list else v))  
crowemi commented 1 year ago

Hey @mun-akkio 👋 -- feel free the put forth a PR and we'll get this squared away. Thank you.

edgarrmondragon commented 11 months ago

I think this can be closed since https://github.com/crowemi/target-s3/pull/28 removed usage of collections.MutableMapping.