Skip to content

Commit

Permalink
Fix type hints for itertools.cycle()
Browse files Browse the repository at this point in the history
  • Loading branch information
glatterf42 committed Nov 12, 2024
1 parent 8c994bd commit 46dca74
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions ixmp4/cli/platforms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import re
from collections.abc import Generator
from collections.abc import Generator, Iterator
from itertools import cycle
from pathlib import Path
from typing import Optional
Expand Down Expand Up @@ -272,7 +272,7 @@ def generate(
utils.good("Done!")


def create_cycle(generator: Generator, name: str, total: int) -> cycle:
def create_cycle(generator: Generator, name: str, total: int) -> Iterator:
return cycle(
[
m
Expand Down
12 changes: 6 additions & 6 deletions ixmp4/data/generator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import random
import sys
from collections.abc import Generator
from collections.abc import Generator, Iterator
from datetime import datetime, timedelta
from itertools import cycle
from typing import Any
Expand Down Expand Up @@ -42,7 +42,7 @@ def yield_model_names(self) -> Generator[str, Any, None]:
for i in range(self.num_models):
yield f"Model {i}"

def yield_runs(self, model_names: cycle[str]) -> Generator[Run, Any, None]:
def yield_runs(self, model_names: Iterator[str]) -> Generator[Run, Any, None]:
scen_per_model = self.num_runs // self.num_models
if scen_per_model == 0:
scen_per_model = 1
Expand Down Expand Up @@ -81,10 +81,10 @@ def yield_variable_names(self) -> Generator[str, Any, None]:

def yield_datapoints(
self,
runs: cycle[Run],
variable_names: cycle[str],
units: cycle[Unit],
regions: cycle[Region],
runs: Iterator[Run],
variable_names: Iterator[str],
units: Iterator[Unit],
regions: Iterator[Region],
) -> Generator[pd.DataFrame, Any, None]:
dp_count = 0
for run in runs:
Expand Down

0 comments on commit 46dca74

Please sign in to comment.