Skip to content

Commit

Permalink
Again resolve SonarCloud complain: Remove unused parameter token
Browse files Browse the repository at this point in the history
  • Loading branch information
juhoinkinen committed Sep 30, 2024
1 parent 4dfa2d1 commit caf0325
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion annif/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ def run_download(project_ids_pattern, repo_id, token, revision, force, trust_rep
`--trust-repo` option needs to be used.
"""

hfh_util.check_is_download_allowed(trust_repo, repo_id, token)
hfh_util.check_is_download_allowed(trust_repo, repo_id)

project_ids = hfh_util.get_matching_project_ids_from_hf_hub(
project_ids_pattern, repo_id, token, revision
Expand Down
2 changes: 1 addition & 1 deletion annif/hfh_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
logger = annif.logger


def check_is_download_allowed(trust_repo, repo_id, token):
def check_is_download_allowed(trust_repo, repo_id):
"""Check if downloading from the specified repository is allowed based on the trust
option and cache status."""
if trust_repo:
Expand Down
9 changes: 3 additions & 6 deletions tests/test_hfh_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
def test_download_allowed_trust_repo(mock_is_repo_in_cache, caplog):
trust_repo = True
repo_id = "dummy-repo"
token = "dummy-token"

with caplog.at_level(logging.WARNING, logger="annif"):
annif.hfh_util.check_is_download_allowed(trust_repo, repo_id, token)
annif.hfh_util.check_is_download_allowed(trust_repo, repo_id)
assert (
'Download allowed from "dummy-repo" because "--trust-repo" flag is used.'
in caplog.text
Expand All @@ -34,10 +33,9 @@ def test_download_allowed_trust_repo(mock_is_repo_in_cache, caplog):
def test_download_allowed_repo_in_cache(mock_is_repo_in_cache, caplog):
trust_repo = False
repo_id = "dummy-repo"
token = "dummy-token"

with caplog.at_level(logging.DEBUG, logger="annif"):
annif.hfh_util.check_is_download_allowed(trust_repo, repo_id, token)
annif.hfh_util.check_is_download_allowed(trust_repo, repo_id)
assert (
'Download allowed from "dummy-repo" because repo is already in cache.'
in caplog.text
Expand All @@ -48,10 +46,9 @@ def test_download_allowed_repo_in_cache(mock_is_repo_in_cache, caplog):
def test_download_not_allowed(mock_is_repo_in_cache):
trust_repo = False
repo_id = "dummy-repo"
token = "dummy-token"

with pytest.raises(OperationFailedException) as excinfo:
annif.hfh_util.check_is_download_allowed(trust_repo, repo_id, token)
annif.hfh_util.check_is_download_allowed(trust_repo, repo_id)
assert (
str(excinfo.value)
== 'Cannot download projects from untrusted repo "dummy-repo"'
Expand Down

0 comments on commit caf0325

Please sign in to comment.