Skip to content

Commit

Permalink
uses TypeVal with default
Browse files Browse the repository at this point in the history
  • Loading branch information
rudolfix committed Apr 7, 2024
1 parent 16ebdc2 commit 48cdfa1
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions dlt/pipeline/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Sequence, Type, TypeVar, cast, overload
from typing import Sequence, Type, cast, overload
from typing_extensions import TypeVar

from dlt.common.schema import Schema
from dlt.common.schema.typing import TColumnSchema, TWriteDisposition, TSchemaContract
Expand All @@ -15,7 +16,7 @@
from dlt.pipeline.progress import _from_name as collector_from_name, TCollectorArg, _NULL_COLLECTOR
from dlt.pipeline.warnings import credentials_argument_deprecated

TPipeline = TypeVar("TPipeline", bound=Pipeline)
TPipeline = TypeVar("TPipeline", bound=Pipeline, default=Pipeline)


@overload
Expand All @@ -31,7 +32,7 @@ def pipeline(
full_refresh: bool = False,
credentials: Any = None,
progress: TCollectorArg = _NULL_COLLECTOR,
_impl_cls: Type[TPipeline] = Pipeline,
_impl_cls: Type[TPipeline] = Pipeline, # type: ignore[assignment]
) -> TPipeline:
"""Creates a new instance of `dlt` pipeline, which moves the data from the source ie. a REST API to a destination ie. database or a data lake.
Expand Down Expand Up @@ -81,6 +82,12 @@ def pipeline(
"""


@overload
def pipeline() -> Pipeline: # type: ignore
"""When called without any arguments, returns the recently created `Pipeline` instance.
If not found, it creates a new instance with all the pipeline options set to defaults."""


@with_config(spec=PipelineConfiguration, auto_pipeline_section=True)
def pipeline(
pipeline_name: str = None,
Expand All @@ -94,7 +101,7 @@ def pipeline(
full_refresh: bool = False,
credentials: Any = None,
progress: TCollectorArg = _NULL_COLLECTOR,
_impl_cls: Type[TPipeline] = Pipeline,
_impl_cls: Type[TPipeline] = Pipeline, # type: ignore[assignment]
**kwargs: Any,
) -> TPipeline:
ensure_correct_pipeline_kwargs(pipeline, **kwargs)
Expand Down

0 comments on commit 48cdfa1

Please sign in to comment.