Skip to content

Commit

Permalink
remove unsued attributes from ohsome response (debatable and, if stri…
Browse files Browse the repository at this point in the history
…ct is a major breaking change)
  • Loading branch information
SlowMo24 committed Sep 3, 2024
1 parent a0ac8e5 commit 3d3bd1c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ohsome/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def _handle_request(self) -> OhsomeResponse:
ohsome_exception.log(self.log_dir)
raise ohsome_exception

return OhsomeResponse(response, url=self._url, params=self._parameters)
return OhsomeResponse(data=data, url=self._url)

def _format_parameters(self, params):
"""
Expand Down
6 changes: 2 additions & 4 deletions ohsome/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@
class OhsomeResponse:
"""Contains the response of the request to the ohsome API"""

def __init__(self, response=None, url=None, params=None):
def __init__(self, data: dict, url: str = None):
"""Initialize the OhsomeResponse class."""
self.response = response
self.data = data
self.url = url
self.parameters = params
self.data = response.json()

def as_dataframe(
self, multi_index: Optional[bool] = True, explode_tags: Optional[tuple] = ()
Expand Down
2 changes: 1 addition & 1 deletion ohsome/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,4 @@ def dummy_ohsome_response() -> OhsomeResponse:
)
response = Response()
response._content = test_gdf.to_json().encode()
return OhsomeResponse(response=response)
return OhsomeResponse(data=response.json())
2 changes: 1 addition & 1 deletion ohsome/test/test_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ def test_explode_tags_present_on_empty_result():
'{"attribution":{"url":"https://ohsome.org/copyrights","text":"© OpenStreetMap contributors"},'
'"apiVersion":"1.10.1","type":"FeatureCollection","features":[]}'
).encode()
computed_df = OhsomeResponse(response=response).as_dataframe(
computed_df = OhsomeResponse(data=response.json()).as_dataframe(
explode_tags=("some_key", "some_other_key")
)

Expand Down

0 comments on commit 3d3bd1c

Please sign in to comment.