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 a4e3481 commit 9173823
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

Check warning on line 2 in ixmp4/cli/platforms.py

View check run for this annotation

Codecov / codecov/patch

ixmp4/cli/platforms.py#L2

Added line #L2 was not covered by tests
from itertools import cycle
from pathlib import Path
from typing import Optional

Check warning on line 5 in ixmp4/cli/platforms.py

View check run for this annotation

Codecov / codecov/patch

ixmp4/cli/platforms.py#L5

Added line #L5 was not covered by tests
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:

Check warning on line 275 in ixmp4/cli/platforms.py

View check run for this annotation

Codecov / codecov/patch

ixmp4/cli/platforms.py#L275

Added line #L275 was not covered by tests
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

Check warning on line 3 in ixmp4/data/generator.py

View check run for this annotation

Codecov / codecov/patch

ixmp4/data/generator.py#L3

Added line #L3 was not covered by tests
from datetime import datetime, timedelta
from itertools import cycle
from typing import Any

Check warning on line 6 in ixmp4/data/generator.py

View check run for this annotation

Codecov / codecov/patch

ixmp4/data/generator.py#L6

Added line #L6 was not covered by tests
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]:

Check warning on line 45 in ixmp4/data/generator.py

View check run for this annotation

Codecov / codecov/patch

ixmp4/data/generator.py#L45

Added line #L45 was not covered by tests
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 9173823

Please sign in to comment.