-
-
Notifications
You must be signed in to change notification settings - Fork 273
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
Prefer using the module loader to get source in builder. #1207
Prefer using the module loader to get source in builder. #1207
Conversation
Otherwise we fail to get the module source code when running in an embedded hermetic interpreter environment where the source does not live on a filesystem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand well the testing is easier on pylint ? Is there a simple way to also test that on astroid ?
Try this:
I didn't try this, but I believe it'd work and be self contained and not have additional dependencies. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merging without tests as pylint's test suite is passing and the actual testing will be done in pylint-dev/pylint#5341
Congratulation on becoming an astroid contributor :)
Thanks! I had stalled on responding while pondering how to construct a meaningful regression test case without being overcomplicated! :) |
You're welcome to contribute to pylint-dev/pylint#5341 if you have new ideas :) |
…1207) * Use loader.get_source() in builder.module_build() Otherwise we fail to get the module source code when running in an embedded hermetic interpreter environment where the source does not live on a filesystem. Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
…1207) * Use loader.get_source() in builder.module_build() Otherwise we fail to get the module source code when running in an embedded hermetic interpreter environment where the source does not live on a filesystem. Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
Steps
Description
Prefer the module loader get_source() method in AstroidBuilder's module_build() when possible to avoid assumptions about source code being available on a filesystem. Otherwise the source cannot be found and application behavior changes when running within an embedded hermetic interpreter environment (pyoxidizer, etc.).
Without this change, pylint packaged up as such would fail to infer that functions like
bz2.compress
returnedsomething other than None, triggering
assignment-from-no-return
when it clearly should not.At the pylint level, this works as an application integration regression test - when you run the test build within such a no-filesystem environment.
I did not try to come up with a smaller targeted astroid unittest faking the "The path in .__file__ does not exist" environment. That would probably be useful.
Type of Changes
Related Issue