Skip to content

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

Closed
@zsimpso

Description

@zsimpso

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions