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

skip directories with perm error when building autoimport index #733

Merged
merged 11 commits into from
Jan 3, 2024

Conversation

MrBago
Copy link

@MrBago MrBago commented Dec 1, 2023

Description

WIth this fix, rope will skip folders in sys.path that the user does not have permission to access instead of failing the entire cache build.

Fixes #(issue)

Checklist (delete if not relevant):

  • I have added tests that prove my fix is effective or that my feature works
  • I have updated CHANGELOG.md
  • I have made corresponding changes to user documentation for new features
  • I have made corresponding changes to library documentation for API changes

@MrBago
Copy link
Author

MrBago commented Dec 1, 2023

I ran into this minor issue when working on my other PR so here's a quick patch.

@tkrabel-db
Copy link

@MrBago thanks for that! LGTM.

with tempfile.TemporaryDirectory() as dir:
import os
os.chmod(dir, 0)
sys.path.append(dir)
Copy link
Member

Choose a reason for hiding this comment

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

This test lacks isolation, changing the sys.path here is global mutation that won't be undone by the end of the test so it will affect other tests as well.

Choose a reason for hiding this comment

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

@MrBago I think it's enough to remove the dir at the end of the context manager.

Copy link
Author

Choose a reason for hiding this comment

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

@lieryan I updated the test to use prefs.python_paths instead of sys.path.

Copy link
Member

@lieryan lieryan left a comment

Choose a reason for hiding this comment

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

Tests shouldn't be changing the sys.path globally

@MrBago MrBago requested a review from lieryan December 21, 2023 19:33
@MrBago
Copy link
Author

MrBago commented Jan 2, 2024

@lieryan Happy new year! When you have a min, can you look the update I made to this PR?

@lieryan lieryan changed the title skip sys.path dirs with perm error skip directories with perm error when building autoimport index Jan 3, 2024
@lieryan lieryan enabled auto-merge January 3, 2024 01:08
@lieryan
Copy link
Member

lieryan commented Jan 3, 2024

Thanks for fixing this issue @MrBago

@lieryan
Copy link
Member

lieryan commented Jan 3, 2024

@all-contributors add @MrBago for code contribution

Copy link
Contributor

@lieryan

I've put up a pull request to add @MrBago! 🎉

@lieryan lieryan merged commit 174f084 into python-rope:master Jan 3, 2024
17 checks passed
@lieryan lieryan added this to the 1.12.0 milestone Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants