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

[Bug]: Incorrect overload handling for Any #139

Open
1 task
maxfischer2781 opened this issue Mar 25, 2024 · 1 comment
Open
1 task

[Bug]: Incorrect overload handling for Any #139

maxfischer2781 opened this issue Mar 25, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@maxfischer2781
Copy link
Owner

maxfischer2781 commented Mar 25, 2024

What happened?

Since typing.Any matches literally anything, for @overload that start with special cases these are always picked in untyped code. Instead, @overload should prefer the most generic, conservative case.

This is related to and got my attention by the pandas concat type hints bug that causes Any -> ??? paths to select None -> Never overloads.

Minimal Reproducible Example

# Type test
# MyPy "correctly" reports the unused type ignore

async def test_filter_any(aitr: "AsyncIterator[int | None]") -> None:
    filter_any: Any = ...  # < we don't know the actual type and don't care
    async for item in a.filter(filter_any, aitr):
        print(2 + item)  # type: ignore

Request Assignment [Optional]

  • I already understand the cause and want to submit a bugfix.
@maxfischer2781 maxfischer2781 added the bug Something isn't working label Mar 25, 2024
@maxfischer2781 maxfischer2781 self-assigned this Mar 25, 2024
@maxfischer2781 maxfischer2781 removed their assignment Jun 14, 2024
@maxfischer2781
Copy link
Owner Author

There currently seems to be no way to fix this for both MyPy and PyRight. See the open StackOverflow question How to overload functions to handle Any-arguments? for the current status quo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant