-
Notifications
You must be signed in to change notification settings - Fork 74k
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
Module structure not recognized by Visual Studio Code Linter #54435
Comments
@bmorledge-hampton19 , |
Thanks for the links. They are very helpful. My apologies for rehashing an issue that is clearly already recognized. |
Hope the pr gets merged soon that linter error it's driving me nuts |
Don't apologize, the issue has been around since TF 2.0 release and nothing was ever done about it, it is unacceptable that every new release breaks PyLance. |
System information
I am very perplexed by tensorflow's module structure. I recently started using tensorflow in Visual Studio Code and immediately ran into a problem where imports from tensorflow.keras cannot be resolved by Pylance. For example, the "layers" module is not recognized from the line
from tensorflow.keras import layers
. Interestingly enough, the code runs fine despite this error, but the lack of support from the linter makes writing code very difficult. (For reference, I am using the "Probabilistic Bayesian Neural Networks" example script.)My attempts to fix this issue led to a number of other discoveries which still have me confused:
from tensorflow import keras
is recognized by the linter, but the linter still can't offer any helpful predictions off of the keras module. In this instance, replacing references tolayers
withkeras.layers
still work, despite no indication from the linter that they should.keras.layers
is still valid, but hints from linting are still not present, and other parts of the code will break unexpectedly. For example, a call tokeras.optimizers.RMSprop
, is invalid even thoughkeras.optimizers
is recognized and both are recognized if keras is imported through tensor flow.keras.layers
is not recognized by the linter after importing just keras, the linter does recognizefrom keras import layers
and offers completions for layers after the fact.from tensorflow import keras
was recognized in tensorflow 2.7.0. This issue only started when I updated.Admittedly, my understanding of packaging and linting in Python is somewhat limited, but I've never had issues like this with any other package I've worked with. Am I missing something obvious here? Is this a known issue? If this kind of structure is intentional, what is the rationale behind it? Are there known workarounds/resources that I could use to better understand this issue?
Thanks in advance for the help.
The text was updated successfully, but these errors were encountered: