There are many places where we could make use of Pathlib.
Look for any places that uses with open(...)
and ask yourself:
Path()
, Don't try to bite more than you can chew (or more than I can review), try to fix 1 place at a time.
for example see https://github.com/ipython/ipython/pull/12512
Hi @Carreau, if no one is working on /core/page.py for using Pathlib, can I take this part?
Hi @Carreau, if no one is working on /core/page.py for using Pathlib, can I take this part?
Sure, please. Thanks.
Hi, I would like to work on core/interactiveshell.py and add there more use of Pathlib.
Can I help with that?
Hey @Carreau can I take on testing/iptestcontroller.py and core/magics/execution.py ?
Might also be of use: https://docs.python.org/3/library/pathlib.html#correspondence-to-tools-in-the-os-module
There are many places other than with open()
that might use pathlib treatment:
- conda_history = os.path.join(sys.prefix, 'conda-meta', 'history')
- return os.path.exists(conda_history)
+ return Path(sys.prefix, 'conda-meta', 'history').exists()
That's a good point.
On Sat, Oct 10, 2020 at 8:33 PM Blazej Michalik notifications@github.com
wrote:
Might also be of use:
https://docs.python.org/3/library/pathlib.html#correspondence-to-tools-in-the-os-moduleThere are many places other than with open() that might use pathlib
treatment:
- conda_history = os.path.join(sys.prefix, 'conda-meta', 'history')- return os.path.exists(conda_history)+ return Path(sys.prefix, 'conda-meta', 'history').exists()
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/ipython/ipython/issues/12515#issuecomment-706630653,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ADMY5F73MJDQ6CL32KEUZS3SKD4LXANCNFSM4QNPWX2Q
.
Might also be of use: https://docs.python.org/3/library/pathlib.html#correspondence-to-tools-in-the-os-module
There are many places other than
with open()
that might use pathlib treatment:
Although... some of them might be less trivial and more error prone, especially when they're interpreted as text. For example, when returning a PosixPath
object breaks code in the scope above because it is being ' '.join()
-ed with other shell arguments.
There still any places left to fix this? Looks like a lot of people are working on it.
edit: found some, nevermind
There still any places left to fix this? Looks like a lot of people are working on it.
I'm slowly checking the PRs and merging them, I'm not sure if there are other places left.
THere are other things you can try; find all places that uses cast_unicode/cast_bytes, and see if they are removable. Many of those are due to old Python 2 compatibility.
for example there is
def find_file(obj) -> str:
...
fname = None
try:
fname = inspect.getabsfile(obj)
except TypeError:
# For an instance, the file that matters is where its class was
# declared.
if hasattr(obj, '__class__'):
try:
fname = inspect.getabsfile(obj.__class__)
except TypeError:
# Can happen for builtins
pass
except:
pass
return cast_unicode(fname)
If you can prove that inspect.getabsfil
always return str and not bytes, then cast_unicode
is unnecessary. It's a bit more work, but that would cleanup a bt the codebase.
I searched for the functions in the whole project and i found many of them. Should i consider replacing all of them with Pathlib alternatives or what files should i consider not replacing the functions in?
Sorry if i couldn't make you understand what i want to say.
I'm working on paths.py
and I found the following line in several functions:
assert isinstance(ipdir, str)
One of such assertions gives a message saying "all path manipulation should be str(unicode), but are not."
.
Should I delete such lines so the move to pathlib can work?
I'm working on
paths.py
and I found the following line in several functions:assert isinstance(ipdir, str)
One of such assertions gives a message saying
"all path manipulation should be str(unicode), but are not."
.Should I delete such lines so the move to pathlib can work?
Yea some places are not working because of that.
Hi everyone, I'm trying to review all the PRs, there are many tacking this issues, be careful some of you are sending changes for which there are already other PRs opened.
Why is this closed now?
@meeseeksdev open
Awww, sorry ashwinvis you do not seem to be allowed to do that, please ask a repository maintainer.
I am new to open source contribution and would love to work on this issue. After I am done with my changes, what would be the easiest way to test the code before I create a PR?
I am new to open source contribution and would love to work on this issue. After I am done with my changes, what would be the easiest way to test the code before I create a PR?
Hello @squarebat
You should do this:
$ pip3 install -e .[test]
$ iptest
I want to work on the test_run.py
file. However, I'm having trouble resolving some errors in that file. The two main errors are
undefined variable get_ipython
(This one is resolved by adding an import but that seems wrong)
undefined variable _ip
: In some functions _ip
is initialized as _ip = get_ipython()
hence defining it, but in other functions it not initialized, hence causing error.
I have set up my environment using pip install .
I just wanted to know if I made a mistake while setting up the environment, or if there is a bug in the test_run.py
file.
I have set up my environment using
pip install
You have to use pip install -e .[test]
The -e
means that you Install it in editable mode.
Hello! This is my first time contributing to an open source project , I would like to work on this issue .
can i get assigned ?
Most helpful comment
Hi everyone, I'm trying to review all the PRs, there are many tacking this issues, be careful some of you are sending changes for which there are already other PRs opened.