-
-
Notifications
You must be signed in to change notification settings - Fork 10
PR: Cleaning up code #94
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a quick pass on the code. A few comments here and here but overall the code looks more clear and more pythonic after your changes.
@@ -275,17 +268,17 @@ def data(self, index, role=Qt.DisplayRole): | |||
color = palette.color(QPalette.Mid) | |||
color = P['foreground.not.installed'] | |||
return to_qvariant(color) | |||
elif column in [C.COL_VERSION]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use ==
here since there is only one choice ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
# | ||
# Licensed under the terms of the MIT License | ||
# ----------------------------------------------------------------------------- | ||
"""Bottstrap script.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in Bootstrap
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
elif role == Qt.SizeHintRole: | ||
if column in [C.ACTION_COLUMNS] + [C.COL_PACKAGE_TYPE]: | ||
elif (role == Qt.SizeHintRole and column in | ||
C.ACTION_COLUMNS + [C.COL_PACKAGE_TYPE]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The semantic is changed for the addition here, is it normal ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it was a mistae :-|
@@ -129,7 +129,7 @@ def toint(x): | |||
# replace letters found by a negative number | |||
replace_dic = {} | |||
alpha = sorted(alpha, reverse=True) | |||
if len(alpha): | |||
if alpha: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sort can be done inside the if
block I guess ?
@@ -116,23 +116,28 @@ def set_environments(self, prefix): | |||
""" """ | |||
self.packages.set_environment(prefix=prefix) | |||
|
|||
def add_env(self): | |||
@staticmethod | |||
def add_env(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These shouldn't be removed since I guess that self
will be used in the methods. Did you use an automated program to clean the code ?
@@ -163,7 +165,7 @@ def __init__(self, | |||
self._parent = parent | |||
self._current_action_name = '' | |||
self._hide_widgets = False | |||
self._metadata = extra_metadata # From repo.continuum | |||
self._metadata = extra_metadata if extra_metadata else {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe extra_metadata or {}
instead ? It's a common idiom in python.
self._metadata = metadata | ||
else: | ||
blacklist = [] | ||
self._metadata = metadata if metadata else {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as before
""" """ | ||
# If environment exists already? GUI should take care of this | ||
# BUT the api call should simply set that env as the env | ||
dic = {} | ||
packages = packages if packages else ['python'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same again.
self.button_clear.setVisible(True) | ||
else: | ||
self.button_clear.setVisible(False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about:
visibility = self.text() # or bool(self.text()) to help the reader understand the intent
self.button_clear.setVisible(visibility)
It's shorter and looks less naive.
""" """ | ||
self.proxy_model = MultiColumnSortFilterProxy(self) | ||
self.source_model = CondaPackagesModel(self, packages, data) | ||
self.proxy_model.setSourceModel(self.source_model) | ||
self.setModel(self.proxy_model) | ||
self.metadata_links = metadata_links | ||
self.metadata_links = metadata_links if metadata_links else {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same.
Thanks for the comments @Nodd will fix them and merge. |
No description provided.