diff --git a/conda_forge_tick/update_prs.py b/conda_forge_tick/update_prs.py index 2e60c658ec..02812ded1a 100644 --- a/conda_forge_tick/update_prs.py +++ b/conda_forge_tick/update_prs.py @@ -23,10 +23,6 @@ # from conda_forge_tick.profiler import profiling - -if typing.TYPE_CHECKING: - from .cli import CLIArgs - logger = logging.getLogger("conda_forge_tick.update_prs") NUM_GITHUB_THREADS = 2 diff --git a/conda_forge_tick/update_upstream_versions.py b/conda_forge_tick/update_upstream_versions.py index 9378a0a410..59e0461628 100644 --- a/conda_forge_tick/update_upstream_versions.py +++ b/conda_forge_tick/update_upstream_versions.py @@ -9,6 +9,7 @@ Dict, Iterable, Iterator, + List, Literal, Mapping, Optional, @@ -65,7 +66,7 @@ def get_latest_version( name: str, attrs: Mapping[str, Any], sources: Iterable[AbstractSource], -) -> Dict[str, Union[bool, str]]: +) -> Dict[str, Union[Literal[False], str]]: """ Given a package, return the new version information to be written into the cf-graph. :param name: the name of the package. @@ -87,19 +88,23 @@ def get_latest_version( {}, None, ) + + sources_to_use: Iterable[AbstractSource] if version_sources is not None: version_sources = [vs.lower() for vs in version_sources] - sources_to_use = [] + sources_to_use_list = [] for vs in version_sources: for source in sources: if source.name.lower() == vs: - sources_to_use.append(source) + sources_to_use_list.append(source) break else: logger.warning( f"Package {name} requests version source '{vs}' which is not available. Skipping.", ) + sources_to_use = sources_to_use_list + logger.debug( f"{name} defines the following custom version sources: {[source.name for source in sources_to_use]}", ) @@ -215,12 +220,12 @@ def include_node(package_name: str, payload_attrs: Mapping) -> bool: def _update_upstream_versions_sequential( to_update: Iterable[Tuple[str, Mapping]], - sources: Iterable[AbstractSource] = None, + sources: Iterable[AbstractSource], ) -> None: node_count = 0 for node, attrs in to_update: # checking each node - version_data = {} + version_data: Dict[str, Union[Literal[False], str]] = {} # New version request try: @@ -273,7 +278,7 @@ def _update_upstream_versions_process_pool( n_left = len(futures) start = time.time() # eta :: elapsed time average - eta = -1 + eta = -1.0 for f in as_completed(futures): n_left -= 1 if n_left % 10 == 0: @@ -315,7 +320,7 @@ def _update_upstream_versions_process_pool( def update_upstream_versions( gx: nx.DiGraph, - sources: Iterable[AbstractSource] = None, + sources: Optional[Iterable[AbstractSource]] = None, debug: bool = False, job=1, n_jobs=1, diff --git a/tests/test_upstream_versions.py b/tests/test_upstream_versions.py index 36e2e251c7..01e9585e81 100644 --- a/tests/test_upstream_versions.py +++ b/tests/test_upstream_versions.py @@ -2,7 +2,7 @@ import os import random from concurrent.futures import Future -from typing import Mapping +from typing import Dict, Mapping from unittest import mock from unittest.mock import MagicMock, Mock, patch @@ -1145,7 +1145,7 @@ def test_include_node_parsing_error(caplog): def test_include_node_no_payload(): package_name = "testpackage" - payload_attrs = {} + payload_attrs: Dict = {} assert include_node(package_name, payload_attrs) @@ -1467,8 +1467,8 @@ def test_update_upstream_versions_process_pool( ("testpackage2", {"version": "1.2.4"}), ] - future_1 = Future() - future_2 = Future() + future_1: Future[Dict[str, str]] = Future() + future_2: Future[Dict[str, str]] = Future() pool_mock = executor_mock.return_value.__enter__.return_value pool_mock.submit.side_effect = [future_1, future_2] @@ -1518,7 +1518,7 @@ def test_update_upstream_versions_process_pool_exception( ("testpackage", {"version": "2.2.3"}), ] - future = Future() + future: Future[Dict[str, str]] = Future() pool_mock = executor_mock.return_value.__enter__.return_value pool_mock.submit.return_value = future @@ -1561,7 +1561,7 @@ def test_update_upstream_versions_process_pool_exception_repr_exception( ("testpackage", {"version": "2.2.3"}), ] - future = Future() + future: Future[Dict[str, str]] = Future() pool_mock = executor_mock.return_value.__enter__.return_value pool_mock.submit.return_value = future