src/eric7/QScintilla/Editor.py

branch
eric7
changeset 9482
a2bc06a54d9d
parent 9473
3f23dbf37dbe
child 9517
d73c3a1e432b
--- a/src/eric7/QScintilla/Editor.py	Sun Nov 06 11:22:39 2022 +0100
+++ b/src/eric7/QScintilla/Editor.py	Mon Nov 07 17:19:58 2022 +0100
@@ -32,7 +32,12 @@
     pyqtSlot,
 )
 from PyQt6.QtGui import QActionGroup, QFont, QPainter, QPalette, QPixmap
-from PyQt6.QtPrintSupport import QAbstractPrintDialog, QPrintDialog, QPrinter
+from PyQt6.QtPrintSupport import (
+    QAbstractPrintDialog,
+    QPrintDialog,
+    QPrinter,
+    QPrintPreviewDialog,
+)
 from PyQt6.QtWidgets import QApplication, QDialog, QInputDialog, QLineEdit, QMenu
 
 from eric7 import Preferences, Utilities
@@ -49,6 +54,7 @@
 from eric7.UI import PythonDisViewer
 from eric7.Utilities import MouseUtilities
 
+from . import Exporters, Lexers, TypingCompleters
 from .EditorMarkerMap import EditorMarkerMap
 from .QsciScintillaCompat import QsciScintillaCompat
 from .SpellChecker import SpellChecker
@@ -740,8 +746,6 @@
 
         if not bindName and self.filetype:
             # check filetype
-            from . import Lexers
-
             supportedLanguages = Lexers.getSupportedLanguages()
             if self.filetype in supportedLanguages:
                 bindName = supportedLanguages[self.filetype][1]
@@ -1169,8 +1173,6 @@
         self.languagesActGrp.addAction(self.noLanguageAct)
         menu.addSeparator()
 
-        from . import Lexers
-
         self.supportedLanguages = {}
         supportedLanguages = Lexers.getSupportedLanguages()
         languages = sorted(supportedLanguages.keys())
@@ -1487,8 +1489,6 @@
         @param exporterFormat format the file should be exported into (string)
         """
         if exporterFormat:
-            from . import Exporters
-
             exporter = Exporters.getExporter(exporterFormat, self)
             if exporter:
                 exporter.exportSource()
@@ -1527,7 +1527,7 @@
 
         @return name of the selected pygments lexer (string)
         """
-        from pygments.lexers import get_all_lexers
+        from pygments.lexers import get_all_lexers  # __IGNORE_WARNING_I102__
 
         lexerList = sorted(lex[0] for lex in get_all_lexers())
         try:
@@ -1888,8 +1888,6 @@
             self.filetype = language.split("|")[-1]
             language = ""
 
-        from . import Lexers
-
         self.lexer_ = Lexers.getLexer(language, self, pyname=pyname)
         if self.lexer_ is None:
             self.setLexer()
@@ -2029,8 +2027,6 @@
             elif self.isRubyFile():
                 apiLanguage = "Ruby"
 
-        from . import TypingCompleters
-
         self.completer = TypingCompleters.getCompleter(apiLanguage, self)
 
     def getCompleter(self):
@@ -2619,6 +2615,8 @@
 
         @param line linenumber of the breakpoint to edit
         """
+        from eric7.Debugger.EditBreakpointDialog import EditBreakpointDialog
+
         if line is not None:
             self.line = line - 1
         if self.line < 0:
@@ -2639,8 +2637,6 @@
                     else []
                 )
 
-                from eric7.Debugger.EditBreakpointDialog import EditBreakpointDialog
-
                 dlg = EditBreakpointDialog(
                     (self.fileName, ln),
                     (cond, temp, enabled, ignorecount),
@@ -2883,8 +2879,6 @@
         """
         Public slot to show a print preview of the text.
         """
-        from PyQt6.QtPrintSupport import QPrintPreviewDialog
-
         from .Printer import Printer
 
         printer = Printer(mode=QPrinter.PrinterMode.HighResolution)
@@ -3439,8 +3433,6 @@
         if not path:
             path = Preferences.getMultiProject("Workspace") or Utilities.getHomeDir()
 
-        from . import Lexers
-
         if self.fileName:
             filterPattern = "(*{0})".format(os.path.splitext(self.fileName)[1])
             for fileFilter in Lexers.getSaveFileFiltersList(True):
@@ -6123,11 +6115,11 @@
         """
         Private method to handle the code metrics context menu action.
         """
+        from eric7.DataViews.CodeMetricsDialog import CodeMetricsDialog
+
         if not self.checkDirty():
             return
 
-        from eric7.DataViews.CodeMetricsDialog import CodeMetricsDialog
-
         self.codemetrics = CodeMetricsDialog()
         self.codemetrics.show()
         self.codemetrics.start(self.fileName)
@@ -6182,11 +6174,11 @@
         """
         Private method to handle the code coverage context menu action.
         """
+        from eric7.DataViews.PyCoverageDialog import PyCoverageDialog
+
         fn = self.__getCodeCoverageFile()
         self.__coverageFile = fn
         if fn:
-            from eric7.DataViews.PyCoverageDialog import PyCoverageDialog
-
             self.codecoverage = PyCoverageDialog()
             self.codecoverage.show()
             self.codecoverage.start(fn, self.fileName)
@@ -6210,14 +6202,16 @@
             (defaults to None)
         @type str (optional)
         """
+        from eric7.DebugClients.Python.coverage import (  # __IGNORE_WARNING_I102__
+            Coverage,
+        )
+
         self.__codeCoverageHideAnnotations()
 
         fn = coverageFile if bool(coverageFile) else self.__getCodeCoverageFile()
         self.__coverageFile = fn
 
         if fn:
-            from coverage import Coverage
-
             cover = Coverage(data_file=fn)
             cover.load()
             missing = cover.analysis2(self.fileName)[3]
@@ -6317,6 +6311,8 @@
         """
         Private method to handle the show profile data context menu action.
         """
+        from eric7.DataViews.PyProfileDialog import PyProfileDialog
+
         files = set()
 
         # first check if the file belongs to a project and there is
@@ -6349,8 +6345,6 @@
         else:
             return
 
-        from eric7.DataViews.PyProfileDialog import PyProfileDialog
-
         self.profiledata = PyProfileDialog()
         self.profiledata.show()
         self.profiledata.start(fn, self.fileName)
@@ -8058,10 +8052,10 @@
         """
         Public slot to perform an interactive spell check of the document.
         """
+        from .SpellCheckingDialog import SpellCheckingDialog
+
         if self.spell:
             cline, cindex = self.getCursorPosition()
-            from .SpellCheckingDialog import SpellCheckingDialog
-
             dlg = SpellCheckingDialog(self.spell, 0, self.length(), self)
             dlg.exec()
             self.setCursorPosition(cline, cindex)
@@ -8499,11 +8493,11 @@
         """
         Public slot to sort the lines spanned by a rectangular selection.
         """
+        from .SortOptionsDialog import SortOptionsDialog
+
         if not self.selectionIsRectangle():
             return
 
-        from .SortOptionsDialog import SortOptionsDialog
-
         dlg = SortOptionsDialog()
         if dlg.exec() == QDialog.DialogCode.Accepted:
             ascending, alnum, caseSensitive = dlg.getData()
@@ -8920,9 +8914,9 @@
         @return reference to the docstring generator
         @rtype BaseDocstringGenerator
         """
+        from . import DocstringGenerator
+
         if self.__docstringGenerator is None:
-            from . import DocstringGenerator
-
             self.__docstringGenerator = DocstringGenerator.getDocstringGenerator(self)
 
         return self.__docstringGenerator
@@ -8983,7 +8977,7 @@
 
         generator = self.getDocstringGenerator()
         if generator.hasFunctionDefinition(cursorPosition):
-            from .DocstringGenerator.BaseDocstringGenerator import (
+            from .DocstringGenerator.BaseDocstringGenerator import (  # __IGNORE_WARNING__
                 DocstringMenuForEnterOnly,
             )
 

eric ide

mercurial