fix pyright lints (#188)

This commit is contained in:
figsoda 2023-08-14 04:08:55 -04:00 committed by GitHub
parent aee90c0274
commit 1186454210
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -1,6 +1,6 @@
import re
from functools import partial
from typing import Callable, List, Optional
from typing import Callable, List, Optional, Protocol
from urllib.parse import ParseResult
from ..errors import VersionError
@ -23,6 +23,12 @@ from .version import Version, VersionPreference
# return repo["version"]
# return None
class SnapshotFetcher(Protocol):
def __call__(self, url: ParseResult, branch: str) -> List[Version]:
...
fetchers: List[Callable[[ParseResult], List[Version]]] = [
fetch_crate_versions,
fetch_pypi_versions,
@ -34,7 +40,7 @@ fetchers: List[Callable[[ParseResult], List[Version]]] = [
fetch_sourcehut_versions,
]
branch_snapshots_fetchers: List[Callable[[ParseResult, str], List[Version]]] = [
branch_snapshots_fetchers: List[SnapshotFetcher] = [
fetch_gitea_snapshots,
fetch_github_snapshots,
fetch_gitlab_snapshots,

View File

@ -13,10 +13,12 @@ TEST_ROOT = Path(__file__).parent.resolve()
def fake_urlopen(url: str) -> BinaryIO:
del url
return open(TEST_ROOT.joinpath("test_branch.atom"), "rb")
def test_branch(helpers: conftest.Helpers) -> None:
del helpers
with unittest.mock.patch("urllib.request.urlopen", fake_urlopen):
assert (
fetch_latest_version(