Skip to content

ObjectStoragePath incorrectly typed as UPath in ty 0.0.29 #64861

@m1racoli

Description

@m1racoli

Under which category would you file this issue?

Task SDK

Apache Airflow version

3.1.8

What happened and how to reproduce it?

Given the file dags/example.py

from airflow.sdk import ObjectStoragePath, dag, task


@task
def run() -> ObjectStoragePath:
    return ObjectStoragePath("s3://my-bucket/my-file.csv")


@dag(schedule=None)
def example():
    run()


example()

raises an error when type checking with ty 0.0.29:

$ uvx ty@0.0.29 check dags/example.py 
error[invalid-return-type]: Return type does not match returned value
 --> dags/example.py:5:14
  |
4 | @task
5 | def run() -> ObjectStoragePath:
  |              ----------------- Expected `ObjectStoragePath` because of return type
6 |     return ObjectStoragePath("s3://my-bucket/my-file.csv")
  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `ObjectStoragePath`, found `UPath`
  |
info: rule `invalid-return-type` is enabled by default

Found 1 diagnostic

This is likely because it is inheriting UPath's __new__ method without adjusting its return type:

class UPath(PathlibPathShim, Path):
...
    def __new__(
        cls, *args, protocol: str | None = None, **storage_options: Any
    ) -> UPath:

The issue seems to be result of astral-sh/ruff#24357.

What you think should happen instead?

It should not raise a type error.

Operating System

MacOS

Deployment

None

Apache Airflow Provider(s)

No response

Versions of Apache Airflow Providers

No response

Official Helm Chart version

Not Applicable

Kubernetes Version

No response

Helm Chart configuration

No response

Docker Image customizations

No response

Anything else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind:bugThis is a clearly a bugneeds-triagelabel for new issues that we didn't triage yet

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions