You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importtypingastfromfunctoolsimportpartial# 1.# uncomment this to get type error# partial(lambda x, y: x + y, 10)()# 2.# But this silly little thing passes type-checksilly: t.Callable[[], int] =partial(lambdax, y: x+y, 10)
silly()
Expected Behavior
Fail to coerce partial into incompatible callable type.
Actual Behavior
Success: no issues found in 1 source file
Your Environment
Mypy version used: master
Mypy command-line flags: no
Mypy configuration options from mypy.ini (and other config files):
Python version used: 3.12
Looks like we carry information about needed arguments somewhere anyways, since 1 fails type check due to not enough arguments, so why we allow to coerce that partial into incompatible callable?
Perhaps this is due to this definition of partial:
But, for example, pyright takes that into account and fails as expected:
[nix-shell:/tmp]$ pyright issue.py
/tmp/issue.py
/tmp/issue.py:10:30 - error: Expression of type "partial[Unknown]" is incompatible with declared type "() -> int"
Type "partial[Unknown]" is incompatible with type "() -> int"
Extra parameter "y" (reportAssignmentType)
1 error, 0 warnings, 0 informations
I think it worth fixing, since we support partial and it is useful to rely on that support. It can be fixed, for example, as viewing partial result internally not as partial[int] type, but as something like
Bug Report
partial
support is too fragile and easy to fool.To Reproduce
Expected Behavior
Fail to coerce partial into incompatible callable type.
Actual Behavior
Success: no issues found in 1 source file
Your Environment
mypy.ini
(and other config files):Looks like we carry information about needed arguments somewhere anyways, since
1
fails type check due to not enough arguments, so why we allow to coerce that partial into incompatible callable?Perhaps this is due to this definition of partial:
But, for example,
pyright
takes that into account and fails as expected:I think it worth fixing, since we support
partial
and it is useful to rely on that support. It can be fixed, for example, as viewingpartial
result internally not aspartial[int]
type, but as something likeThe text was updated successfully, but these errors were encountered: