maxfischer2781 / maxfischer2781/asyncstdlib

[Bug]: Incorrect overload handling for Any

Open
#139 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
381
Forks
26
Avg merge
3d 4h
Merged PRs (30d)
2

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal async filter example and inspect the overload definitions for the referenced async filter API. Reproduce how an Any argument selects the special-case overload, then verify that overload resolution prefers the generic conservative case and that the example no longer takes the None-to-Never path.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.