-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
ignore-missing-import option does not work on false positive "Library stubs not installed for X" #10632
Comments
We faced the same issue in our CI. Ended up adding
|
I thought the entire reason for this update was for consistent treatment of stubs for third party packages. So why was it decided to introduce a breaking change that causes |
I have a similar issue, but I'm not sure if it's exactly the same. I'm using
when |
This error is a bit unfortunate, but it's by design. We made this error a little tricky to ignore, since otherwise many mypy users would silently lose type checking precision when upgrading to mypy 0.9xx: mypy would silently stop using various third-party library stubs that were previously bundled with mypy, resulting in a loss in type checking precision. By making the error hard to ignore, users at least will make an explicit decision to not install the type stubs. If you don't want to install the
Usually I'd recommend against doing this, since type checking results would then be worse than with older mypy versions. There's an idea about how to make installing type stubs easier: #10600 (comment) Maybe it would help with some of this? By using |
@epwalsh Your issue seems different. If you have |
@JukkaL I am trying to use the flag mypy . --install-types --ignore-missing-imports --disallow-untyped-defs --disallow-incomplete-defs --show-error-codes --raise-exceptions --no-incremental --cache-dir=nul but I am still getting the same error. |
You have to first run mypy in incremental mode, then run |
@JelleZijlstra If I'm running a CI pipeline though with GitHub Actions, if I run |
I'm not running mypy in any pipeline like that, but if I were you I would first run mypy locally to get the list of stub packages I need, then put those in my requirements list (requirements.txt, setup.py, or whatever else you're using) so that they're available in CI. |
That works fine if I'm running It would be very beneficial to run |
#10669 will support installing types and type checking in one step, by using |
If there are further changes mypy should make, please open a new issue. Fwiw, I recommend adding stubs to your test requirements files. |
I have the same issue and can't find a workaround or understand why I'm getting it.
|
I'm not able to reproduce, could you try upgrading to the latest version of I agree that this whole situation is pretty unfortunate and that |
Neither worked:
Only was to:
Which kinda starts polluting the code. |
Are you sure you're installing types-requests in the right environment? I think you need to specify something like: https://pre-commit.com/#config-additional_dependencies |
Perfect, my bad @hauntsaninja. This solved it!
|
Still having this error. The solution using My config looks like this:
... yet, when running the mypy hook, the following output is seen:
The package My theory is that there is a bug, because this is only the case for the import errors where the "note" lines are logged. If I remove Anyone else facing this and if so any idea how to work around it? EDIT: By adding the command args
So the requirement is definitely met, but somehow mypy doesn't see that. I should also mention that I don't have this issue for EDIT 2: Now I've also confirmed that the issue is not related to This is a desperate cry for help: Help! |
There's a really shitty situation where some stub packages are special cased to ignore If you can't get
|
Also I see mention of |
That's it! Thank you 🙏 |
I found my way here because mypy couldn't find Anyway, this is the section from my - repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.942
hooks:
- id: mypy
args: ["--install-types", "--non-interactive", "--ignore-missing-imports"] I hope this is helpful! |
I believe this is for using the [[tool.mypy.overrides]]
module = "yaml"
ignore_missing_imports = true where |
I'm also suggesting here that this special-casing (ignoring the |
I tried this, but it didn't work? Is the |
Bug Report
I was recommended to post a new issue that is very close to this one. I am specifically getting this error concerning the
pyyaml
package.When running
I am getting an error saying
To Reproduce
I've created a repo demonstrating the issue. To reproduce the error:
Actions
tabPython Windows mypy
workflowRun Workflow
and run it on themain
branchThere are only three files:
requirements.txt
main.py
action.yml
(GitHub Action workflow file)windows-latest
as the base image and runsmypy . --ignore-missing-imports
on the top-level directoryExpected Behavior
--ignore-missing-imports
should ignore the errorActual Behavior
Your Environment
--ignore-missing-imports
mypy.ini
(and other config files): n/awindows-latest
The text was updated successfully, but these errors were encountered: