Skip to content

Commit

Permalink
Use List[] instead of list[] for py3.8 compliance
Browse files Browse the repository at this point in the history
  • Loading branch information
phackstock committed May 9, 2023
1 parent 2878062 commit 91baf31
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions nomenclature/core.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from typing import Optional, Union
from typing import Optional, Union, List

import pyam
from pydantic import validate_arguments
Expand All @@ -15,7 +15,7 @@ def process(
df: pyam.IamDataFrame,
dsd: DataStructureDefinition,
dimensions: Optional[list[str]] = None,
processor: Optional[Union[Processor, list[Processor]]] = None,
processor: Optional[Union[Processor, List[Processor]]] = None,
) -> pyam.IamDataFrame:
"""Function for validation and region aggregation in one step
Expand Down
16 changes: 8 additions & 8 deletions nomenclature/processor/required_data.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from pathlib import Path
from typing import Any, Optional, Union
from typing import Any, Optional, Union, List

import pydantic
import yaml
Expand All @@ -19,12 +19,12 @@
class RequiredMeasurand(BaseModel):

variable: str
unit: Optional[Union[str, list[str]]] = Field(...)
unit: Optional[Union[str, List[str]]] = Field(...)


class RequiredData(BaseModel):

measurand: list[RequiredMeasurand]
measurand: List[RequiredMeasurand]
region: Optional[list[str]]
year: Optional[list[int]]

Expand Down Expand Up @@ -63,11 +63,11 @@ def validate_with_definition(self, dsd: DataStructureDefinition) -> None:
raise ValueError(error_msg)

@property
def variable(self) -> list[str]:
def variable(self) -> List[str]:
return [m.variable for m in self.measurand]

@property
def pyam_required_data_list(self) -> list[dict]:
def pyam_required_data_list(self) -> List[dict]:

return [
{
Expand All @@ -81,8 +81,8 @@ def pyam_required_data_list(self) -> list[dict]:

def _wrong_unit_variables(
self, dsd: DataStructureDefinition
) -> list[tuple[str, str, str]]:
wrong_units: list[tuple[str, Any, Any]] = []
) -> List[tuple[str, str, str]]:
wrong_units: List[tuple[str, Any, Any]] = []
if hasattr(dsd, "variable"):
wrong_units.extend(
(m.variable, m.unit, dsd.variable[m.variable].unit)
Expand All @@ -97,7 +97,7 @@ def _wrong_unit_variables(
class RequiredDataValidator(Processor):

name: str
required_data: list[RequiredData]
required_data: List[RequiredData]
file: Path

@classmethod
Expand Down

0 comments on commit 91baf31

Please sign in to comment.