8000 resolve #6595 use OO inheritence in activate.py by kalefranz · Pull Request #7049 · conda/conda · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

resolve #6595 use OO inheritence in activate.py #7049

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

Merged
merged 3 commits into from
Mar 28, 2018

Conversation

kalefranz
Copy link
Contributor

resolve #6595

@kalefranz kalefranz requested a review from a team as a code owner March 17, 2018 15:54
@kalefranz kalefranz requested a review from mbargull March 17, 2018 15:54
Copy link
Member
@mbargull mbargull left a comment

Choose a reason for hiding this comment

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

The shell-specific code in build_activate and _update_prompt should go into the appropriate derived classes (https://github.com/conda/conda/pull/7049/files#diff-a871ac4214094e0e18e2c240a36dcab3R214 and https://github.com/conda/conda/pull/7049/files#diff-a871ac4214094e0e18e2c240a36dcab3R399).
Otherwise, LGTM for now.

def __init__(self, shell, arguments=None):
self.shell = shell
# The following instance variables must be defined by each implementation.
shell = None
Copy link
Member

Choose a reason for hiding this comment

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

Technically, we don't need self.shell anymore and thus could remove it.


try:
from cytoolz.itertoolz import concatv, drop
except ImportError: # pragma: no cover
from ._vendor.toolz.itertoolz import concatv, drop # NOQA


class Activator(object):
class _Activator(object):
Copy link
Member

Choose a reason for hiding this comment

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

We could make this class _Activator(ABC) and thus use @abstractmethod to automatically check for methods/properties being implemented.
This would add a little bit more boilerplate (which I would be fine with). But we would also need to look out for Python 2 intricacies (e.g., need to use metaclass=ABCMeta, the deprecated @abstractproperty, ...).
So, although I'd prefer using ABC, I'm also not eager to deal with PY2 stuff...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that's why I didn't go in that direction, and just renamed Activator to _Activator.

shift_args = None
command_join = None

unset_var_tmpl = None
Copy link
Member

Choose a reason for hiding this comment

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

We could replace those template with methods that return the appropriate formatted strings, like suggested in #6585 (comment), which would make the code a little cleaner/better readable.
But that could also be done in a subsequent PR anytime and is not crucial for this one.

@mbargull mbargull added the cli pertains to the CLI interface label Mar 18, 2018
@kalefranz
Copy link
Contributor Author

@mbargull If you're around, do we look good to go here now?

@mbargull
Copy link
Member

LGTM. Saw that you already fixed 3.0 conda-build on master.
Any further improvements should profit from these changes and can be put into subsequent separate PRs.

@kalefranz
Copy link
Contributor Author

Thanks @mbargull! I’m getting closer on #6518, and I rebased that PR against this one and built on top. So wanted to be getting this merged.

@kalefranz kalefranz merged commit 31130cd into conda:master Mar 28, 2018
@kalefranz kalefranz deleted the resolve-6595 branch March 28, 2018 14:56
@github-actions
Copy link
github-actions bot commented Sep 4, 2021

Hi there, thank you for your contribution to Conda!

This pull request has been automatically locked since it has not had recent activity after it was closed.

Please open a new issue or pull request if needed.

@github-actions github-actions bot added the locked [bot] locked due to inactivity label Sep 4, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cli pertains to the CLI interface locked [bot] locked due to inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clean up activate.py using proper OO inheritence
2 participants
0