-
Notifications
You must be signed in to change notification settings - Fork 766
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
Is it possible to add a setting to disable is not a known member of module
to Pylance?
#3216
Comments
This error appears only if you enable static type checking, so I presume that you have set |
Hi @erictrait, I of course want to enable type checking in the rest of my own code, but I do not want this specific error to dominate the issues. I need a way to selectively ignore this without littering the code with The user story, if you are curious is something like this:
Thus, it would be highly desirable to have a way to selectively ignore this specific error in one of the ways mentioned above. |
Thanks for the additional details. Here's what I recommend as a workaround. Create a local type stub called def __getattr__(name: str) -> Any: ... This tells the type checker that it should allow access to any attribute within this module. You can also add type annotations for other |
@erictraut, I happen to face that with with Which complaints as: ... while adding explicit I have some "python.analysis.watchForLibraryChanges": false,
"python.analysis.diagnosticMode": "workspace",
"python.analysis.typeCheckingMode": "basic", Well, code works, so I assume the analyzer should as well. Does this setup have some influence over how Pylance indexes/analyzes the libraries? |
@maciejmatczak, if you want to access the submodule |
Rescuing a highly upvoted request from the general numpy typing issue:
Originally posted by @ggydush-fn in #150 (comment)
The problem
The issue is the overly-aggressive error:
"is not a known member of modulePylance [reportGeneralTypeIssues]"
There are thousands of widely used libraries where this issue persists, even if it may be fixed for numpy. It would be great to be able to easily disable this per package. For example, I routinely use
astropy
, among many other packages, and the code is littered with these errors. Makes coding in VS code with pylance typing support a chore.Desired/proposed solutions:
is not a known member of module
for a specific module as a setting, or at import.is not a known member of module
to aninfo
from anerror
, as a setting.is not a known member of module
for all "third-party" libraries as a setting.None of these solutions should be default as it can promote bad practices and miss obvious mistakes, but it would be great to be easily set up such options.
Related issues
With upvotes and requests detailing roughly the above:
#106
#150 - The numpy one.
The text was updated successfully, but these errors were encountered: