Skip to content
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

Excluding Certain LSP Feedback for Otter buffers #207

Open
acederberg opened this issue Feb 3, 2025 · 2 comments
Open

Excluding Certain LSP Feedback for Otter buffers #207

acederberg opened this issue Feb 3, 2025 · 2 comments

Comments

@acederberg
Copy link

acederberg commented Feb 3, 2025

Thanks for otter!

This is a whacky edge case I have but I think it is important enough to bring up.

Certain LSP feedback is not useful for injected content. For instance, in (modern) jupyter notebooks it is possible to use top level await (which is not cool in normal python code). Since quarto uses jupyter it is possible to do this within quarto too. However, this does result in diagnostics that are not helpful in the context of the notebook that tell me not to use await like this:

Image

As nasty as it looks, the page renders just fine too

Image

Is there a way that this can be done without otter possibly?

(Also, # type: ignore does work, but it would be nice to do this at the LSP level)

@jmbuhr
Copy link
Owner

jmbuhr commented Feb 4, 2025

For the R language server the current approach is to configure it (either globally or per project) e.g. like https://github.com/quarto-dev/quarto-nvim?tab=readme-ov-file#r-diagnostics-configuration.

Likewise, pyright has its own configuration file, in which you can turn off individual warnings per project, e.g. the reportUnusedCoroutine warning for your case (see https://github.com/microsoft/pyright/blob/main/docs/configuration.md).

Though, I suppose it would be cool if those options can be set from within a file via some magic comment. In this case I might pick up my earlier idea here to add some by default per language.

@acederberg
Copy link
Author

I think that #99 is a good solution to this, for instance a wrapper of async def main(): could be added around the buffer, which would result in this no longer being an issue.

Additionally, it looks like there are more specialized tools like jupyterlab-lsp but I do not have time at the moment to tinker with making it work (but I might later).

Appearently, there is no name associated with this error so ignoring it is tricky, I ran pyright example.py where

async def main():
  print("It works!")

await main()

and the output I get is

/home/adrian/Projects/Blog/example.py
  /home/adrian/Projects/Blog/example.py:5:1 - error: "await" allowed only within async function
1 error, 0 warnings, 0 informations 

I tested reportUnusedCoroutine but it only ignores the issue where a couroutine is not awaited, for instance removing the await (with the default pyright configuration) from above gets the following

/home/adrian/Projects/Blog/example.py
  /home/adrian/Projects/Blog/example.py:5:1 - error: Result of async function call is not used; use "await" or assign result to variable (reportUnusedCoroutine)
1 error, 0 warnings, 0 informations 

and can be toggled off using that setting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants