Remove import re from script template#13166
Conversation
|
While I would personally prefer the distlib script to contain the minimal number of imports, I am against diverging from distlibs default in pip. If distlib maintainers don't want to take on the burden of this putting that burden on to pip has all the same problems and more, pip is not running distlib's test suite, does not have distlib's expertise, and could fall out of sync with changes in distlib. And this would affect a huge number of users. I'll say -0, because it is actually fairly simple, and maybe some other maintainer is enthusiastic to support this. |
|
Added some code review comments, but see my comment on #13165 for my broader views. |
I am! |
| class PipScriptMaker(ScriptMaker): | ||
| # Override distlib's default script template with one that | ||
| # doesn't import `re` module, allowing scripts to load faster. | ||
| script_template = r"""import sys |
There was a problem hiding this comment.
nit: I'd prefer we do a textwrap.dedent for this template, just to make it easier to work with non-syntax aware collapses (and align the visual hierarchy).
There was a problem hiding this comment.
👍 added textwrap.dedent and made the r-string a regular string that has a backslash escape for the initial newline.
|
Note @ichard26 has some changes for this template also: pypa/distlib#242 @ichard26 you want to pull them in in this or a follow up PR? |
|
Let's keep the changes separate. If we're going to override the script template, then I'm happy to make the changes against our template instead against distlib, but they achieve different goals and should be reviewed independently. |
|
@hukkin thanks for your contribution. |
Overrides
distlib.scripts.ScripMaker.script_templatewith a template that doesn'timport re.Closes #13165