smirarab / sepp

Ensemble of HMM methods (SEPP, TIPP, UPP)
GNU General Public License v3.0
89 stars 38 forks source link

DeprecationWarning importing Mapping from collections directly #117

Closed panlinux closed 3 months ago

panlinux commented 2 years ago

In https://github.com/smirarab/sepp/blob/654a181565ba497fd79160ed74b1d22d1d4e2577/sepp/alignment.py#L29 Mapping is imported directly from collections. This has been deprecated since python 3.3:

# python3
Python 3.8.10 (default, Nov 26 2021, 20:14:08) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from collections import Mapping
<stdin>:1: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working

And in 3.10 it indeed fails:

$ python3
Python 3.10.2 (main, Jan 16 2022, 17:11:27) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from collections import Mapping
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'Mapping' from 'collections' (/usr/lib/python3.10/collections/__init__.py)

Simple fix is:

--- a/sepp/alignment.py
+++ b/sepp/alignment.py
@@ -26,7 +26,8 @@ import re

 from sepp.filemgr import open_with_intermediates

-from collections import Mapping
+
+from collections.abc import Mapping
 import copy
 from sepp import get_logger
 import io
smirarab commented 3 months ago

Fixed by c276adf34040cd2cb4095a965c2ae362e6bab228