Language client based on `@typefox/pyright-browser` unable to resolve 'local' workspace imports
Hello! Thank you for this project!
I am attempting to implement a fully client-side based python editor by leveraging the @typefox/pyright-browser implementation as my language client's worker.
However, when setting up two python files (where one imports the other, like in the example) I get a "reportMissingImports" pyright error.
I created a very simple repo to demonstrate the error, which is also deployed for convenience. From looking at the console logs, pyright is at least "aware" of hello2 (the imported module) as pyright reports binding/analyzing/checking it.
I know this topic has been somewhat discussed in another issues, like #653 , but unfortunately I wasn't able to make use of the information there.
I'm hoping that the provided reproduction repo is straightforward enough to make providing help on this matter as painless as possible. Thank you!
Hi @pmalacho-mit I think #653 addresses a different problem. My observation is so far that pyright does not automatically create a file on its file system when a file is opened on the client side (openTextDocument).
In VSCode language client and language server share the same filesystem, so this issue does not arise. Here the situation different. When you manually create a file at the correct location in the example you linked above (/workspace/hello2.py), then the missing error is gone. I don't have a general solution for dealing with such a situation that. AFAIK there is no possibility to enforce server side file creation with the language server protocol.
Hi @kaisalmen -- thanks very much for the response (and apologies for my tardy reply, I've been out of the office).
Would you be able to describe more specifically how to "manually create a file at the correct location"? I'm wondering if, given my use case, I might be able to handle that programmatically in attempt to get rid of these errors.
Would you be able to describe more specifically how to "manually create a file at the correct location"?
@pmalacho-mit I meant to have a file present at /workspace/hello2.py on the machine where the language server runs.
@kaisalmen The @typefox/pyright-browser package in question is a pure browser based language server. There is no machine.
Yes, I know, I was referring to my example. @msujew is there a virual file system implementation available for it. Maybe you can help @pmalacho-mit or should an issue be opened there? Thanks
Thanks for the replies @msujew and @kaisalmen ! Please let me know if you have any guidance on moving forward and/or if I should make an issue over in the pyright repo.
Hey @msujew and @kaisalmen -- this totally fell of my plate for the past couple months (apologies), but I would love the chance to take advantage of your help to figure this out. Please let me know how best to proceed!
@pmalacho-mit Unfortunately, I'm not really involved in the active development regarding anything pyright related. I just published the pyright-browser package for a project (which we're no longer involved with) early last year after performing some minor adjustments from https://github.com/microbit-foundation/pyright.
Maybe you're better served using a more active fork like https://github.com/posit-dev/pyright/blob/pyright-browser/THIS_FORK.md.
@pmalacho-mit any luck with it?
@pmalacho-mit any luck with it?
Unfortunately not @artkhod -- I did not have the chance to play around with @msujew 's suggestion of https://github.com/posit-dev/pyright/blob/pyright-browser/THIS_FORK.md.
For the time being I'm currently assuming users are working in a single file. 🤞 I can explore this in the future
@pmalacho-mit I will close this issue. If you see the new to address a specific issue in the future, please open a new issue.
To anyone who is intereted in the problem, this may be a possible solution, to inform the server you created a file https://github.com/TypeFox/monaco-languageclient/discussions/837 @pmalacho-mit @kaisalmen
@JCDenton47 thank you
Exciting, @JCDenton47 ! I might not get the chance to test this out in the near future (currently on a different project), but I can't wait to give a shot and will report back. Thanks so much!!