Skip to content
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

Allow args for editor via env variable #8612

Closed
wants to merge 2 commits into from

Conversation

gutsytechster
Copy link
Contributor

This works for the Python3 only as the implementation uses methods
which are only supported by the Python3.

This fixes #7392

This works for the Python3 only as the implementation uses methods
which are only supported by the Python3.

Co-authored by: Chris Hunt <[email protected]>
@gutsytechster
Copy link
Contributor Author

gutsytechster commented Jul 22, 2020

I still have to write tests. However, I am unsure about the location where tests should go? Also, should the helper function go into utils/misc or is it fine here?

Comment on lines 261 to 262
# Currently mypy fails for Python2 as it could not recognise the
# shutil.which()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Currently mypy fails for Python2 as it could not recognise the
# shutil.which()
# mypy fails for Python2 as shutil.which() is not supported

@pradyunsg
Copy link
Member

I still have to write tests

I think you can put them in tests/unit/test_configuration.py.

Also, should the helper function go into utils/misc or is it fine here?

Staying in this module is fine, but since it doesn't use self, I'd suggest making it a module-level function instead of a method.

@@ -237,13 +241,32 @@ def open_in_editor(self, options, args):
raise PipError("Could not determine appropriate file.")

try:
subprocess.check_call([editor, fname])
if PY3:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest moving all the not-subprocess-call stuff into _determine_editor and then, changing the original subprocess call line to:

subprocess.check_call(editor_args + [fname])

Copy link
Member

@pradyunsg pradyunsg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up @gutsytechster! ^.^

(1) I suggest moving all the not-subprocess-call stuff to just-after _determine_editor (and out of the try-except) and then, changing the original subprocess call line to:

subprocess.check_call(editor_command + [fname])

(2) The check for PY3 can probably be moved into _get_editor_cmd (which I suggest renaming to parse_editor_value()) so that we have a direct assignment here, which would be cleaner IMO.

if PY2:
    return [editor]
...

This might also help with the mypy situation, since mypy will recognize (AFAIK) the if PY2: on Python 2. If not, just say Python 2 (not Python2) so that it can show up as part of a Python 2|PY2 search that we'll be doing later in the year. :)

@pradyunsg
Copy link
Member

Going to go ahead and close this, since the underlying issue has been resolved. Thanks @gutsytechster for filing this PR! ^>^

@pradyunsg pradyunsg closed this Sep 30, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs rebase or merge PR has conflicts with current master
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pip config and $EDITOR containing arguments
4 participants