-
Notifications
You must be signed in to change notification settings - Fork 67
Pyright type checking does not pass (causing Pylance in vscode to show typing errors) #179
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
Comments
Pylance uses
|
@pjbull Important information is here: |
Thanks for sharing those details. Does the workaround mentioned resolve the reported pylance error at least? That would be good for other folks finding this issue to know.
It's still the case that we'd accept a PR that makes pyright pass and adds that verification to CI. That said, if I'm reading the issue you linked right, it seems that typing any of the properties that use the dispatching to the |
I would type hint properties normally and for _dispatch_to_path just do, def _dispatch_to_path(self, func: str, *args: object, **kwargs: object) -> Any:
... dispatch_to_path is doing too much magic to be understandable for a static type checker. Mostly getattribute and how literal string value of func can change return type in a variety of ways. After you effectively ignore _dispatch_to_path you can add hints for each property normally like, @property
def name(self) -> str:
... |
I don't have previous error anymore, but I don't have anything, no autocompletion, nothing: So this is fixing it, but at the same time it is disabling so much convenience (auto-completion). So I will keep this setting turned on ;) |
Down to 48 errors on latest code with #298 and other improvements, next time someone looks at making
|
I discovered one issue, described here: microsoft/pyright#4896
I am reporting here, because I think it is issue in cloudpathlib. |
@karolzlot Do you know what the required change would look like? It does seem that |
@karolzlot, a few thoughts here from looking at your example in microsoft/pyright#4896: First, as @pjbull said, cloud_path: Union[str, S3Path] However, this will still result in a type error from pyright, because It may be possible that we could change I don't know much about what you're trying to accomplish since you've only shared a minimal example with the interface. However, the fact that you named your class "Wrapper" suggests that subclassing isn't the best approach. You may want a different implementation that stores an instance of |
Sorry for confusion with It's possible that this suggestion with using My understanding of this issue isn't very good, maybe |
PR #330 will solve this issue, right? |
I will try it once new version with this change is released. I think it will solve it :) |
0.15.0 is released if you want to give it a shot! https://pypi.org/project/cloudpathlib/ Going to leave this issue open since we still only pass |
FYI 0.15.0 solved all pyright errors beside this one: (For me it's small issue, as it's enough to use from typing import Union
from cloudpathlib import S3Path
class S3PathWrapper(S3Path):
def __init__(
self,
cloud_path: Union[str, S3Path],
):
super().__init__(cloud_path=cloud_path) |
Related: microsoft/pyright#5258 |
@karolzlot Your contribution has now shipped in version I think that pyright still doesn't pass outright, so will leave this open for now. |
For example I need to use
str()
for.stem
field, otherwise it shows:The text was updated successfully, but these errors were encountered: