Skip to content

Commit

Permalink
fix: Test another approach with excluding at project level
Browse files Browse the repository at this point in the history
  • Loading branch information
last-partizan committed Feb 25, 2024
1 parent 36a28ad commit 2aaf77c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
15 changes: 14 additions & 1 deletion rope/base/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,22 @@ def __init__(
super().__init__(fscommands)
self.ignored = _ResourceMatcher()
self.file_list = _FileListCacher(self)

extra_ignores = [
p.pathlib.relative_to(self.root.pathlib)
for p in self.get_python_path_folders()
if p.pathlib.is_relative_to(self.root.pathlib)
and "site-packages" in p.pathlib.parts
]
for p in extra_ignores:
# I'm using this approach, because self.prefs.add after _init_prefs
# does not work for some reason.
prefs["ignored_resources"].append(str(p))

self._init_prefs(prefs)
if ropefolder is not None:
self.prefs.add("ignored_resources", ropefolder)

self._init_source_folders()

def __repr__(self):
Expand Down Expand Up @@ -281,7 +294,7 @@ def _init_other_parts(self):
# Forcing the creation of `self.pycore` to register observers
self.pycore # pylint: disable=pointless-statement

def is_ignored(self, resource):
def is_ignored(self, resource: Resource):
return self.ignored.does_match(resource)

def sync(self):
Expand Down
2 changes: 1 addition & 1 deletion rope/base/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def _add_pattern(self, pattern):
re_pattern = "^(.*/)?" + re_pattern + "(/.*)?$"
self.compiled_patterns.append(re.compile(re_pattern))

def does_match(self, resource):
def does_match(self, resource: Resource):
for pattern in self.compiled_patterns:
if pattern.match(resource.path):
return True
Expand Down
5 changes: 1 addition & 4 deletions rope/contrib/autoimport/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,7 @@ def generate_cache(
project are cached.
"""
if resources is None:
resources = [
f for f in self.project.get_python_files()
if "site-packages" not in f.pathlib.parts
]
resources = self.project.get_python_files()
job_set = task_handle.create_jobset(
"Generating autoimport cache", len(resources)
)
Expand Down

0 comments on commit 2aaf77c

Please sign in to comment.