-
Notifications
You must be signed in to change notification settings - Fork 16.8k
ObjectStoragePath incorrectly typed as UPath in ty 0.0.29 #64861
Copy link
Copy link
Open
Labels
kind:bugThis is a clearly a bugThis is a clearly a bugneeds-triagelabel for new issues that we didn't triage yetlabel for new issues that we didn't triage yet
Description
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 diagnosticThis 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
- I agree to follow this project's Code of Conduct
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
kind:bugThis is a clearly a bugThis is a clearly a bugneeds-triagelabel for new issues that we didn't triage yetlabel for new issues that we didn't triage yet
Type
Fields
Give feedbackNo fields configured for issues without a type.