You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are many places where we could make use of Pathlib.
Look for any places that uses with open(...) and ask yourself:
is the argument a string ?
would it make sens to make it a Path(),
how far upstream in the code can I make it a 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.
Reacted by Charles Tapley Hoyt, Daniel Malik, Deepak Raj, Ashwin V. Mohanan, Michał Krassowski, Rômulo Férrer Filho, Faris A Chugthai, Léo Banno-Cloutier, David Brito and Sumagna Das
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.
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 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 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.
In general this is open source, we can't/won't assign people to it; if you want to work on something you are free to do so; You can comment that you are planning on doing X/Y/Z to avoid people doing duplicate work, you can also submit draft/incomplete PRs to show that you are working on it.
But keep in mind that in general maintainer will tend to just ignore those comments as too many people say "I will do X" and never do it.
Even if closed, if you believe some files may make use of better libraries like pathlib, feel free to do so, but please keep your PRs small.
Activity
Carreau commentedon Aug 27, 2020
for example see #12512
Inception95 commentedon Sep 21, 2020
Hi @Carreau, if no one is working on /core/page.py for using Pathlib, can I take this part?
Carreau commentedon Sep 21, 2020
Sure, please. Thanks.
barhenkro commentedon Oct 8, 2020
Hi, I would like to work on core/interactiveshell.py and add there more use of Pathlib.
Can I help with that?
nicksspirit commentedon Oct 9, 2020
Hey @Carreau can I take on testing/iptestcontroller.py and core/magics/execution.py ?
MrMino commentedon Oct 11, 2020
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:nicksspirit commentedon Oct 11, 2020
MrMino commentedon Oct 11, 2020
Although... some of them might be less trivial and more error prone, especially when they're interpreted as text. For example, when returning a
PosixPathobject breaks code in the scope above because it is being' '.join()-ed with other shell arguments.Creonalia commentedon Oct 13, 2020
There still any places left to fix this? Looks like a lot of people are working on it.
edit: found some, nevermind
Carreau commentedon Oct 13, 2020
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
If you can prove that
inspect.getabsfilalways return str and not bytes, thencast_unicodeis unnecessary. It's a bit more work, but that would cleanup a bt the codebase.sumagnadas commentedon Oct 16, 2020
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.
davbrito commentedon Oct 19, 2020
I'm working on
paths.pyand I found the following line in several functions: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?
8 remaining items
davbrito commentedon Nov 5, 2020
Hello @squarebat
You should do this:
squarebat commentedon Nov 5, 2020
I want to work on the
test_run.pyfile. However, I'm having trouble resolving some errors in that file. The two main errors areundefined variable get_ipython(This one is resolved by adding an import but that seems wrong)undefined variable _ip: In some functions_ipis 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.pyfile.davbrito commentedon Nov 7, 2020
You have to use
pip install -e .[test]The
-emeans that you Install it in editable mode.joesinghh commentedon Dec 6, 2020
Hello! This is my first time contributing to an open source project , I would like to work on this issue .
can i get assigned ?
Use `pathlib` instead of `os` in IPython/lib/demo (ipython#12515)
nitin-pandita commentedon Apr 2, 2023
Hey, I would love to work on this issue, as a beginner in Open source I think I can make it work. Thank you
refactor: Use pathlib in tools/ (#14218)
refactor: use pathlib in sysinfo.py (#14221)
HmbleCreator commentedon Oct 14, 2024
Hey, I would love to work on this issue can you assign it to me ?
kevin1kevin1k commentedon Oct 15, 2024
I am also willing to work on this, possibly on different set of files.
Carreau commentedon Oct 17, 2024
Closing this issue,
In general this is open source, we can't/won't assign people to it; if you want to work on something you are free to do so; You can comment that you are planning on doing X/Y/Z to avoid people doing duplicate work, you can also submit draft/incomplete PRs to show that you are working on it.
But keep in mind that in general maintainer will tend to just ignore those comments as too many people say "I will do X" and never do it.
Even if closed, if you believe some files may make use of better libraries like pathlib, feel free to do so, but please keep your PRs small.
Refactor with Pathlib for setupbase.py (#14543)