From 0d583be4b1dbefc224f95d3a29a4d0d2f007d4ec Mon Sep 17 00:00:00 2001 From: Chris Mutel Date: Fri, 5 Jul 2024 10:45:18 +0200 Subject: [PATCH] Restore 3.9 compatibility --- .github/workflows/python-test.yml | 2 +- bw2io/extractors/ecospold1.py | 4 ++-- bw2io/importers/ecoinvent_lcia.py | 3 ++- bw2io/importers/ecospold2.py | 4 ++-- bw2io/importers/ecospold2_biosphere.py | 3 ++- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/python-test.yml b/.github/workflows/python-test.yml index 422720c..d41468a 100644 --- a/.github/workflows/python-test.yml +++ b/.github/workflows/python-test.yml @@ -36,7 +36,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-13, ubuntu-20.04, macos-latest, windows-2019] - py-version: ["3.10", "3.11", "3.12"] + py-version: ["3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v4 diff --git a/bw2io/extractors/ecospold1.py b/bw2io/extractors/ecospold1.py index 01d6951..94052cb 100644 --- a/bw2io/extractors/ecospold1.py +++ b/bw2io/extractors/ecospold1.py @@ -3,7 +3,7 @@ import os from io import StringIO from pathlib import Path -from typing import Any, Union +from typing import Any, Union, Optional import numpy as np import pyecospold @@ -18,7 +18,7 @@ from tqdm import tqdm -def robust_text(root: etree.ElementBase, attribute: str) -> str | None: +def robust_text(root: etree.ElementBase, attribute: str) -> Optional[str]: """Just because the spec says it must be there doesn't mean it will be.""" try: return getattr(root, attribute).text diff --git a/bw2io/importers/ecoinvent_lcia.py b/bw2io/importers/ecoinvent_lcia.py index 3edfdf4..8054e70 100644 --- a/bw2io/importers/ecoinvent_lcia.py +++ b/bw2io/importers/ecoinvent_lcia.py @@ -1,6 +1,7 @@ import functools import warnings from numbers import Number +from typing import Optional from bw2data import Database, config @@ -21,7 +22,7 @@ class EcoinventLCIAImporter(LCIAImporter): """ - def __init__(self, biosphere_database: str | None = None): + def __init__(self, biosphere_database: Optional[str] = None): """Initialize an instance of EcoinventLCIAImporter. Defines strategies in ``__init__`` because ``config.biosphere`` is dynamic. diff --git a/bw2io/importers/ecospold2.py b/bw2io/importers/ecospold2.py index 4a67fec..1db4082 100644 --- a/bw2io/importers/ecospold2.py +++ b/bw2io/importers/ecospold2.py @@ -1,7 +1,7 @@ from functools import partial from pathlib import Path from time import time -from typing import Any +from typing import Any, Optional from bw2data import Database, config @@ -52,7 +52,7 @@ def __init__( self, dirpath: str, db_name: str, - biosphere_database_name: str | None = None, + biosphere_database_name: Optional[str] = None, extractor: Any = Ecospold2DataExtractor, use_mp: bool = True, signal: Any = None, diff --git a/bw2io/importers/ecospold2_biosphere.py b/bw2io/importers/ecospold2_biosphere.py index eb8cf4d..866abfa 100644 --- a/bw2io/importers/ecospold2_biosphere.py +++ b/bw2io/importers/ecospold2_biosphere.py @@ -1,6 +1,7 @@ import json import os from pathlib import Path +from typing import Optional from bw2data.utils import recursive_str_to_unicode from lxml import objectify @@ -46,7 +47,7 @@ def __init__( self, name: str = "biosphere3", version: str = "3.9", - filepath: Path | None = None, + filepath: Optional[Path] = None, ): """ Initialize the importer.