Skip to content

Commit

Permalink
Rename attribute project_paths -> project_path and declare attributes…
Browse files Browse the repository at this point in the history
… in __init__
  • Loading branch information
mrclary committed Jan 24, 2025
1 parent 1c0dc21 commit 9045eff
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
4 changes: 2 additions & 2 deletions spyder/plugins/pythonpath/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def show_path_manager(self):
# see spyder-ide/spyder#20808.
if not self.path_manager_dialog.isVisible():
self.path_manager_dialog.update_paths(
project_paths=self._project_path,
project_path=self._project_path,
user_paths=self._user_paths,
system_paths=self._system_paths,
prioritize=self._prioritize
Expand All @@ -117,7 +117,7 @@ def show_path_manager(self):

def get_spyder_pythonpath(self):
"""Return active Spyder PYTHONPATH as a list of paths."""
# Desired behavior is project_paths | user_paths | system_paths, but
# Desired behavior is project_path | user_paths | system_paths, but
# Python 3.8 does not support | operator for OrderedDict.
all_paths = OrderedDict(reversed(self._system_paths.items()))
all_paths.update(reversed(self._user_paths.items()))
Expand Down
24 changes: 15 additions & 9 deletions spyder/plugins/pythonpath/widgets/pathmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ def __init__(self, parent, sync=True):
self.bbox.accepted.connect(self.accept)
self.bbox.rejected.connect(self.reject)

# Attributes
self.project_path = None
self.user_paths = None
self.system_paths = None
self.prioritize = None

# ---- Private methods
# -------------------------------------------------------------------------
def _add_buttons_to_layout(self, widgets, layout):
Expand Down Expand Up @@ -200,7 +206,7 @@ def _create_item(self, path, active):
"""Helper to create a new list item."""
item = QListWidgetItem(path)

if path in self.project_paths:
if path in self.project_path:
item.setFlags(Qt.NoItemFlags | Qt.ItemIsUserCheckable)
item.setCheckState(Qt.Checked)
else:
Expand Down Expand Up @@ -279,7 +285,7 @@ def editable_bottom_row(self):
bottom_row = 0

if self.project_header:
bottom_row += len(self.project_paths) + 1
bottom_row += len(self.project_path) + 1
if self.user_header:
bottom_row += len(self.get_user_paths())

Expand All @@ -291,7 +297,7 @@ def editable_top_row(self):
top_row = 0

if self.project_header:
top_row += len(self.project_paths) + 1
top_row += len(self.project_path) + 1
if self.user_header:
top_row += 1

Expand All @@ -306,15 +312,15 @@ def setup(self):
self.system_header = None

# Project path
if self.project_paths:
if self.project_path:
self.project_header, project_widget = (
self._create_header(_("Project path"))
)
self.headers.append(self.project_header)
self.listwidget.addItem(self.project_header)
self.listwidget.setItemWidget(self.project_header, project_widget)

for path, active in self.project_paths.items():
for path, active in self.project_path.items():
item = self._create_item(path, active)
self.listwidget.addItem(item)

Expand Down Expand Up @@ -438,7 +444,7 @@ def get_system_paths(self):

def update_paths(
self,
project_paths=None,
project_path=None,
user_paths=None,
system_paths=None,
prioritize=None
Expand All @@ -451,8 +457,8 @@ def update_paths(
used to compare with what is shown in the listwidget in order to detect
changes.
"""
if project_paths is not None:
self.project_paths = project_paths
if project_path is not None:
self.project_path = project_path
if user_paths is not None:
self.user_paths = user_paths
if system_paths is not None:
Expand Down Expand Up @@ -707,7 +713,7 @@ def test():
)
dlg.update_paths(
user_paths={p: True for p in sys.path[1:-2]},
project_paths={p: True for p in sys.path[:1]},
project_path={p: True for p in sys.path[:1]},
system_paths={p: True for p in sys.path[-2:]},
prioritize=False
)
Expand Down
4 changes: 2 additions & 2 deletions spyder/plugins/pythonpath/widgets/tests/test_pathmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
@pytest.fixture
def pathmanager(qtbot, request):
"""Set up PathManager."""
user_paths, project_paths, system_paths = request.param
user_paths, project_path, system_paths = request.param

widget = pathmanager_mod.PathManager(None)
widget.update_paths(
user_paths=OrderedDict({p: True for p in user_paths}),
project_paths=OrderedDict({p: True for p in project_paths}),
project_path=OrderedDict({p: True for p in project_path}),
system_paths=OrderedDict({p: True for p in system_paths}),
prioritize=False
)
Expand Down

0 comments on commit 9045eff

Please sign in to comment.