Skip to content

NetworkBase fetch() and fetch_data() headers param listed as wrong type #31

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

Closed
zsimpso opened this issue Apr 19, 2021 · 0 comments · Fixed by #32
Closed

NetworkBase fetch() and fetch_data() headers param listed as wrong type #31

zsimpso opened this issue Apr 19, 2021 · 0 comments · Fixed by #32

Comments

@zsimpso
Copy link
Contributor

zsimpso commented Apr 19, 2021

In working on a project and reading the docs for PortalBase.network I ran into a lot of confusion seeing that fetch() has headers as a list type[0].

Seeings how header params are nearly always a dictionary I decided to pass a dictionary and it worked. Also, from what I understand the underlying adafruit_requests is based on they Python Requests library, which also uses a dictionary for headers params[1].

When I try and pass a list I encounter the following traceback:

  File "code.py", line 34, in <module>
  File "code.py", line 30, in fetch_data
  File "adafruit_portalbase/network.py", line 548, in fetch_data
  File "adafruit_portalbase/network.py", line 467, in fetch
  File "adafruit_requests.py", line 684, in get
  File "adafruit_requests.py", line 567, in request
  File "adafruit_requests.py", line 565, in request
  File "adafruit_requests.py", line 494, in _send_request
  TypeError: list indices must be integers, not str

Looking into adafruit_requests it does indeed look to expect a dict[2].

[0] https://github.com/adafruit/Adafruit_CircuitPython_PortalBase/blob/main/adafruit_portalbase/network.py#L450
[1] https://docs.python-requests.org/en/master/user/quickstart/#custom-headers
[2] https://github.com/adafruit/Adafruit_CircuitPython_Requests/blob/master/adafruit_requests.py#L533

makermelissa added a commit that referenced this issue Apr 19, 2021
#31: update docstrings to be proper type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant