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

Need to _switch_endpoints on fields #138

Open
ptwales opened this issue Jan 17, 2024 · 0 comments
Open

Need to _switch_endpoints on fields #138

ptwales opened this issue Jan 17, 2024 · 0 comments

Comments

@ptwales
Copy link

ptwales commented Jan 17, 2024

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.

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

No branches or pull requests

1 participant