Closed dt-woods closed 6 months ago
Hi @dt-woods,
We have just included some changes that should solve that. Let us know if this works after updating olca-ipc.py
: pip install -U git+https://github.com/GreenDelta/olca-ipc.py.git/@master
Hey @Miguel-g-c , thanks. I believe you missed another one, below the diff
I needed to get import olca
to work. Thanks for the hard work!
You simply need to replace tuple[...]
with Tuple[...]
and of course import Tuple
from typing
at the top.
/work/openlca/olca-ipc.py$ git diff
diff --git a/olca/ipc.py b/olca/ipc.py
index 5d831fc..ae400aa 100644
--- a/olca/ipc.py
+++ b/olca/ipc.py
@@ -7,7 +7,7 @@ import olca.upstream_tree as utree
from dataclasses import dataclass
-from typing import Any, Iterator, List, Optional, Type, TypeVar, Union
+from typing import Any, Iterator, List, Optional, Tuple, Type, TypeVar, Union
E = TypeVar('E', bound=schema.RootEntity)
ModelType = Union[Type[E], str]
@@ -1003,7 +1003,7 @@ class Client(object):
return None
return utree.UpstreamTree.from_json(raw)
- def __post(self, method: str, params) -> tuple[Any, Optional[str]]:
+ def __post(self, method: str, params) -> Tuple[Any, Optional[str]]:
"""
Performs a request with the given parameters.
Hey @selimyoussry, thanks for pointing that out! I've just created a PR which should be merged soon 😁
When using USEPA's electricityLCI Python package, olca is imported via fedelemflowlist. When running the script through main.py, no errors, but when individual modules are loaded, the following TypeError was encountered. A little research turned up that the annotation style used in ipc.py is supported in Python 3.9+; however, not for Python 3.8 (which is being used here).
A simple fix would be to add a Python version check (e.g.,
sys.version
) and for versions that don't support these annotations, add a future import,from __future__ import annotations
, which solved the problem on my end.*this is the first of many TypeErrors encountered
More information available on StackOverflow <-- This is not the exact site I found earlier, but close enough.