-
Notifications
You must be signed in to change notification settings - Fork 216
Closed
astral-sh/ruff
#19850Labels
diagnosticsRelated to reporting of diagnostics.Related to reporting of diagnostics.
Description
Context
When you have two types of the same name from different packages/ parts of the code base Ty will only give the error based on type name, and not its dir, leading to ambiguous errors.
I suggest adding some extra logic to be able to easier differentiate between identically named types, so in the case that it finds this issue, it appends something about the dir of the type.
Example
Say I have a function which expects a polars dataframe but a pandas dataframe is passed:
import polars as pl
import pandas as pd
def polars_function(df: pl.DataFrame) -> pl.DataFrame:
return df
df_pd = pd.DataFrame()
polars_function(df_pd)
Will receive this ambiguous error:

Solution
Would be very helpful if ty noticed that DataFrame and DataFrame are the same name and then appended the package name/ dir as follows:
--> test_file.py:8:17
|
7 | df_pd = pd.DataFrame()
8 | polars_function(df_pd)
| ^^^^^ Expected `polars.DataFrame`, found `pandas.DataFrame`
Version
ty 0.0.1-alpha.14
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
diagnosticsRelated to reporting of diagnostics.Related to reporting of diagnostics.