Skip to content

Commit

Permalink
Merge branch 'master' into relax_urllib_dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
SlowMo24 authored Feb 21, 2024
2 parents 93eeacc + 4104b70 commit f49761b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
### Changed

- relaxed dependency requirement for `urllib3` to >=2.0.2 to prevent ohsome-py from becoming a 'diamond-dependency'
- improved and sped up testing (first steps towards [#139](https://github.com/GIScience/ohsome-py/issues/139))
- move metadata property from singleton to `chached_property`

### Fixed

- removed time-dependency of unit tests that would cause them to fail at any time after the cassettes were recorded

## 0.3.0

Expand Down
14 changes: 4 additions & 10 deletions ohsome/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""OhsomeClient classes to build and handle requests to ohsome API"""
import datetime as dt
import json
from functools import cached_property
from pathlib import Path
from typing import Union, Optional, List
from urllib.parse import urljoin
Expand Down Expand Up @@ -129,8 +130,7 @@ def __init__(
base_api_url, log, log_dir, cache, user_agent, retry
)
self._parameters = None
self._metadata = None
self._metadata_url = self.base_api_url + "metadata"
self._metadata_url = f"{self.base_api_url}metadata"

@property
def base_api_url(self):
Expand Down Expand Up @@ -164,13 +164,8 @@ def api_version(self):
"""
return self.metadata["apiVersion"]

@property
@cached_property
def metadata(self):
if self._metadata is None:
self._query_metadata()
return self._metadata

def _query_metadata(self):
"""
Send ohsome GET request
:return:
Expand All @@ -193,7 +188,7 @@ def _query_metadata(self):
error_code=e.response.status_code,
)
else:
self._metadata = response.json()
return response.json()


class _OhsomePostClient(_OhsomeBaseClient):
Expand Down Expand Up @@ -223,7 +218,6 @@ def __init__(
base_api_url, log, log_dir, cache, user_agent, retry
)
self._parameters = None
self._metadata = None
self._url = None

def post(
Expand Down

0 comments on commit f49761b

Please sign in to comment.