chaimleib / intervaltree

A mutable, self-balancing interval tree. Queries may be by point, by range overlap, or by range containment.
Apache License 2.0
636 stars 108 forks source link

python 3.10 support #118

Open brainfo opened 2 years ago

brainfo commented 2 years ago

since collections in py 3.10 put MutableSet, MutableMapping, etc. in collections.abc insert these lines

import sys 
if sys.version_info.major == 3 and sys.version_info.minor >= 10:
    from collections.abc import MutableSet
    collections.MutableSet = collections.abc.MutableSet
else: 
    from collections import MutableSet

from https://stackoverflow.com/questions/74006130/attributeerror-module-collections-has-no-attribute-mutableset in interveltree.py would get over this version problem.

Jeremiah-England commented 1 year ago

@brainfo, I think you are using intervaltree 2.x. Since intervaltree 3.0.0 (released in 2018) the MutableSet has been imported like this:

https://github.com/chaimleib/intervaltree/blob/328d6db96596a0b7180dd3ad3fae4f6ff7301e01/intervaltree/intervaltree.py

try:
    from collections.abc import MutableSet  # Python 3?
except ImportError:
    from collections import MutableSet

We have been using intervaltree 3.1.0 on Python 3.10 and 3.11 and it has been working fine.