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

mypy not ignoring file #160

Open
jaraco opened this issue Aug 6, 2023 · 3 comments
Open

mypy not ignoring file #160

jaraco opened this issue Aug 6, 2023 · 3 comments

Comments

@jaraco
Copy link

jaraco commented Aug 6, 2023

The jaraco.site project has a file in the tree that's ignored for tests.

However, even with that configuration, the file gets collected and is run by mypy and causes tests to fail:

__________________________________________________________________ test session ___________________________________________________________________
mypy exited with status 1.
...
====================================================================== mypy =======================================================================
jaraco/site/projecthoneypot/croakysteel.py:528: error: "Callable[[Any, Any, Any, Any], Any]" has no attribute "getSettings"  [attr-defined]
jaraco/site/projecthoneypot/croakysteel.py:529: error: "Callable[[Any, Any, Any, Any], Any]" has no attribute "makeHTML"  [attr-defined]
jaraco/site/projecthoneypot/croakysteel.py:533: error: "Callable[[Any, Any, Any, Any], Any]" not callable  [operator]
Found 3 errors in 1 file (checked 11 source files)
============================================================= short test summary info =============================================================
FAILED conftest.py::mypy-status
============================================== 1 failed, 25 passed, 10 skipped, 3 warnings in 5.09s ===============================================
py: exit 1 (5.43 seconds) /Users/jaraco/code/jaraco/jaraco.site> pytest pid=33733

Is there a way that pytest-mypy can honor collect_ignore?

jaraco added a commit to jaraco/jaraco.site that referenced this issue Aug 6, 2023
jaraco added a commit to jaraco/jaraco.site that referenced this issue Aug 6, 2023
@dmtucker
Copy link
Collaborator

dmtucker commented Aug 6, 2023

I think mypy is following this import.

@jaraco
Copy link
Author

jaraco commented Aug 7, 2023

Oh, right. I hadn't considered that the checking has to be done holistically. Yeah, that makes sense. I did find that I could suppress the errors by configuring the project to ignore types for that module.

I guess it's conceivable that pytest-mypy could translate the collect_ignore setting into mypy excludes, but that's definitely more of a feature request.

@jaraco
Copy link
Author

jaraco commented Apr 2, 2024

I've found another project affected by this issue: keyrings.alt. This project has a module _win_crypto.py that imports ctypes and accesses attributes of ctypes that are only available on Windows. Thus when checking mypy, it fails its type checks. The module is excluded from tests, but that's insufficient to prevent mypy from failing, even when run under pytest:

keyrings/alt/_win_crypto.py:13: error: Module "ctypes" has no attribute "windll"  [attr-defined]
keyrings/alt/_win_crypto.py:13: error: Module "ctypes" has no attribute "WinDLL"  [attr-defined]
keyrings/alt/_win_crypto.py:13: error: Module "ctypes" has no attribute "WINFUNCTYPE"; maybe "PYFUNCTYPE"?  [attr-defined]
Found 3 errors in 1 file (checked 21 source files)

jaraco added a commit to jaraco/keyrings.alt that referenced this issue Apr 2, 2024
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