8000 Fix overloading with a typevar missing by A5rocks · Pull Request #15320 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Fix overloading with a typevar missing #15320

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add a trivial test
  • Loading branch information
A5rocks authored Jun 14, 2023
commit 712c88ed3c4b7fc09ded15a4b616b25ea8037d43
18 changes: 18 additions & 0 deletions test-data/unit/check-overloading.test
Original file line number Diff line number Diff line change
Expand Up @@ -6545,3 +6545,21 @@ class Snafu(object):
reveal_type(Snafu().snafu('123')) # N: Revealed type is "builtins.str"
reveal_type(Snafu.snafu('123')) # N: Revealed type is "builtins.str"
[builtins fixtures/staticmethod.pyi]

[case testOverloadedFunctionWithTypevarMissing]
import typing

class A: ...

T = typing.TypeVar("T", bound=A)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should investigate why current mypy is a-ok without the bound=A here, but errors when it is. That's strange and probably a sign of incorrect special casing: something I hate!


@typing.overload
def f(a: T) -> T: ...

@typing.overload
def f(*, copy: bool = False) -> None: ...

def f(a: T = ..., *, copy: bool = False) -> T:
...

reveal_type(f) # N: Revealed type is "Overload(def [T <: __main__.A] (a: T`-1) -> T`-1, def (*, copy: builtins.bool =))"
0