Skip to content

Commit 0fe453c

Browse files
authored
Merge pull request #81 from chennes/moreUnusedImports
Eliminate more unused imports
2 parents e008194 + 348cee8 commit 0fe453c

File tree

6 files changed

+21
-16
lines changed

6 files changed

+21
-16
lines changed

Addon.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
import os
2727
import re
28-
from datetime import datetime
2928
from urllib.parse import urlparse
3029
from typing import Dict, Set, List, Optional
3130
from threading import Lock

AddonManagerTest/app/test_utilities.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@
2727
import os
2828
import subprocess
2929

30-
try:
31-
import FreeCAD
32-
except ImportError:
33-
FreeCAD = None
34-
3530
from AddonManagerTest.app.mocks import MockAddon as Addon
3631

3732
from addonmanager_utilities import (

AddonManagerTest/gui/test_python_deps_gui.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,7 @@
44
import unittest
55
from unittest.mock import MagicMock, patch
66

7-
try:
8-
import FreeCAD
9-
import FreeCADGui
10-
except ImportError:
11-
try:
12-
from PySide6 import QtCore, QtWidgets
13-
except ImportError:
14-
from PySide2 import QtCore, QtWidgets
7+
from PySideWrapper import QtCore, QtWidgets
158

169

1710
from addonmanager_python_deps_gui import (
@@ -21,7 +14,7 @@
2114
python_package_updates_are_available,
2215
parse_pip_list_output,
2316
)
24-
from AddonManagerTest.gui.gui_mocks import DialogInteractor, DialogWatcher
17+
from AddonManagerTest.gui.gui_mocks import DialogWatcher
2518

2619

2720
class TestPythonPackageManager(unittest.TestCase):

AddonManagerTest/run_gui_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
QApplication = None
1212
try:
1313
from PySide6 import QtCore, QtWidgets
14-
from PySide6.QtWidgets import QApplication, QWidget
14+
from PySide6.QtWidgets import QApplication
1515

1616
pyside_version = 6
1717
except ImportError:

PySideWrapper.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,16 @@
3131
from PySide6 import QtCore, QtGui, QtNetwork, QtSvg, QtWidgets
3232
except ImportError:
3333
from PySide2 import QtCore, QtGui, QtNetwork, QtSvg, QtWidgets
34+
35+
# Dummy usage so the linter doesn't complain about the unused imports (since the whole point here is
36+
# that the imports aren't used in this file, they are just wrapped here)
37+
if hasattr(QtCore, "silence_the_linter"):
38+
pass
39+
if hasattr(QtGui, "silence_the_linter"):
40+
pass
41+
if hasattr(QtNetwork, "silence_the_linter"):
42+
pass
43+
if hasattr(QtSvg, "silence_the_linter"):
44+
pass
45+
if hasattr(QtWidgets, "silence_the_linter"):
46+
pass

addonmanager_freecad_interface.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@
4343

4444
try:
4545
from freecad.utils import get_python_exe
46+
47+
try:
48+
_ = get_python_exe()
49+
except AttributeError as e:
50+
raise RuntimeError("Could not get the FreeCAD python executable") from e
4651
except ImportError:
4752
# This was only added in FreeCAD 1.0 -- to support FreeCAD 0.21 a backup strategy must be
4853
# used. This code is borrowed from FreeCAD 1.1dev.

0 commit comments

Comments
 (0)