From e75f31b6a7737f46b61d45332cfd51ec72e6b03b Mon Sep 17 00:00:00 2001
From: Timothe Jost <timothe.jost@wanadoo.fr>
Date: Wed, 29 May 2024 23:11:42 +0200
Subject: [PATCH] changes to pipelines to use typehinting for dynamics
 attributes (but not very well done. Might remove this later if it causes more
 isses than it helps)

---
 src/pypelines/__init__.py  | 2 +-
 src/pypelines/pipelines.py | 7 ++++++-
 src/pypelines/pipes.py     | 7 ++++++-
 src/pypelines/steps.py     | 4 ++--
 4 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/pypelines/__init__.py b/src/pypelines/__init__.py
index 93cb8a1..4fd42c1 100644
--- a/src/pypelines/__init__.py
+++ b/src/pypelines/__init__.py
@@ -1,4 +1,4 @@
-__version__ = "0.0.59"
+__version__ = "0.0.60"
 
 from . import loggs
 from .pipes import *
diff --git a/src/pypelines/pipelines.py b/src/pypelines/pipelines.py
index a140325..06e4533 100644
--- a/src/pypelines/pipelines.py
+++ b/src/pypelines/pipelines.py
@@ -10,7 +10,12 @@ if TYPE_CHECKING:
     from .graphs import PipelineGraph
 
 
-class Pipeline:
+class PipelineType(Protocol):
+
+    def __getattr__(self, name: str) -> "BasePipe": ...
+
+
+class Pipeline(PipelineType):
     pipes: Dict[str, "BasePipe"]
     runner_backend_class = BaseTaskBackend
 
diff --git a/src/pypelines/pipes.py b/src/pypelines/pipes.py
index 0f95a07..3393780 100644
--- a/src/pypelines/pipes.py
+++ b/src/pypelines/pipes.py
@@ -17,7 +17,12 @@ if TYPE_CHECKING:
     from .pipelines import Pipeline
 
 
-class BasePipe(metaclass=ABCMeta):
+class BasePipeType(Protocol):
+
+    def __getattr__(self, name: str) -> "BaseStep": ...
+
+
+class BasePipe(BasePipeType, metaclass=ABCMeta):
     # this class must implements only the logic to link steps together.
 
     default_extra = None
diff --git a/src/pypelines/steps.py b/src/pypelines/steps.py
index e624fc9..c9a6ebf 100644
--- a/src/pypelines/steps.py
+++ b/src/pypelines/steps.py
@@ -7,7 +7,7 @@ from pandas import DataFrame
 from dataclasses import dataclass
 
 from types import MethodType
-from typing import Callable, Type, Iterable, Protocol, List, TYPE_CHECKING
+from typing import Callable, Type, Iterable, Protocol, List, TYPE_CHECKING, Any
 
 if TYPE_CHECKING:
     from .pipelines import Pipeline
@@ -244,7 +244,7 @@ class BaseStep:
         """
 
         @wraps(self.pipe.disk_class.load)
-        def wrapper(session, extra=None, strict=False):
+        def wrapper(session, extra=None, strict=False) -> Any:
             """Wrapper function to load disk object with session and optional extra parameters.
 
             Args:
-- 
GitLab