-
class Base:
def __init__(self, **params):
pass
class FunctionBase(Base):
def __new__(cls, *args, **kwargs):
inst = Base.__new__(cls)
result = inst.__call__(*args, **kwargs)
return result
def __call__(self, *args, **kwargs):
raise NotImplementedError
class SomeFunction(FunctionBase):
def __call__(self, *args, **kwargs):
return 1
SomeFunction('test') The typing spec includes this:
So I annotated the return type of Instead, I added a dummy class FunctionBase(Base):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) Is this the only solution available? What should |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Yes, you're correct. Pyright isn't following the typing spec here. The spec conformance test tests for a union that contains I've created a separate bug report to track the issue. This issue will be fixed in the next release of pyright. I've also updated the unit tests to cover this case. |
Beta Was this translation helpful? Give feedback.
Yes, you're correct. Pyright isn't following the typing spec here. The spec conformance test tests for a union that contains
Any
but doesn't check for anAny
by itself. (I wrote this conformance test, so the omission was my fault.) That explains why this bug wasn't caught earlier. I also didn't have this case covered in the pyright unit tests.I've created a separate bug report to track the issue.
This issue will be fixed in the next release of pyright. I've also updated the unit tests to cover this case.