Open vikigenius opened 3 weeks ago
This looks like a defect in boto3-stubs
, the type mypy_boto3_clouddirectory.client.CloudDirectoryClient
is imported within boto3.session
, but there is no module mypy_boto3_clouddirectory
included in boto3-stubs[essential]
Why does pyright not report this error? I'm not sure sorry, maybe @DetachHead Could answer that.
Here is the minification:
from typing import overload
from sus import sus
class A:
@overload
def f(self, x: int) -> sus: ...
@overload
def f(self, x: str) -> int: ...
def f(self, x: object) -> object: ...
b = A().f("asdf") # type of "f" is partially unknown
Which does actually show in pyright if you enable strict mode
this is just because basedpyright enables all rules by default. (specifically this rule is reportUnknownMemberType
). you can disable that rule if you want:
[tool.basedpyright]
reportUnknownMemberType = false
or if you want to set basedpyright's defaults to be the same as pyright's:
[tool.basedpyright]
typeCheckingMode = 'standard'
Huh that seems to have fixed the discrepancy. Although it's weird that it complains about partially unknown type.
Looks like it's a known issue with pyright: https://github.com/youtype/mypy_boto3_builder/issues/202
pyright complains about partially unknown types if not all overloads can be resolved.
I am not sure if this is desired behavior. Disabling reportUnknownMemberType
seems to affect a lot more than this.
the issue is that reportUnknownMemberType
gets reported on attribute access, rather than when the method actually gets called:
b = A().f # type of "f" is partially unknown
this is why it doesn't care which overload is being matched. it's reporting the error before it even checks the call
I installed type stubs from https://pypi.org/project/boto3-stubs/#usage
Like this:
pip install boto3-stubs[essential]
and pyright no longer complains about partially unknown client but basedpyright still does.