Skip to content
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

Merged
merged 3 commits into from
Feb 27, 2022

Conversation

thejcannon
Copy link
Contributor

@thejcannon thejcannon commented Oct 20, 2021

Steps

  • For new features or bug fixes, add a ChangeLog entry describing what your PR does.
  • Write a good description on what the PR does.

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:

  • Keep the code in _post_build and pass the info along
  • Same, but pass the builder

Type of Changes

Type
🐛 Bug fix
✨ New feature
🔨 Refactoring
📜 Docs

Related Issue

@Pierre-Sassoulas Pierre-Sassoulas added the Maintenance Discussion or action around maintaining astroid or the dev workflow label Oct 21, 2021
@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.9.0 milestone Oct 21, 2021
@Pierre-Sassoulas Pierre-Sassoulas self-requested a review October 21, 2021 11:32
@DanielNoord DanielNoord self-requested a review December 30, 2021 17:12
Copy link
Collaborator

@DanielNoord DanielNoord left a 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" 😅

module._import_from_nodes = builder._import_from_nodes
module._delayed_assattr = builder._delayed_assattr

self._manager.cache_module(module)
Copy link
Collaborator

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?

Copy link
Member

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.

cdce8p
cdce8p previously requested changes Feb 27, 2022
Copy link
Member

@cdce8p cdce8p left a 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.

@cdce8p cdce8p dismissed their stale review February 27, 2022 19:13

Updated code

@cdce8p
Copy link
Member

cdce8p commented Feb 27, 2022

I've updated the code to pass builder along instead. Didn't want to drag this on any longer.

@cdce8p cdce8p requested review from DanielNoord and Pierre-Sassoulas and removed request for Pierre-Sassoulas February 27, 2022 19:17
@cdce8p cdce8p added the pylint-tested PRs that don't cause major regressions with pylint label Feb 27, 2022
Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a 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

@Pierre-Sassoulas Pierre-Sassoulas merged commit 0acb961 into pylint-dev:main Feb 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Maintenance Discussion or action around maintaining astroid or the dev workflow pylint-tested PRs that don't cause major regressions with pylint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants