andycasey / ads

Python tool for ADS
MIT License
170 stars 72 forks source link

changed syntax in cached_property for python >= 3.9.6 #119

Closed CodeBBQ closed 1 year ago

CodeBBQ commented 2 years ago

The syntax in cached_property changed at the version change from 1.0.x to 2.0.x in werkzeug package.

I, therefore, introduced a try-except block to use the newer attribute fget instead of func if an AttributeError occurs.

For running:

python -m unittest discover > ~/testresult.txt

s./Users/user/repositories/ads/ads/base.py:135: RuntimeWarning: No token found
  warnings.warn("No token found", RuntimeWarning)
........../Users/user/repositories/ads/ads/utils.py:33: UserWarning: You are lazy loading attributes via 'citation_count', and so are making multiple calls to the API. This will impact your overall rate limits.
  warnings.warn(
/Users/user/repositories/ads/ads/utils.py:33: UserWarning: You are lazy loading attributes via 'author', and so are making multiple calls to the API. This will impact your overall rate limits.
  warnings.warn(
/Users/user/repositories/ads/ads/utils.py:33: UserWarning: You are lazy loading attributes via 'volume', and so are making multiple calls to the API. This will impact your overall rate limits.
  warnings.warn(
/Users/user/repositories/ads/ads/utils.py:33: UserWarning: You are lazy loading attributes via 'metrics', and so are making multiple calls to the API. This will impact your overall rate limits.
  warnings.warn(
/Users/user/repositories/ads/ads/search.py:288: UserWarning: metrics should be queried with ads.MetricsQuery(); You willhit API ratelimits very quickly otherwise.
  warnings.warn("metrics should be queried with ads.MetricsQuery(); You will"
/Users/user/repositories/ads/ads/utils.py:33: UserWarning: You are lazy loading attributes via 'bibtex', and so are making multiple calls to the API. This will impact your overall rate limits.
  warnings.warn(
/Users/user/repositories/ads/ads/search.py:295: UserWarning: bibtex should be queried with ads.ExportQuery(); You will hit API ratelimits very quickly otherwise.
  warnings.warn("bibtex should be queried with ads.ExportQuery(); You will "
..../Users/user/repositories/ads/ads/utils.py:33: UserWarning: You are lazy loading attributes via 'aff', and so are making multiple calls to the API. This will impact your overall rate limits.
  warnings.warn(
../Users/user/repositories/ads/ads/utils.py:33: UserWarning: You are lazy loading attributes via 'pubdate', and so are making multiple calls to the API. This will impact your overall rate limits.
  warnings.warn(
/Users/user/repositories/ads/ads/utils.py:33: UserWarning: You are lazy loading attributes via 'read_count', and so are making multiple calls to the API. This will impact your overall rate limits.
  warnings.warn(
/Users/user/repositories/ads/ads/utils.py:33: UserWarning: You are lazy loading attributes via 'issue', and so are making multiple calls to the API. This will impact your overall rate limits.
  warnings.warn(
.../Users/user/repositories/ads/ads/utils.py:33: UserWarning: You are lazy loading attributes via 'first_author', and so are making multiple calls to the API. This will impact your overall rate limits.
  warnings.warn(
/Users/user/repositories/ads/ads/utils.py:33: UserWarning: You are lazy loading attributes via 'author', and so are making multiple calls to the API. This will impact your overall rate limits.
  warnings.warn(
/Users/user/repositories/ads/ads/utils.py:33: UserWarning: You are lazy loading attributes via 'year', and so are making multiple calls to the API. This will impact your overall rate limits.
  warnings.warn(
.........../Users/user/repositories/ads/ads/search.py:567: DeprecationWarning: ads.query will be deprectated. Use ads.SearchQuery in the future
  warnings.warn(
..
----------------------------------------------------------------------
Ran 34 tests in 0.176s

OK (skipped=1)

I do not know why the test does not find my token in ~/.ads/dev_key, but this works for regular use.

rieder commented 2 years ago

would be good to see this fixed

JohannesBuchner commented 1 year ago

I ran into this issue as well. I was about to submit a PR when I saw this PR, which is very similar or better than what I prepared. I would recommend merging it and making a new release on pypi, please @andycasey .