genthalili / searoute-py

A python package to calculate the shortest sea route between two points on Earth.
Apache License 2.0
81 stars 17 forks source link

import searoute with python 3.7 #36

Closed arthys974 closed 5 months ago

arthys974 commented 5 months ago

Hello, I am using the library Searoute and I noticed there is a new version of your library since 9th June.

There is an error when I import the library in python 3.7.

Here is the error message when I do import searoute as sr

Error in python process: At line 12: <class 'TypeError'>: 'type' object is not subscriptable

More details: [07:54:11] [INFO] - def distance_length(line: list[tuple], units: str = "km"): [07:54:11] [INFO] - TypeError: 'type' object is not subscriptable

I think it is because of the "str" in distance_length function but I am not sure. I switched to the last version and it worked fine. Hope I can get some help about this. Thank you in advance. Best regards,

MasterMindSudo commented 5 months ago

Yes i have this problem as well, is it not supporting py3.7?

arthys974 commented 5 months ago

I am not sure. I didn't use 3.8 for this library.

genthalili commented 5 months ago

Looks like this is caused by typing in the function you mentioned, list[tuple] specifically it is not recognized in python version 3.7. => to fix this, I will remove the tuple part and let only list

The other is caused by @cache which was introduced in 3.9 Before 3.9 @lru_cache was used https://docs.python.org/3.7/library/functools.html#functools.lru_cache where @cache is equivalent to @lru_cache(maxsize=None) : https://docs.python.org/3.9/library/functools.html#functools.cache

@functools.cache(user_function) Simple lightweight unbounded function cache. Sometimes called “memoize”. Returns the same as lru_cache(maxsize=None), creating a thin wrapper around a dictionary lookup for the function arguments. Because it never needs to evict old values, this is smaller and faster than lru_cache() with a size limit.

According to the documentation, python 3.7 is no longer supported, so I can not even install on my pc to make the tests.

However I tested changes for python >=3.8 and it is working as it should. Will soon commit the new changes (in v1.4.1), so feel free to test at your end in 3.7, and let me know.

genthalili commented 5 months ago

Upgraded to 1.4.1, feel free to test it in python 3.7 and me know https://pypi.org/project/searoute/1.4.1/

MasterMindSudo commented 5 months ago

Hi Gent, updated to 1.4.1 and the issue has been resolved, no issue for now, thanks for your work!