-
-
Notifications
You must be signed in to change notification settings - Fork 278
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
Refactor: Stop adding arbitrary attributes to module obj when building #1215
Refactor: Stop adding arbitrary attributes to module obj when building #1215
Conversation
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.
Based on the tests and the actual code I this change seems fine? It doesn't actually do much different, other than making the code more readable since _post_build
is called after _data_build
anyway.
Edit: And by the way @thejcannon sorry for letting this PR drop down into "stale-PR-hell" 😅
astroid/builder.py
Outdated
module._import_from_nodes = builder._import_from_nodes | ||
module._delayed_assattr = builder._delayed_assattr | ||
|
||
self._manager.cache_module(module) |
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.
Shouldn't the cache_module
stay in _post_build
? If we ever do something different in _data_build
after this line or we add a method between _data_build
and _post_build
it won't be cached?
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.
I think it wouldn't matter. The module
object reference is cached, ie. if the object changes, those changes are also reflected in the cache.
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.
I would prefer if we kept the logic inside _post_build
. IMO passing the builder
along is probably the better alternative.
I've updated the code to pass |
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.
LGTM thank you @thejcannon and @cdce8p
Steps
Description
Moving code from
_post_build
into_data_build
so that we don't have to attach arbitrary objects to the module (namely_import_from_nodes
, and_delayed_assattr
).Alternatively we could:
_post_build
and pass the info alongType of Changes
Related Issue