From 91baf310f64c12b17e6b224e73a50fd63dac6fd7 Mon Sep 17 00:00:00 2001 From: Philip Hackstock <20710924+phackstock@users.noreply.github.com> Date: Tue, 9 May 2023 14:11:03 +0200 Subject: [PATCH] Use List[] instead of list[] for py3.8 compliance --- nomenclature/core.py | 4 ++-- nomenclature/processor/required_data.py | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/nomenclature/core.py b/nomenclature/core.py index c41e16e0..7d047857 100644 --- a/nomenclature/core.py +++ b/nomenclature/core.py @@ -1,5 +1,5 @@ import logging -from typing import Optional, Union +from typing import Optional, Union, List import pyam from pydantic import validate_arguments @@ -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 diff --git a/nomenclature/processor/required_data.py b/nomenclature/processor/required_data.py index 3c99f540..ffa026ea 100644 --- a/nomenclature/processor/required_data.py +++ b/nomenclature/processor/required_data.py @@ -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 @@ -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]] @@ -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 [ { @@ -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) @@ -97,7 +97,7 @@ def _wrong_unit_variables( class RequiredDataValidator(Processor): name: str - required_data: list[RequiredData] + required_data: List[RequiredData] file: Path @classmethod