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.

Mypy third-party stubs

See original GitHub issue

Since Mypy 0.900 third-party stubs are not shipped by default. Can (I’m not sure if it’s viable) the pre-commit hook be updated to run mypy --install-types to install all missing stub package prior to running the mypy command?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
asottilecommented, Jun 11, 2021

to be clear, args: [--install-types] may possibly work but is not supported because it mutates the pre-commit environment at runtime – pre-commit environments are intended to be immutable. it will also, for instance, not work in https://pre-commit.ci where network is forbidden at runtime.

also note that this is not a new problem, the isolated mypy virtualenv has always been missing some amount of stubs – just now it is missing more of them.

auto-enabling --install-types will not happen here but you’re free to proceed in unsupported territory if you want.

1reaction
flniucommented, Jul 13, 2021

I tried this in .pre-commit-config.yaml and it worked:

- repo: https://github.com/pre-commit/mirrors-mypy
  rev: v0.910
  hooks:
  - id: mypy
    args:
      - --install-types
      - --non-interactive
Read more comments on GitHub >

github_iconTop Results From Across the Web

Stub files - mypy 0.991 documentation
Mypy uses stub files stored in the typeshed repository to determine the types of standard library and third-party library functions, classes, ...
Read more >
Third-party stubs: recommending a default path for installing ...
My plan is to only have stubs/python2 and stubs/python3 (or similar) in mypy. Also, should the directory be shared/python/typehints/... instead (i.e., with / ......
Read more >
one-off 3rd party mypy types (intermediate) anthony explains ...
today I show how to fix "Cannot find implementation or library stub for module named ..." errors in mypy by writing our own...
Read more >
python - Extending stub file for a third-party library/module
So, how can I, within my own project, "tack on" (or extend) an instance attribute annotation to URL so that it can be...
Read more >
Missing types | Code Cookbook - Michael Currin
Write your own stub files containing type hints for the library. You can point mypy at your type hints either by passing them...
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