AG3NTZ3R0 / cnbc

A Python package that wraps CNBC API endpoints and returns financial data in JSON.
https://pypi.org/project/cnbc/
GNU General Public License v3.0
4 stars 0 forks source link

[BUG] Circular import #16

Closed lwinkler closed 2 months ago

lwinkler commented 2 months ago

Overview

Hi. Thanks for taking the time to do this python utility. Sadly I cannot use it due to a circular import. I ran into this issue by running the example you give on pypi:

I use python 3.11.6

Reproduction Procedure

# cnbc.py 
from cnbc import APIWrapper, Endpoints

api_wrapper = APIWrapper(
    api_key='YOUR_API_KEY',
    endpoint=Endpoints.TRANSLATE
)
# The APIWrapper class will supply the required parameters for the configured CNBC API endpoint.
api_wrapper_params = api_wrapper.params
api_wrapper_params['symbol'] = 'AAPL'
# The APIWrapper class will make a request to the CNBC API and return the response in JSON.
json_response = api_wrapper.request()

# The APIWrapper class can be repurposed to make multiple requests to the CNBC API.
api_wrapper.endpoint = Endpoints.GET_SUMMARY
api_wrapper_params = api_wrapper.params
api_wrapper_params['issueIds'] = json_response['issueId']
json_response = api_wrapper.request()

$ python3 cnbc.py Traceback (most recent call last): File "/home/lwinkler/prog/python/stocki/stocki/services/cnbc.py", line 1, in from cnbc import APIWrapper, Endpoints File "/home/lwinkler/prog/python/stocki/stocki/services/cnbc.py", line 1, in from cnbc import APIWrapper, Endpoints ImportError: cannot import name 'APIWrapper' from partially initialized module 'cnbc' (most likely due to a circular import) (/home/lwinkler/prog/python/stocki/stocki/services/cnbc.py) zsh: exit 1 python3 cnbc.py

``

lwinkler commented 2 months ago

Hi. Please ignore this issue. This was due to the name of the file that I used: cnbc.py This was responsible for the circular import of course.