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
So something like the following gives me main.py:4: error: Attribute function "default_factory" with type "Callable[[], _T]" does not accept self argument:
import dataclasses
def foo(x: dataclasses.Field):
if x.default_factory is not dataclasses.MISSING:
...
Okay, hmm. Let's try to repro:
from typing import Callable
class X:
# f: Callable[[], str]
def __init__(self) -> None:
self.f = lambda: "whatever"
x = X()
reveal_type(x.f)
reveal_type(x.f())
This works fine! But if you uncomment the commented line, then you're back to the error, which is problematic if you want to express this in stubs. I can get things checking again by using a callback protocol — is that the best one can do?
The text was updated successfully, but these errors were encountered:
So something like the following gives me
main.py:4: error: Attribute function "default_factory" with type "Callable[[], _T]" does not accept self argument
:Okay, hmm. Let's try to repro:
This works fine! But if you uncomment the commented line, then you're back to the error, which is problematic if you want to express this in stubs. I can get things checking again by using a callback protocol — is that the best one can do?
The text was updated successfully, but these errors were encountered: