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

add support for pyright #647

Open
4 tasks
MarcoGorelli opened this issue Jul 30, 2021 · 6 comments
Open
4 tasks

add support for pyright #647

MarcoGorelli opened this issue Jul 30, 2021 · 6 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@MarcoGorelli
Copy link
Collaborator

MarcoGorelli commented Jul 30, 2021

What needs doing:

  • add a hook in .pre-commit-hooks.yaml
  • add an example in docs/examples.rst
  • add dependency to requirements-dev.txt
  • add a new test in tests/tools (see tests/tools/test_yapf.py for an example)
@MarcoGorelli MarcoGorelli added enhancement New feature or request help wanted Extra attention is needed labels Jul 30, 2021
@karolzlot
Copy link

@MarcoGorelli is it supported?

@MarcoGorelli
Copy link
Collaborator Author

Hi - I'd expect it to work out-of-the-box

If not, please do let me know

@karolzlot
Copy link

karolzlot commented Apr 23, 2023

@MarcoGorelli

So I tested it and it works, but not in a way which I need it to work. I was unable so far to find any workaround.

The issue is that nbqa assumes that all files may be evaluated independently, which is not true for type checkers, especially not for pyright.
In this case I want pyright to evaluate notebooks in context of all other files in repository. When I specify . path to nbqa, then it feeds pyright only with python files generated from notebooks. I expected that it will also include my other python files, but this is not the case.

What I'm missing in this tool is the ability to convert notebook to python files and keep them. I see that currently this feature can't be used independently and also those generated python files are instantly removed.
If I could generate those python files and keep them, then I could easily run pyright on them in the next step.

@MarcoGorelli
Copy link
Collaborator Author

If I could generate those python files and keep them, then I could easily run pyright on them in the next step.

seems like a reasonable request - reopening then, thanks for the ping!

@MarcoGorelli MarcoGorelli reopened this Apr 23, 2023
@tqa236
Copy link

tqa236 commented Apr 12, 2024

Hello, I would like to understand if this limitation also applies to mypy, which also needs the context of the whole codebase to correctly analyze the notebooks?

@cgravill
Copy link

In case it's helpful I'm able to run nbqa with pyright via uv:

uv run nbqa pyright examples

and it correctly picks out all the notebooks in the examples directory. Imports from the notebooks to the rest of the local code work.

This seems to work well for us, and now avoids a extra steps of nbconvert and temporary files, so that's really useful so far. Thanks for making the tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants