You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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)
Activity
Ignore mypy errors in croakysteel. Workaround for realpython/pytest-m…
Add mypy-specific workaround for realpython/pytest-mypy#160 and avoid…
dmtucker commentedon Aug 6, 2023
I think mypy is following this import.
jaraco commentedon 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_ignoresetting into mypy excludes, but that's definitely more of a feature request.jaraco commentedon Apr 2, 2024
I've found another project affected by this issue: keyrings.alt. This project has a module
_win_crypto.pythat 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:Add mypy-specific workaround for realpython/pytest-mypy#160.
dmtucker commentedon Aug 10, 2024
Ya, also likely because of this import...
It's actually interesting to see that
collect_ignoreis generally respected:That is because the plugin only creates
MypyFiles (and subsequentlyMypyItems) for files presented by thepytest_collect_filehook. It then runsmypyon the file of any collectedItem.[-]mypy not ignoring file[/-][+]Add mypy excludes for collect_ignore entries[/+]