question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proper way to use nbqa-mypy

See original GitHub issue

Thanks for your work! I have a question, that might convert into an issue, so I’m trying to use nbqa-mypy, my config looks like this:

  - repo: https://github.com/nbQA-dev/nbQA
    rev: 0.5.7
    hooks:
      - id: nbqa-mypy
        args: ["--nbqa-ignore-cells=%%R", "--strict", "--show-error-codes"]

But I’m getting error about missing modules that are part of the repository, example:

pipelines/notebooks/foo.ipynb:cell_2:1: error: Cannot find implementation or library stub for module named 'my_utils'  [import

Where the repo contains {pipelines, my_utils} in the root, and import from my_utils doesn’t raise issues in py modules and vanilla mypy checks. Am I doing sth wrong? Is there a blessed way to use nbqa-mypy and give access to the main repo? Maybe nbqa-mypy is missing some step to add repo to the pre-commit’s nbqa-mypy virtualenv?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:28 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
MarcoGorellicommented, Feb 19, 2021

Seems like we need to set MYPYPATH in addition to PYTHONPATH https://mypy.readthedocs.io/en/latest/running_mypy.html#following-imports

Will make a new release over the weekend

1reaction
MarcoGorellicommented, Feb 20, 2021

I would suggest using subprocess.run and capturing the output. If you share your command I can try to be more specific

Read more comments on GitHub >

github_iconTop Results From Across the Web

nbQA-dev/nbQA: Run isort, pyupgrade, mypy, pylint, flake8 ...
Pre-commit. Here's an example of how to set up some pre-commit hooks: put this in your .pre-commit-config.yaml ...
Read more >
nbQA Documentation
Here's one way to set one up using Conda - see this tutorial for other options. ... nbqa mypy my_notebook.ipynb --ignore-missing-imports.
Read more >
Keep your Jupyter Notebooks maintainable with nbQA
If we want to use any of the following excellent tools: flake8 (style guide enforcement); pylint (suggests refactorings, brings up code smells) ...
Read more >
Type-check Jupyter Notebooks with mypy - Stack Overflow
You can: Convert all notebooks to python, then run mypy on that (How do I convert a IPython Notebook into a Python file...
Read more >
nbqa · PyPI
You can configure nbQA either at the command line, or by using a .nbqa.ini file. We'll see some examples below. Extra flags. If ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found