Skip to content

Commit

Permalink
Merge pull request #16899 from ccordoba12/fix-deps-issues
Browse files Browse the repository at this point in the history
PR: Fix some issues with dependencies
  • Loading branch information
ccordoba12 committed Nov 26, 2021
2 parents 316e3ea + d52d80a commit def812c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 18 deletions.
8 changes: 4 additions & 4 deletions spyder/dependencies.py
Expand Up @@ -350,8 +350,8 @@ def add(modname, package_name, features, required_version,
global DEPENDENCIES
for dependency in DEPENDENCIES:
if dependency.modname == modname:
raise ValueError("Dependency has already been registered: %s"\
% modname)
raise ValueError(
f"Dependency has already been registered: {modname}")
DEPENDENCIES += [Dependency(modname, package_name, features,
required_version,
installed_version, kind)]
Expand Down Expand Up @@ -396,9 +396,9 @@ def status(deps=DEPENDENCIES, linesep=os.linesep):
text += '{title}: {version}{linesep}'.format(
title=title.ljust(maxwidth), version=version, linesep=linesep)

# Remove spurious linesep when reporting deps to Github
# Remove spurious linesep's when reporting deps to Github
if not linesep == '<br>':
text = text[:-1]
text = text[1:-1]

return text

Expand Down
19 changes: 17 additions & 2 deletions spyder/plugins/application/container.py
Expand Up @@ -342,13 +342,28 @@ def check_updates(self, startup=False):
@Slot()
def show_dependencies(self):
"""Show Spyder Dependencies dialog."""
# This is here in case the user tries to display the dialog before
# dependencies_thread has finished.
if not dependencies.DEPENDENCIES:
dependencies.declare_dependencies()

dlg = DependenciesDialog(self)
dlg.set_data(dependencies.DEPENDENCIES)
dlg.show()

def _compute_dependencies(self):
"""Compute dependencies without errors."""
# Skip error when trying to register dependencies several times.
# This can happen if the user tries to display the dependencies
# dialog before dependencies_thread has finished.
try:
dependencies.declare_dependencies()
except ValueError:
pass

def compute_dependencies(self):
"""Compute dependencies"""
self.dependencies_thread.run = dependencies.declare_dependencies
"""Compute dependencies."""
self.dependencies_thread.run = self._compute_dependencies
self.dependencies_thread.finished.connect(
self.report_missing_dependencies)

Expand Down
28 changes: 16 additions & 12 deletions spyder/widgets/reporterror.py
Expand Up @@ -126,6 +126,11 @@ class SpyderErrorDialog(QDialog):
def __init__(self, parent=None, is_report=False):
QDialog.__init__(self, parent)
self.is_report = is_report

# Set to true to run tests on the dialog. This is the default
# in the test function at the end of this file.
self._testing = False

self.setWindowTitle(_("Issue reporter"))
self._github_org = 'spyder-ide'
self._github_repo = 'spyder'
Expand Down Expand Up @@ -268,6 +273,13 @@ def render_issue(description='', traceback=''):
# Get component versions
versions = get_versions()

# Get dependencies if they haven't beed computed yet.
if not dependencies.DEPENDENCIES:
try:
dependencies.declare_dependencies()
except ValueError:
pass

# Get git revision for development version
revision = ''
if versions['revision']:
Expand Down Expand Up @@ -363,25 +375,16 @@ def _submit_to_github(self):
traceback = self.error_traceback[:-1] # Remove last EOL

# Render issue
if traceback:
issue_text = self.render_issue(description=description,
traceback=traceback)
else:
issue_text = description
issue_text = self.render_issue(description=description,
traceback=traceback)

try:
if running_under_pytest():
org = 'ccordoba12'
else:
org = self._github_org

org = self._github_org if not self._testing else 'ccordoba12'
repo = self._github_repo
github_backend = GithubBackend(org, repo, parent_widget=self)
github_report = github_backend.send_report(title, issue_text)

if github_report:
self.close()

except Exception:
ret = QMessageBox.question(
self,
Expand Down Expand Up @@ -463,6 +466,7 @@ def test():
from spyder.utils.qthelpers import qapplication
app = qapplication()
dlg = SpyderErrorDialog()
dlg._testing = True
dlg.show()
sys.exit(dlg.exec_())

Expand Down

0 comments on commit def812c

Please sign in to comment.