gumyr / cq_warehouse

A cadquery parametric part collection

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fasteners.py fails to import in python 3.8 due to use of 'functools.cache' (specific to 3.9) instead of 'functools.lru_cache(maxsize=None)'

alikureishy opened this issue · comments

~/code/repositories/cq_warehouse/src/cq_warehouse/fastener.py in <module>
     31 from typing import Literal, Tuple, Optional, overload, List
     32 from math import sin, cos, tan, radians, pi, degrees
---> 33 from functools import cache
     34 import csv
     35 import importlib.resources as pkg_resources

ImportError: cannot import name 'cache' from 'functools' (/home/safdar/anaconda3/envs/ros1/lib/python3.8/functools.py)

I ran into this since my environment is on 3.8 and the import above is specific to 3.9.

Logging this here since the fix for backwards portability is quite trivial.

The documentation here suggests that cache is equivalent to lru_cache(maxsize=None) in python 3.8.

I'd attempt submitting a PR for this, but I can't run the unit tests (issue #7).

Thanks for raising the issue. I don't use or test with version 3.8 so these types of problems (this was the root of the previous typing issues as well) are bound to come up again. To help understand if support of 3.8 is generally valuable, why are you using 3.8 and not 3.9?

I see. I don't have a strong reason to stick with 3.8 -- it's just what I started my project with, and I've picked up some inertia with all the dependencies I've accumulated along the way.

If you feel it's best to remain on 3.9, then you might want to update this module's metadata, which lists 3.8+ as the minimum python version (both in setup.cfg, and in the egg-info). :)

As of release 0.4.0, python 3.9 is the minimum version.