Skip to content

Commit

Permalink
Fix regression in Snakebids version lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
pvandyken committed Dec 13, 2023
1 parent dfe4334 commit ede325e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
11 changes: 5 additions & 6 deletions snakebids/jinja2_ext/snakebids_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ def _lookup_version(self):
version_regex = re.compile(r"\d+\.\d+\.\d+")
try:
request.raise_for_status()
except (requests.HTTPError, KeyError):
version = impm.version("snakebids")
else:
version = request.json()["info"]["version"]

if version == "0.0.0" or not re.fullmatch(version_regex, version):
return None
version = version_regex.fullmatch(version).group() # type: ignore
except (requests.HTTPError, KeyError, AttributeError, TypeError):
version = impm.version("snakebids")
if version == "0.0.0" or not version_regex.fullmatch(version):
return None
return version
5 changes: 3 additions & 2 deletions snakebids/tests/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ def test_gets_correct_snakebids_version(
json={"info": {"version": server}},
status_code=server_status,
)
metadata_patch = mocker.patch("importlib.metadata.version")
metadata_patch.return_value = metadata
from snakebids.jinja2_ext.snakebids_version import impm

mocker.patch.object(impm, "version", return_value=metadata)
data = get_empty_data("testapp", build)
copier.run_copy(
str(Path(itx.first(snakebids.__path__), "project_template")),
Expand Down

0 comments on commit ede325e

Please sign in to comment.