feat: automatically patch collections for >python 3.10 support (#21)

Co-authored-by: Bo Liu <benjaminliu.eecs@gmail.com>
This commit is contained in:
Nicola Dall'Asen
2024-03-13 15:34:10 +01:00
committed by GitHub
parent 601426030d
commit 717ed7639c
5 changed files with 28 additions and 9 deletions

View File

@@ -16,3 +16,16 @@
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# check if python version is above 3.10
import sys
if sys.version_info >= (3, 10):
print("Python version is above 3.10, patching the collections module.")
# Monkey patch collections
import collections
import collections.abc
for type_name in collections.abc.__all__:
setattr(collections, type_name, getattr(collections.abc, type_name))