mdanalysis icon indicating copy to clipboard operation
mdanalysis copied to clipboard

Replace custom lib.util.which with shutil.which

Open Seanny123 opened this issue 3 years ago • 4 comments
trafficstars

Given the newest version of MDAnalysis support Python 3.6+, is it reasonable to replace lib.util.which with shutil.which? They seems to have identical intended uses and functionality. Using the standard library instead of custom code reduces the maintenance burden.

If this is a reasonable/desired change, I'll make a PR performing the replacement.

I realize this is a small nitpick, but I found it while reading the codebase and would like to take this opportunity to become a contributor to this project.

Seanny123 avatar Apr 18 '22 17:04 Seanny123

Less code is always the best option in my opinion. If they work equally under the OS conditions they are expected to work then I support such a change.

IAlibay avatar Apr 18 '22 18:04 IAlibay

I think we would then

  • replace the lib.util.which function with shutil.which and add a deprecation note (to be removed in 3.0)
  • replace all use of lib.util.which with shutil.which across the library (so that we don't trigger our own deprecation warning)

orbeckst avatar Apr 22 '22 23:04 orbeckst

Since no PR has been opened for this, I would like to work on this issue. @orbeckst please let me know how and where should the note be added once we replace the usage of lib.util.which with shutil.which.

aditi2906 avatar May 14 '22 18:05 aditi2906

You need to keep lib.util.which() but decorate it with our deprecated decorator (see other examples in the code). You’d replace the body of the lib.util.which() function with a call to shutil.which().

The idea is that existing code that uses lib.util.which() will not break but raise a deprecation warning so that people have time to change their code to use shutil.which().

orbeckst avatar May 15 '22 05:05 orbeckst