monaco-languageclient icon indicating copy to clipboard operation
monaco-languageclient copied to clipboard

Language client based on `@typefox/pyright-browser` unable to resolve 'local' workspace imports

Open pmalacho-mit opened this issue 1 year ago • 8 comments

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!

pmalacho-mit avatar May 28 '24 03:05 pmalacho-mit

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.

kaisalmen avatar Jun 03 '24 07:06 kaisalmen

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.

pmalacho-mit avatar Jun 22 '24 20:06 pmalacho-mit

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 avatar Jun 24 '24 08:06 kaisalmen

@kaisalmen The @typefox/pyright-browser package in question is a pure browser based language server. There is no machine.

msujew avatar Jun 24 '24 09:06 msujew

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

kaisalmen avatar Jun 24 '24 10:06 kaisalmen

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.

pmalacho-mit avatar Jul 02 '24 18:07 pmalacho-mit

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 avatar Aug 14 '24 00:08 pmalacho-mit

@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.

msujew avatar Aug 14 '24 14:08 msujew

@pmalacho-mit any luck with it?

artkhod avatar Oct 21 '24 11:10 artkhod

@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 avatar Oct 21 '24 16:10 pmalacho-mit

@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.

kaisalmen avatar Oct 25 '24 13:10 kaisalmen

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 avatar Jan 26 '25 08:01 JCDenton47

@JCDenton47 thank you

kaisalmen avatar Jan 27 '25 09:01 kaisalmen

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!!

pmalacho-mit avatar Jan 28 '25 22:01 pmalacho-mit