Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipeline protocols are out of sync with implementation and do not play well with static type checkers. #2363

Open
ubiquitousbyte opened this issue Mar 1, 2025 · 0 comments · May be fixed by #2364

Comments

@ubiquitousbyte
Copy link

ubiquitousbyte commented Mar 1, 2025

dlt version

1.7.0

Describe the problem

We're using pyright as our type checker. I noticed that pyright does not like the pipeline.run(...) method because the parameter types do not match their default values. For example, destination: TDestinationReferenceArg = None contains a type violation, because None cannot be assigned to TDestinationReferenceArg. We're adding # type: ignore comments to pipeline.run(...) calls because of this.

I also noticed that the run method of the SupportsPipeline protocol is currently out of sync with the actual implementation. The same holds true for __call__ in SupportsPipelineRun.

Expected behavior

The solution is to wrap the types of all the named arguments in an Optional, so that None can be passed in by users without any errors from the static type checker.

Steps to reproduce

Try to define the following code snippet:

def run(
    pipeline: SupportsPipeline,
    data: Any = None,
    *,
    destination: TDestinationReferenceArg | None = None
) -> LoadInfo:
        return pipeline.run(
            data,
            destination=destination
        )

and look for the following warning

Pyright: Argument of type "TDestinationReferenceArg | None" cannot be assigned to parameter "destination" of type "TDestinationReferenceArg" in function "run"
  Type "TDestinationReferenceArg | None" is not assignable to type "TDestinationReferenceArg"
    "None" is not assignable to "TDestinationReferenceArg"

Operating system

macOS

Runtime environment

Local

Python version

3.12

dlt data source

No response

dlt destination

No response

Other deployment details

No response

Additional information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

1 participant