Skip to content

Avoid importing submodules sharing names with standard library modules #2702

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

Merged
merged 1 commit into from
Mar 9, 2025

Conversation

jacobtylerwalls
Copy link
Member

@jacobtylerwalls jacobtylerwalls commented Mar 9, 2025

Type of Changes

Type
βœ“ πŸ› Bug fix

Description

Closes #2684
Avoid importing user_module.std_lib_name if we can help it.

sys.path.insert(0, resources.find("data"))
try:
with pytest.raises(ImportError):
spec._find_spec_with_path(
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 would have preferred to find a public interface to test, but after almost an hour of fiddling I threw in the towel.

@jacobtylerwalls jacobtylerwalls merged commit 9f8faeb into main Mar 9, 2025
19 of 20 checks passed
@jacobtylerwalls jacobtylerwalls deleted the jtw/avoid-import branch March 9, 2025 20:49
github-actions bot pushed a commit that referenced this pull request Mar 9, 2025
Pierre-Sassoulas pushed a commit that referenced this pull request Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Astroid >=3.3.7 imports and executes modules that contain any similarly named identifier as some stdlib module
3 participants