diff --git a/nomenclature/codelist.py b/nomenclature/codelist.py index 6167dd4d..aa7b6d43 100644 --- a/nomenclature/codelist.py +++ b/nomenclature/codelist.py @@ -275,8 +275,8 @@ def to_yaml(self, path=None): """ class Dumper(yaml.Dumper): - def increase_indent(self, flow=False, *args, **kwargs): - return super().increase_indent(flow=flow, indentless=False) + def increase_indent(self, flow: bool = False, indentless: bool = False): + return super().increase_indent(flow=flow, indentless=indentless) # translate to list of nested dicts, replace None by empty field, write to file stream = ( @@ -289,11 +289,10 @@ def increase_indent(self, flow=False, *args, **kwargs): .replace(": nan\n", ":\n") ) - if path is not None: - with open(path, "w") as file: - file.write(stream) - else: + if path is None: return stream + with open(path, "w") as file: + file.write(stream) def to_pandas(self, sort_by_code: bool = False) -> pd.DataFrame: """Export the CodeList to a :class:`pandas.DataFrame` @@ -586,7 +585,7 @@ def hierarchy(self) -> List[str]: List[str] """ - return sorted(list(set(v.hierarchy for v in self.mapping.values()))) + return sorted(list({v.hierarchy for v in self.mapping.values()})) class MetaCodeList(CodeList): diff --git a/nomenclature/core.py b/nomenclature/core.py index e228f924..c3d8a1e9 100644 --- a/nomenclature/core.py +++ b/nomenclature/core.py @@ -10,7 +10,7 @@ logger = logging.getLogger(__name__) -@validate_arguments(config=dict(arbitrary_types_allowed=True)) +@validate_arguments(config={"arbitrary_types_allowed": True}) def process( df: pyam.IamDataFrame, dsd: DataStructureDefinition,