Skip to content

Need to _switch_endpoints on fields #138

@ptwales

Description

@ptwales

The following works

tables = c.acs5.tables(year=2020)
fields = c.acs5.fields(year=2020)

The following raises a json decode error from a 404 response

fields = c.acs5.fields(year=2020)

This is because ACSClient.tables calls _switch_endpoints which mutates the state of the client. which ACSClient.fields does not. The simplest hotfix is to add the following code to ACSClient

    def fields(self, *args, **kwargs):
        self._switch_endpoints(kwargs.get("year", self.default_year))
        return super(ACSClient, self).fields(*args, **kwargs)

But I highly suggest removing the mutable state from ACSClient.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions