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

Let AstroidManager.clear_cache act on other caches #1521

Merged

Conversation

jacobtylerwalls
Copy link
Member

@jacobtylerwalls jacobtylerwalls commented Apr 20, 2022

Description

Alternative to #1242. See #1242 (review)

Type of Changes

Type
βœ“ πŸ› Bug fix
βœ“ πŸ”¨ Refactoring

Related Issue

Resolves #792 (but let's get a benchmark and find out)

@coveralls
Copy link

coveralls commented Apr 20, 2022

Pull Request Test Coverage Report for Build 2281918404

  • 20 of 20 (100.0%) changed or added relevant lines in 4 files are covered.
  • 69 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.06%) to 91.735%

Files with Coverage Reduction New Missed Lines %
astroid/interpreter/_import/spec.py 3 98.21%
astroid/objects.py 11 93.13%
astroid/nodes/node_classes.py 55 94.79%
Totals Coverage Status
Change from base Build 2271567685: 0.06%
Covered Lines: 9157
Relevant Lines: 9982

πŸ’› - Coveralls

@jacobtylerwalls jacobtylerwalls changed the title Proof of concept for extending Manager.clear_cache to other caches Let Manager.clear_cache act on other caches Apr 20, 2022
@jacobtylerwalls jacobtylerwalls marked this pull request as ready for review April 20, 2022 19:58
@jacobtylerwalls jacobtylerwalls added the Maintenance Discussion or action around maintaining astroid or the dev workflow label Apr 20, 2022
astroid/interpreter/objectmodel.py Show resolved Hide resolved
astroid/manager.py Outdated Show resolved Hide resolved
astroid/modutils.py Show resolved Hide resolved
tests/unittest_scoped_nodes.py Outdated Show resolved Hide resolved
astroid/manager.py Show resolved Hide resolved
astroid/modutils.py Show resolved Hide resolved
jacobtylerwalls and others added 3 commits April 21, 2022 09:14
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
@jacobtylerwalls jacobtylerwalls added the Blocked 🚧 A PR or issue blocked by another PR or issue label Apr 23, 2022
@jacobtylerwalls jacobtylerwalls changed the title Let Manager.clear_cache act on other caches Let AstroidManager.clear_cache act on other caches Apr 23, 2022
@jacobtylerwalls jacobtylerwalls added this to the 2.12.0 milestone Apr 23, 2022
@jacobtylerwalls jacobtylerwalls removed the Blocked 🚧 A PR or issue blocked by another PR or issue label May 4, 2022
result = _NORM_PATH_CACHE[path] = _normalize_path(path)
return result
if not path: # don't cache result for ''
return _normalize_path(path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is not covered, on the other hand are we really ever having something falsey here ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added coverage. We talked a bit about it here.

tests/unittest_manager.py Outdated Show resolved Hide resolved
@@ -23,8 +23,6 @@
Union,
)

import wrapt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering if we could remove the dependency to wrapt following this change, Turns out that there are other uses elsewhere but not that much.

@jacobtylerwalls
Copy link
Member Author

Ah, another test isolation issue to look into.

@@ -179,7 +179,7 @@ def test_load_packages_without_init(self) -> None:
https://github.com/PyCQA/astroid/issues/1327
"""
tmp_dir = Path(tempfile.gettempdir())
self.addCleanup(os.chdir, os.curdir)
self.addCleanup(os.chdir, os.getcwd())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to actually find the cwd before changing dir, otherwise this cleanup won't do anything.

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.

πŸ‘

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Continuously increasing memory usage when pylint is run via its API
4 participants