-
Notifications
You must be signed in to change notification settings - Fork 135
Description
Summary
error: lint\:no-matching-overload: No overload of bound method `__init__` matches arguments
for this minimal example:
import logging
h = logging.StreamHandler() # ← error
Why this is unexpected
-
The CPython docs and runtime accept a zero-argument constructor that defaults to
sys.stderr. -
typeshed’s
logging/__init__.pyireflects that signature:class StreamHandler(Handler): def __init__(self, stream: IO[str] | None = ...) -> None: ... -
Ty’s own stub—
red_knot/builtins/logging.pyi—still exposes the old overloads that takefilename|PathLikeand therefore rejects the common no-argument form.
Because of that divergence, projects that pass mypy/ruff/mkdocs etc. must add:
handler = logging.StreamHandler() # ty: ignore
and then hit issue #130 when the code is split across lines.
Repro
echo 'import logging; logging.StreamHandler()' > t.pyty check t.py
Expected
No diagnostics.
Actual
lint:no-matching-overload
Proposed fix
Import logging and update the StreamHandler overloads in Ty’s stdlib stubs to match typeshed (i.e., make the first positional argument an optional IO[str], default None).
This bug is separate from #130 (“unused suppression for type: ignore”) – that issue only appears because we’re forced to ignore this stub mismatch.
Version
0.0.0-alpha.7 (905a3e1 2025-05-07)