Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decorators not processed successfully with alpha_vantage #8303

Open
AnthonyZ71 opened this issue Feb 16, 2023 · 1 comment
Open

decorators not processed successfully with alpha_vantage #8303

AnthonyZ71 opened this issue Feb 16, 2023 · 1 comment
Labels
Decorators Lib specific 💅 This affect the code from a particular library Needs investigation 🔬 A bug or crash where it's not immediately obvious what is happenning

Comments

@AnthonyZ71
Copy link

AnthonyZ71 commented Feb 16, 2023

Bug description

Using pip install --upgrade alpha_vantage and the following application (av_pylint_test.py):

#!/usr/bin/env python
"""Example application to demonstrate pylint false positives"""
import os

from alpha_vantage.timeseries import TimeSeries

api_key = os.getenv("AV_API_KEY")
time_series = TimeSeries(key=api_key)
av_data, _ = time_series.get_daily_adjusted("IBM", "compact")
av_quote_dates = av_data.keys()
for quote_date in av_quote_dates:
    print(f"{quote_date} : {av_data[quote_date]['4. close']}")

Unfortunately, to get an ALPHA VANTAGE API key they do require to register with their website. Using the demo key doesn't work.

This may be a duplicate of #7437 but I'm not sure if that is the case or not.

Following the code a little bit:

    @av._output_format
    @av._call_api_on_func
    def get_daily_adjusted(self, symbol, outputsize='compact'):
        _FUNCTION_KEY = "TIME_SERIES_DAILY_ADJUSTED"
        return _FUNCTION_KEY, 'Time Series (Daily)', 'Meta Data'

The _call_api_on_func looks like it creates and returns a wrapper function that invokes the API which is then passed into _output_format which creates another wrapper around the function to convert the output of the API into the requested format.

Command used

pylint av_pylint_test.py

Pylint output

************* Module av_pylint_test
av_pylint_test.py:9:0: W0632: Possible unbalanced tuple unpacking with sequence defined at line 76 of alpha_vantage.timeseries: left side has 2 labels, right side has 3 values (unbalanced-tuple-unpacking)
av_pylint_test.py:10:17: E1101: Instance of 'str' has no 'keys' member (no-member)

------------------------------------------------------------------
Your code has been rated at 2.50/10 (previous run: 2.50/10, +0.00)

Expected behavior

pylint would follow the decorators and understand the actual output.

Pylint version

pylint 2.16.2
astroid 2.14.2
Python 3.11.2 (main, Feb 11 2023, 02:24:27) [GCC 10.2.1 20210110]

OS / Environment

vscode devcontainer based upon mcr.microsoft.com/devcontainers/python:3

Additional dependencies

alpha-vantage==2.3.1
pandas==1.5.3

There are a lot of other libraries loaded into this environment. In case there are additional dependencies that I didn't realize, this is the full output of the pip freeze:

absl-py==1.4.0
aiohttp==3.8.4
aiosignal==1.3.1
alpha-vantage==2.3.1
anyio==3.6.2
appdirs==1.4.4
astroid==2.14.2
astunparse==1.6.3
async-generator==1.10
async-timeout==4.0.2
attrs==22.2.0
Authlib==1.2.0
autopep8==2.0.1
beautifulsoup4==4.11.2
cachetools==5.3.0
certifi==2022.12.7
cffi==1.15.1
charset-normalizer==3.0.1
contourpy==1.0.7
cryptography==39.0.1
cycler==0.11.0
dill==0.3.6
flatbuffers==23.1.21
fonttools==4.38.0
frozendict==2.3.4
frozenlist==1.3.3
gast==0.4.0
google-auth==2.16.0
google-auth-oauthlib==0.4.6
google-pasta==0.2.0
greenlet==2.0.1
grpcio==1.51.1
h11==0.14.0
h5py==3.8.0
html5lib==1.1
httpcore==0.16.3
httpx==0.23.3
idna==3.4
isort==5.12.0
jax==0.4.3
keras-nightly==2.13.0.dev2023021508
kiwisolver==1.4.4
lazy-object-proxy==1.9.0
libclang==15.0.6.1
lxml==4.9.2
mariadb==1.1.5.post3
Markdown==3.4.1
MarkupSafe==2.1.2
matplotlib==3.7.0
mccabe==0.7.0
multidict==6.0.4
multitasking==0.0.11
numpy==1.23.5
nvidia-cublas-cu11==11.10.3.66
nvidia-cuda-nvrtc-cu11==11.7.99
nvidia-cuda-runtime-cu11==11.7.99
nvidia-cudnn-cu11==8.5.0.96
oath==1.4.4
oauthlib==3.2.2
opt-einsum==3.3.0
outcome==1.2.0
packaging==23.0
pandas==1.5.3
Pillow==9.4.0
platformdirs==3.0.0
playwright==1.30.0
playwright-stealth==1.0.5
prompt-toolkit==3.0.36
protobuf==4.21.12
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycodestyle==2.10.0
pycparser==2.21
pycryptodome==3.17
pyee==9.0.4
pylint==2.16.2
pyotp==2.8.0
pyparsing==3.0.9
PySocks==1.7.1
python-dateutil==2.8.2
python-vipaccess==0.14.1
pytz==2022.7.1
requests==2.28.2
requests-oauthlib==1.3.1
rfc3986==1.5.0
rsa==4.9
schwab-api==0.2.2
scipy==1.10.0
selenium==4.8.0
six==1.16.0
sniffio==1.3.0
sortedcontainers==2.4.0
soupsieve==2.4
SQLAlchemy==2.0.3
ta==0.10.2
tb-nightly==2.13.0a20230215
tda-api==1.6.0
tensorboard-data-server==0.7.0
tensorboard-plugin-wit==1.8.1
tensorflow-io-gcs-filesystem==0.30.0
termcolor==2.2.0
tf-estimator-nightly==2.13.0.dev2023021509
tf-nightly==2.13.0.dev20230215
tomlkit==0.11.6
torch==1.13.1
trio==0.22.0
trio-websocket==0.9.2
typing_extensions==4.5.0
urllib3==1.26.14
wcwidth==0.2.6
webencodings==0.5.1
websockets==10.4
Werkzeug==2.2.3
wrapt==1.14.1
wsproto==1.2.0
yarl==1.8.2
yfinance==0.2.11
@AnthonyZ71 AnthonyZ71 added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Feb 16, 2023
@AnthonyZ71
Copy link
Author

Running the sample application this morning results in:

$ ./av_pylint_test.py 
2023-02-15 : 136.4
2023-02-14 : 136.01
...
2022-09-26 : 122.01
2022-09-23 : 122.71

@Pierre-Sassoulas Pierre-Sassoulas added Decorators Lib specific 💅 This affect the code from a particular library Needs investigation 🔬 A bug or crash where it's not immediately obvious what is happenning and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Decorators Lib specific 💅 This affect the code from a particular library Needs investigation 🔬 A bug or crash where it's not immediately obvious what is happenning
Projects
None yet
Development

No branches or pull requests

2 participants