Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

PR: Cleaning up code #94

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

PR: Cleaning up code #94

wants to merge 10 commits into from

Conversation

goanpeca
Copy link
Member

No description provided.

Copy link

@Nodd Nodd left a 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]:
Copy link

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 ?

Copy link
Member Author

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."""
Copy link

Choose a reason for hiding this comment

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

Typo in Bootstrap

Copy link
Member Author

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]):
Copy link

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 ?

Copy link
Member Author

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:
Copy link

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():
Copy link

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 {}
Copy link

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 {}
Copy link

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']
Copy link

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)
Copy link

@Nodd Nodd Sep 23, 2016

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 {}
Copy link

Choose a reason for hiding this comment

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

Same.

@goanpeca
Copy link
Member Author

Thanks for the comments @Nodd will fix them and merge.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants