wxWidgets / Phoenix

wxPython's Project Phoenix. A new implementation of wxPython, better, stronger, faster than he was before.
http://wxpython.org/
2.22k stars 509 forks source link

mypy doesn't understand wx.lib.inspection #2485

Closed Newbytee closed 6 months ago

Newbytee commented 6 months ago

Operating system: Ubuntu 22.04.3 LTS wxPython version & source: 4.2.1, pypi Python version & source: 3.10.12, Ubuntu's package repositories

Description of the problem:

I'm making an application with wxPython, and to debug problems I use the inspection tool. To help with refactoring among other things, I use mypy to ensure that all the types are correct. However, with the wx.lib.inspection module, this does not work as I would expect. When running mypy on my code that includes this module, it says this:

sketch/mypy-issue.py:1: error: Skipping analyzing "wx.lib.inspection": module is installed, but missing library stubs or py.typed marker  [import]
sketch/mypy-issue.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 1 source file)

I don't think this could be something I'm doing wrong given that I can reproduce this by just importing a single module.

Code Example (click to expand) ```python # Yes, this is really it. import wx.lib.inspection ```
komoto48g commented 6 months ago
# It also occurs with:
import wx

I don't think wxpython provides stub files. You should ignore the error by writing the following in your configuration file:

[mypy-wx.*]
ignore_missing_imports = True

see also: https://mypy.readthedocs.io/en/stable/config_file.html

Newbytee commented 6 months ago

Thanks, the codebase I encountered this in must be doing something to suppress that error (not sure what exactly though, can't find any mypy configuration file).