Skip to content

Commit

Permalink
Blacken and make expection msg an f-string
Browse files Browse the repository at this point in the history
  • Loading branch information
CasperWA committed Feb 6, 2020
1 parent 6a60379 commit 80e2dcc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions optimade/models/baseinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,16 @@ def version_must_be_valid(cls, v):
@root_validator(pre=False, skip_on_failure=True)
def crosscheck_url_and_version(cls, values):
""" Check that URL version and API version are compatible. """
url_version = values["url"].split("/")[-2 if values["url"].endswith('/') else -1].replace('v', '')
url_version = tuple(int(val) for val in url_version.split('.'))
url_version = (
values["url"]
.split("/")[-2 if values["url"].endswith("/") else -1]
.replace("v", "")
)
url_version = tuple(int(val) for val in url_version.split("."))
api_version = tuple(int(val) for val in values["version"].split("."))
if any(a != b for a, b in zip(url_version, api_version)):
raise ValueError(
"API version {api_version} is not compatible with url version {url_version}."
f"API version {api_version} is not compatible with url version {url_version}."
)

return values
Expand Down

0 comments on commit 80e2dcc

Please sign in to comment.