Corrected some code style and formatting issues and prepared the code for Python 3.12. eric7 release-10.3.0

Wed, 30 Aug 2023 11:38:43 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Aug 2023 11:38:43 +0200
branch
eric7
changeset 206
0e83bc0cc7fd
parent 205
900e71dd7e81
child 207
e9742998c5d9

Corrected some code style and formatting issues and prepared the code for Python 3.12.

AssistantEric/APIsManager.py file | annotate | diff | comparison | revisions
AssistantEric/Assistant.py file | annotate | diff | comparison | revisions
AssistantEric/Documentation/source/Plugin_Assistant_Eric.AssistantEric.Assistant.html file | annotate | diff | comparison | revisions
AssistantEric/Documentation/source/Plugin_Assistant_Eric.PluginAssistantEric.html file | annotate | diff | comparison | revisions
ChangeLog file | annotate | diff | comparison | revisions
PluginAssistantEric.py file | annotate | diff | comparison | revisions
PluginAssistantEric.zip file | annotate | diff | comparison | revisions
PluginEricAssistant.epj file | annotate | diff | comparison | revisions
--- a/AssistantEric/APIsManager.py	Sun May 28 14:34:08 2023 +0200
+++ b/AssistantEric/APIsManager.py	Wed Aug 30 11:38:43 2023 +0200
@@ -16,8 +16,10 @@
     from PyQt6.QtSql import QSqlDatabase, QSqlQuery
 
 from eric7 import Globals, Preferences, Utilities
+from eric7.DocumentationTools.APIGenerator import APIGenerator
 from eric7.EricWidgets.EricApplication import ericApp
 from eric7.QScintilla import Lexers
+from eric7.QScintilla.Editor import Editor
 from eric7.Utilities import ModuleParser
 
 WorkerStatusStarted = 2001
@@ -213,8 +215,6 @@
             classNameStr = "{0}{1}.".format(moduleName, className)
             for variable in sorted(_class.attributes.keys()):
                 if not _class.attributes[variable].isPrivate():
-                    from eric7.QScintilla.Editor import Editor
-
                     if _class.attributes[variable].isPublic():
                         iconId = Editor.AttributeID
                     elif _class.attributes[variable].isProtected():
@@ -243,8 +243,6 @@
                 )
                 language = module.getType()
                 if language:
-                    from eric7.DocumentationTools.APIGenerator import APIGenerator
-
                     apiGenerator = APIGenerator(module)
                     try:
                         apis = apiGenerator.genAPI("", True)
--- a/AssistantEric/Assistant.py	Sun May 28 14:34:08 2023 +0200
+++ b/AssistantEric/Assistant.py	Wed Aug 30 11:38:43 2023 +0200
@@ -8,12 +8,13 @@
 calltips system.
 """
 
-import imp
 import re
 
 from PyQt6.QtCore import QObject
 
 from eric7.EricWidgets.EricApplication import ericApp
+from eric7.QScintilla.Editor import Editor
+from eric7.Utilities.ModuleParser import PY_SOURCE, Module
 
 from .APIsManager import APIsManager, ApisNameProject
 
@@ -50,8 +51,6 @@
         self.__lastContext = None
         self.__lastFullContext = None
 
-        from eric7.QScintilla.Editor import Editor
-
         self.__fromDocumentID = Editor.FromDocumentID
 
     def activate(self):
@@ -93,7 +92,11 @@
 
         self.__apisManager.deactivate()
 
-    def setEnabled(self, key, enabled):
+    def setEnabled(
+        self,
+        key,  # noqa: U100
+        enabled,  # noqa: U100
+    ):
         """
         Public method to enable or disable a feature.
 
@@ -241,8 +244,8 @@
         line, col = editor.getCursorPosition()
         sep = ""
         if language and context:
-            wc = re.sub("\w", "", editor.wordCharacters())
-            pat = re.compile("\w{0}".format(re.escape(wc)))
+            wc = re.sub(r"\w", "", editor.wordCharacters())
+            pat = re.compile(r"\w{0}".format(re.escape(wc)))
             text = editor.text(line)
 
             beg = text[:col]
@@ -298,13 +301,11 @@
                     col -= 1
             prefix = editor.getWordLeft(line, col)
             if editor.isPyFile():
-                from eric7.Utilities.ModuleParser import Module
-
                 src = editor.text()
                 fn = editor.getFileName()
                 if fn is None:
                     fn = ""
-                mod = Module("", fn, imp.PY_SOURCE)
+                mod = Module("", fn, PY_SOURCE)
                 mod.scan(src)
 
         importCompletion = False
@@ -534,7 +535,7 @@
                         entry += "?{0}".format(completion["pictureId"])
                     else:
                         cont = False
-                        regexp = re.compile(re.escape(entry) + "\?\d{,2}")
+                        regexp = re.compile(re.escape(entry) + r"\?\d{,2}")
                         for comp in completionsList:
                             if regexp.fullmatch(comp):
                                 cont = True
@@ -572,8 +573,6 @@
 
         prefixFound = False
         if prefix and module:
-            from eric7.QScintilla.Editor import Editor
-
             line, col = editor.getCursorPosition()
             if prefix in ["cls", "self"]:
                 prefixFound = True
@@ -804,8 +803,8 @@
         projectType = self.__getProjectType(editor)
 
         line, col = editor.lineIndexFromPosition(pos)
-        wc = re.sub("\w", "", editor.wordCharacters())
-        pat = re.compile("\w{0}".format(re.escape(wc)))
+        wc = re.sub(r"\w", "", editor.wordCharacters())
+        pat = re.compile(r"\w{0}".format(re.escape(wc)))
         text = editor.text(line)
         while col > 0 and not pat.match(text[col - 1]):
             col -= 1
@@ -826,13 +825,11 @@
                     col -= 1
             prefix = editor.getWordLeft(line, col)
             if editor.isPyFile():
-                from eric7.Utilities.ModuleParser import Module
-
                 src = editor.text()
                 fn = editor.getFileName()
                 if fn is None:
                     fn = ""
-                mod = Module("", fn, imp.PY_SOURCE)
+                mod = Module("", fn, PY_SOURCE)
                 mod.scan(src)
 
         apiCalltips = []
--- a/AssistantEric/Documentation/source/Plugin_Assistant_Eric.AssistantEric.Assistant.html	Sun May 28 14:34:08 2023 +0200
+++ b/AssistantEric/Documentation/source/Plugin_Assistant_Eric.AssistantEric.Assistant.html	Wed Aug 30 11:38:43 2023 +0200
@@ -633,7 +633,7 @@
 </dl>
 <a NAME="Assistant.setEnabled" ID="Assistant.setEnabled"></a>
 <h4>Assistant.setEnabled</h4>
-<b>setEnabled</b>(<i>key, enabled</i>)
+<b>setEnabled</b>(<i>key, enabled, </i>)
 
 <p>
         Public method to enable or disable a feature.
--- a/AssistantEric/Documentation/source/Plugin_Assistant_Eric.PluginAssistantEric.html	Sun May 28 14:34:08 2023 +0200
+++ b/AssistantEric/Documentation/source/Plugin_Assistant_Eric.PluginAssistantEric.html	Wed Aug 30 11:38:43 2023 +0200
@@ -231,7 +231,7 @@
 <hr />
 <a NAME="createAutoCompletionPage" ID="createAutoCompletionPage"></a>
 <h2>createAutoCompletionPage</h2>
-<b>createAutoCompletionPage</b>(<i>configDlg</i>)
+<b>createAutoCompletionPage</b>(<i>configDlg, </i>)
 
 <p>
     Module function to create the autocompletion configuration page.
@@ -260,7 +260,7 @@
 <hr />
 <a NAME="createCallTipsPage" ID="createCallTipsPage"></a>
 <h2>createCallTipsPage</h2>
-<b>createCallTipsPage</b>(<i>configDlg</i>)
+<b>createCallTipsPage</b>(<i>configDlg, </i>)
 
 <p>
     Module function to create the calltips configuration page.
--- a/ChangeLog	Sun May 28 14:34:08 2023 +0200
+++ b/ChangeLog	Wed Aug 30 11:38:43 2023 +0200
@@ -1,5 +1,9 @@
 ChangeLog
 ---------
+Version 10.3.0:
+- bug fixes
+- prepared code for Python 3.12
+
 Version 10.2.4:
 - bug fixes
 
--- a/PluginAssistantEric.py	Sun May 28 14:34:08 2023 +0200
+++ b/PluginAssistantEric.py	Wed Aug 30 11:38:43 2023 +0200
@@ -11,7 +11,7 @@
 
 from PyQt6.QtCore import QCoreApplication, QObject, QTranslator
 
-from AssistantEric.Assistant import AcsAPIs, AcsProject
+from AssistantEric.Assistant import AcsAPIs, AcsProject, Assistant
 from eric7 import Preferences
 from eric7.EricWidgets.EricApplication import ericApp
 
@@ -20,7 +20,7 @@
 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
 autoactivate = True
 deactivateable = True
-version = "10.2.4"
+version = "10.3.0"
 className = "AssistantEricPlugin"
 packageName = "AssistantEric"
 shortDescription = "Alternative autocompletion and calltips provider."
@@ -37,7 +37,9 @@
 assistantEricPluginObject = None
 
 
-def createAutoCompletionPage(configDlg):
+def createAutoCompletionPage(
+    configDlg,  # noqa: U100
+):
     """
     Module function to create the autocompletion configuration page.
 
@@ -47,14 +49,16 @@
     @rtype QWidget
     """
     global assistantEricPluginObject
-    from AssistantEric.ConfigurationPages.AutoCompletionEricPage import (
+    from AssistantEric.ConfigurationPages.AutoCompletionEricPage import (  # noqa: I101
         AutoCompletionEricPage,
     )
 
     return AutoCompletionEricPage(assistantEricPluginObject)
 
 
-def createCallTipsPage(configDlg):
+def createCallTipsPage(
+    configDlg,  # noqa: U100
+):
     """
     Module function to create the calltips configuration page.
 
@@ -64,7 +68,9 @@
     @rtype QWidget
     """
     global assistantEricPluginObject
-    from AssistantEric.ConfigurationPages.CallTipsEricPage import CallTipsEricPage
+    from AssistantEric.ConfigurationPages.CallTipsEricPage import (  # noqa: I101
+        CallTipsEricPage,
+    )
 
     return CallTipsEricPage(assistantEricPluginObject)
 
@@ -79,7 +85,7 @@
     try:
         usesDarkPalette = ericApp().usesDarkPalette()
     except AttributeError:
-        from PyQt6.QtGui import QPalette
+        from PyQt6.QtGui import QPalette  # noqa: I101, I102
 
         palette = ericApp().palette()
         lightness = palette.color(QPalette.ColorRole.Window).lightness()
@@ -161,7 +167,7 @@
         global error
 
         try:
-            from PyQt6.QtSql import QSqlDatabase
+            from PyQt6.QtSql import QSqlDatabase  # noqa: I101, I102
         except ImportError:
             error = self.tr("PyQt6.QtSql is not available.")
             return False
@@ -189,8 +195,6 @@
         global assistantEricPluginObject
         assistantEricPluginObject = self
 
-        from AssistantEric.Assistant import Assistant
-
         self.__object = Assistant(self, self.__ui)
         ericApp().registerPluginObject("AssistantEric", self.__object)
 
Binary file PluginAssistantEric.zip has changed
--- a/PluginEricAssistant.epj	Sun May 28 14:34:08 2023 +0200
+++ b/PluginEricAssistant.epj	Wed Aug 30 11:38:43 2023 +0200
@@ -11,10 +11,14 @@
           "AllowStarArgAny": false,
           "AllowUntypedDefs": false,
           "AllowUntypedNested": false,
+          "CheckFutureAnnotations": false,
           "DispatchDecorators": [
             "singledispatch",
             "singledispatchmethod"
           ],
+          "ExemptedTypingSymbols": [
+            ""
+          ],
           "ForceFutureAnnotations": false,
           "MaximumComplexity": 3,
           "MaximumLength": 7,
@@ -62,15 +66,18 @@
         "CopyrightAuthor": "",
         "CopyrightMinFileSize": 0,
         "DocstringType": "eric_black",
-        "EnabledCheckerCategories": "C, D, E, M, N, Y, W",
+        "EnabledCheckerCategories": "C, D, E, I, M, NO, N, Y, U, W",
         "ExcludeFiles": "*/Ui_*.py, */*_rc.py",
-        "ExcludeMessages": "C101,E203,E265,E266,E305,E402,M201,M301,M302,M303,M304,M305,M306,M307,M308,M311,M312,M313,M314,M315,M321,M701,M702,M811,M834,N802,N803,N807,N808,N821,W293,W503,Y401,Y402",
+        "ExcludeMessages": "C101,E203,E265,E266,E305,E402,M201,M301,M302,M303,M304,M305,M306,M307,M308,M311,M312,M313,M314,M315,M321,M701,M702,M811,M834,N802,N803,N807,N808,N821,U200,W293,W503,Y401,Y402",
         "FixCodes": "",
         "FixIssues": false,
         "FutureChecker": "",
         "HangClosing": false,
         "ImportsChecker": {
-          "ApplicationPackageNames": [],
+          "ApplicationPackageNames": [
+            "AssistantEric",
+            "eric7"
+          ],
           "BanRelativeImports": "",
           "BannedModules": []
         },
@@ -80,6 +87,17 @@
         "MaxCodeComplexity": 10,
         "MaxDocLineLength": 88,
         "MaxLineLength": 88,
+        "NameOrderChecker": {
+          "ApplicationPackageNames": [
+            "AssistantEric",
+            "eric7"
+          ],
+          "CombinedAsImports": true,
+          "SortCaseSensitive": false,
+          "SortFromFirst": false,
+          "SortIgnoringStyle": false,
+          "SortOrder": "natural"
+        },
         "NoFixCodes": "E501",
         "RepeatMessages": true,
         "SecurityChecker": {
@@ -113,6 +131,19 @@
           "WeakKeySizeRsaMedium": "2048"
         },
         "ShowIgnored": false,
+        "UnusedChecker": {
+          "IgnoreAbstract": true,
+          "IgnoreDunderGlobals": true,
+          "IgnoreDunderMethods": true,
+          "IgnoreEventHandlerMethods": true,
+          "IgnoreLambdas": false,
+          "IgnoreNestedFunctions": false,
+          "IgnoreOverload": true,
+          "IgnoreOverride": true,
+          "IgnoreSlotMethods": true,
+          "IgnoreStubs": true,
+          "IgnoreVariadicNames": false
+        },
         "ValidEncodings": "latin-1, utf-8"
       },
       "SyntaxChecker": {
@@ -201,7 +232,7 @@
     ],
     "OTHERTOOLSPARMS": {
       "Black": {
-        "exclude": "/(\\.direnv|\\.eggs|\\.git|\\.hg|\\.mypy_cache|\\.nox|\\.tox|\\.venv|venv|\\.svn|\\.ipynb_checkpoints|_build|buck-out|build|dist|__pypackages__)/",
+        "exclude": "/(\\.direnv|\\.eggs|\\.git|\\.hg|\\.ipynb_checkpoints|\\.mypy_cache|\\.nox|\\.pytest_cache|\\.ruff_cache|\\.tox|\\.svn|\\.venv|\\.vscode|__pypackages__|_build|buck-out|build|dist|venv)/",
         "extend-exclude": "",
         "force-exclude": "",
         "line-length": 88,
@@ -209,11 +240,11 @@
         "skip-string-normalization": false,
         "source": "project",
         "target-version": [
+          "py312",
           "py311",
           "py310",
           "py39",
-          "py38",
-          "py37"
+          "py38"
         ]
       },
       "isort": {
@@ -256,6 +287,7 @@
       "PluginAssistantEric.py",
       "__init__.py"
     ],
+    "SOURCESDIR": "",
     "SPELLEXCLUDES": "",
     "SPELLLANGUAGE": "en",
     "SPELLWORDS": "",

eric ide

mercurial