-
-
Notifications
You must be signed in to change notification settings - Fork 276
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
Prefer stdlib modules over same-named modules on sys.path #2223
base: main
Are you sure you want to change the base?
Conversation
02f375b
to
7a6b60f
Compare
For example: `import copy` now finds `copy` instead of `copy.py`. This worked correctly before in at least some cases if there was a (more?) complete chain of __init__.py files from cwd all the way to the location of the `copy.py` module. Closes pylint-dev/pylint#6535
cb0007c
to
b8755ba
Compare
e0d3f36
to
dae5921
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #2223 +/- ##
=======================================
Coverage 92.85% 92.85%
=======================================
Files 94 94
Lines 11053 11055 +2
=======================================
+ Hits 10263 10265 +2
Misses 790 790
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@@ -157,6 +157,19 @@ def find_module( | |||
location=getattr(spec.loader_state, "filename", None), | |||
type=ModuleType.PY_FROZEN, | |||
) | |||
if ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this clash with namespace
modules?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you flesh this out a little more for me? (Sorry!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
β― tree .
.
βββ argparse.py
βββ test.py
1 directory, 2 files
# test.py
import argparse
argparse.i_dont_exist()
# argparse.py
def i_dont_exist():
print("1")
β― python test.py
1
Won't this implementation default to stdlib.argparse
instead of the local argparse
?
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, in the comment I just hid I hadn't run the test case against the correct copy of astroid. More soon.
Type of Changes
Description
Prefer stdlib modules over same-named modules on sys.path
For example:
import copy
now findscopy
instead ofcopy.py
.This worked correctly before in at least some cases if there was a (more?) complete chain of
__init__.py
files from cwd all the way to the location of thecopy.py
module.Closes pylint-dev/pylint#6535