Sat, 24 Apr 2021 10:56:08 +0200
- applied some code simplifications
- dropped support for some obsolete eric6 versions
--- a/AssistantEric/APIsManager.py Tue Apr 13 17:39:32 2021 +0200 +++ b/AssistantEric/APIsManager.py Sat Apr 24 10:56:08 2021 +0200 @@ -7,18 +7,14 @@ Module implementing the APIsManager. """ -from __future__ import unicode_literals - +import contextlib import os from PyQt5.QtCore import ( QTimer, QThread, QFileInfo, pyqtSignal, QDateTime, QObject, Qt ) -try: +with contextlib.suppress(ImportError): from PyQt5.QtSql import QSqlDatabase, QSqlQuery -except ImportError: - # just ignore it because the main plug-in file will deal with it - pass from E5Gui.E5Application import e5App @@ -166,11 +162,12 @@ query.prepare(self.file_loaded_stmt) query.bindValue(":file", apiFile) query.exec() - if query.next() and query.isValid(): # __IGNORE_WARNING_M513__ - loadTime = QDateTime.fromString( - query.value(0), Qt.DateFormat.ISODate) - else: - loadTime = QDateTime(1970, 1, 1, 0, 0) + loadTime = ( + QDateTime.fromString(query.value(0), Qt.DateFormat.ISODate) + if query.next() and query.isValid() else + # __IGNORE_WARNING_M513__ + QDateTime(1970, 1, 1, 0, 0) + ) query.finish() del query finally: @@ -228,7 +225,7 @@ bases = [] if self.__language == ApisNameProject: - try: + with contextlib.suppress(OSError, ImportError): module = Utilities.ModuleParser.readModule( os.path.join(self.__projectPath, apiFile), basename=self.__projectPath + os.sep, @@ -249,22 +246,16 @@ bases.append("{0} {1}\n".format( baseEntry, " ".join( sorted(basesDict[baseEntry])))) - except (OSError, ImportError): - pass else: - try: + with contextlib.suppress(OSError, UnicodeError): apis = Utilities.readEncodedFile(apiFile)[0].splitlines(True) - except (OSError, UnicodeError): - pass - try: + with contextlib.suppress(OSError, UnicodeError): basesFile = os.path.splitext(apiFile)[0] + ".bas" if os.path.exists(basesFile): bases = ( Utilities.readEncodedFile(basesFile)[0] .splitlines(True) ) - except (OSError, UnicodeError): - pass language = None if len(apis) > 0: @@ -384,10 +375,8 @@ index = len(path) fullContext = path context = path - try: + with contextlib.suppress(ValueError): acWord, pictureId = acWord.split("?", 1) - except ValueError: - pass else: context = path[index:] break @@ -1055,11 +1044,7 @@ return [] formsSources = [] - try: - forms = self.__project.getProjectFiles("FORMS") - except AttributeError: - # backward compatibility < 16.12 - forms = self.__project.pdata["FORMS"] + forms = self.__project.getProjectFiles("FORMS") for fn in forms: ofn = os.path.splitext(fn)[0] dirname, filename = os.path.split(ofn) @@ -1268,7 +1253,7 @@ return self.__apis[(language, projectType)] except KeyError: if ( - language in self.__supportedApiLanguages() or + language in QScintilla.Lexers.getSupportedApiLanguages() or language == ApisNameProject ): # create the api object @@ -1279,24 +1264,6 @@ else: return None - def __supportedApiLanguages(self): - """ - Private method to build a list of supported API languages. - - Note: This is a compatibility method to make this code work with - older eric versions. - - @return list of supported API languages - @rtype list of str - """ - try: - return QScintilla.Lexers.getSupportedApiLanguages() - except AttributeError: - # backward compatibility < 16.12 - return [lang for lang in - QScintilla.Lexers.getSupportedLanguages().keys() - if lang != "Guessed" and not lang.startswith("Pygments|")] - def deactivate(self): """ Public method to perform actions upon deactivation.
--- a/AssistantEric/Assistant.py Tue Apr 13 17:39:32 2021 +0200 +++ b/AssistantEric/Assistant.py Sat Apr 24 10:56:08 2021 +0200 @@ -8,8 +8,6 @@ calltips system. """ -from __future__ import unicode_literals - import re import imp @@ -118,11 +116,7 @@ self.__editors.append(editor) # preload the api to give the manager a chance to prepare the database - try: - language = editor.getApiLanguage() - except AttributeError: - # backward compatibility < 16.12 - language = editor.apiLanguage + language = editor.getApiLanguage() if language: projectType = self.__getProjectType(editor) self.__apisManager.getAPIs(language, projectType=projectType) @@ -158,14 +152,13 @@ @rtype str """ filename = editor.getFileName() - if ( - self.__project.isOpen() and - filename and - self.__project.isProjectFile(filename) - ): - projectType = self.__project.getProjectType() - else: - projectType = "" + projectType = ( + self.__project.getProjectType() + if (self.__project.isOpen() and + filename and + self.__project.isProjectFile(filename)) else + "" + ) return projectType @@ -217,12 +210,7 @@ @param context flag indicating to autocomplete a context (boolean) @return list of possible completions (list of strings) """ - try: - language = editor.getApiLanguage() - except AttributeError: - # backward compatibility < 16.12 - language = editor.apiLanguage - + language = editor.getApiLanguage() completeFromDocumentOnly = False if language in ["", "Guessed"] or language.startswith("Pygments|"): if ( @@ -284,15 +272,13 @@ prefix = "" mod = None - if context: - beg = beg[:col + 1] - else: - beg = editor.text(line)[:col] + beg = beg[:col + 1] if context else editor.text(line)[:col] col = len(beg) - if language: - wseps = editor.getLexer().autoCompletionWordSeparators() - else: - wseps = [] + wseps = ( + editor.getLexer().autoCompletionWordSeparators() + if language else + [] + ) if wseps: wseps.append(" ") if col > 0 and beg[col - 1] in wseps: @@ -718,12 +704,7 @@ (integer) @return list of possible calltips (list of strings) """ - try: - language = editor.getApiLanguage() - except AttributeError: - # backward compatibility < 16.12 - language = editor.apiLanguage - + language = editor.getApiLanguage() completeFromDocumentOnly = False if language in ["", "Guessed"] or language.startswith("Pygments|"): if ( @@ -748,10 +729,11 @@ mod = None beg = editor.text(line)[:col] col = len(beg) - if language: - wseps = editor.getLexer().autoCompletionWordSeparators() - else: - wseps = [] + wseps = ( + editor.getLexer().autoCompletionWordSeparators() + if language else + [] + ) if wseps: if col > 0 and beg[col - 1] in wseps: col -= 1
--- a/AssistantEric/ConfigurationPages/AutoCompletionEricPage.py Tue Apr 13 17:39:32 2021 +0200 +++ b/AssistantEric/ConfigurationPages/AutoCompletionEricPage.py Sat Apr 24 10:56:08 2021 +0200 @@ -7,8 +7,6 @@ Module implementing the Eric Autocompletion configuration page. """ -from __future__ import unicode_literals - from AssistantEric.Assistant import AcsAPIs, AcsDocument, AcsProject from Preferences.ConfigurationPages.ConfigurationPageBase import (
--- a/AssistantEric/ConfigurationPages/CallTipsEricPage.py Tue Apr 13 17:39:32 2021 +0200 +++ b/AssistantEric/ConfigurationPages/CallTipsEricPage.py Sat Apr 24 10:56:08 2021 +0200 @@ -7,8 +7,6 @@ Module implementing the Eric Calltips configuration page. """ -from __future__ import unicode_literals - from Preferences.ConfigurationPages.ConfigurationPageBase import ( ConfigurationPageBase )
--- a/AssistantEric/Documentation/source/Plugin_Assistant_Eric.AssistantEric.APIsManager.html Tue Apr 13 17:39:32 2021 +0200 +++ b/AssistantEric/Documentation/source/Plugin_Assistant_Eric.AssistantEric.APIsManager.html Sat Apr 24 10:56:08 2021 +0200 @@ -90,10 +90,6 @@ <td>Private message to show a message in the main windows status bar.</td> </tr> <tr> -<td><a href="#APIsManager.__supportedApiLanguages">__supportedApiLanguages</a></td> -<td>Private method to build a list of supported API languages.</td> -</tr> -<tr> <td><a href="#APIsManager.deactivate">deactivate</a></td> <td>Public method to perform actions upon deactivation.</td> </tr> @@ -166,29 +162,6 @@ message to be shown (string) </dd> </dl> -<a NAME="APIsManager.__supportedApiLanguages" ID="APIsManager.__supportedApiLanguages"></a> -<h4>APIsManager.__supportedApiLanguages</h4> -<b>__supportedApiLanguages</b>(<i></i>) - -<p> - Private method to build a list of supported API languages. -</p> -<p> - Note: This is a compatibility method to make this code work with - older eric versions. -</p> -<dl> -<dt>Returns:</dt> -<dd> -list of supported API languages -</dd> -</dl> -<dl> -<dt>Return Type:</dt> -<dd> -list of str -</dd> -</dl> <a NAME="APIsManager.deactivate" ID="APIsManager.deactivate"></a> <h4>APIsManager.deactivate</h4> <b>deactivate</b>(<i></i>) @@ -220,7 +193,7 @@ </dd> </dl> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> reference to the APIs object </dd> @@ -424,7 +397,7 @@ </dd> </dl> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> flag indicating, that there are enough commas (boolean) </dd> @@ -445,7 +418,7 @@ </dd> </dl> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> list of project form sources (list of strings) </dd> @@ -472,7 +445,7 @@ Private method to check, if the database has been prepared. </p> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> flag indicating the prepared status (boolean) </dd> @@ -492,7 +465,7 @@ Private method to open the API database. </p> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> flag indicating the database status (boolean) </dd> @@ -566,7 +539,7 @@ Protected method to determine the name of the database file. </p> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> name of the database file (string) </dd> @@ -579,7 +552,7 @@ Public method to get the word separator characters. </p> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> word separator characters (list of strings) </dd> @@ -613,7 +586,7 @@ Public method to get a list of API files loaded into the database. </p> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> list of API filenames (list of strings) </dd> @@ -656,7 +629,7 @@ </dd> </dl> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> list of calltips (list of string) </dd> @@ -687,7 +660,7 @@ </dd> </dl> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> list of dictionaries with possible completions (key 'completion' contains the completion (string), @@ -703,7 +676,7 @@ Public method to return a reference to our lexer object. </p> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> reference to the lexer object (QScintilla.Lexers.Lexer) </dd> @@ -861,7 +834,7 @@ </dd> </dl> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> word separator characters (list of strings) </dd> @@ -881,7 +854,7 @@ </dd> </dl> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> API information (list of strings) </dd> @@ -908,7 +881,7 @@ Private method to get a list of API files loaded into the database. </p> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> list of API filenames </dd>
--- a/AssistantEric/Documentation/source/Plugin_Assistant_Eric.AssistantEric.Assistant.html Tue Apr 13 17:39:32 2021 +0200 +++ b/AssistantEric/Documentation/source/Plugin_Assistant_Eric.AssistantEric.Assistant.html Sat Apr 24 10:56:08 2021 +0200 @@ -242,7 +242,7 @@ </dd> </dl> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> list of calltips (list of string) </dd> @@ -282,7 +282,7 @@ </dd> </dl> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> list of possible completions (list of strings) </dd> @@ -339,7 +339,7 @@ </dd> </dl> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> list of possible completions (list of strings) </dd> @@ -375,7 +375,7 @@ </dd> </dl> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> list of calltips (list of string) </dd> @@ -419,7 +419,7 @@ </dd> </dl> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> list of possible completions (list of strings) </dd> @@ -439,7 +439,7 @@ </dd> </dl> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> project type </dd> @@ -570,7 +570,7 @@ </dd> </dl> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> list of possible calltips (list of strings) </dd> @@ -602,7 +602,7 @@ </dd> </dl> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> list of possible completions (list of strings) </dd>
--- a/AssistantEric/Documentation/source/Plugin_Assistant_Eric.PluginAssistantEric.html Tue Apr 13 17:39:32 2021 +0200 +++ b/AssistantEric/Documentation/source/Plugin_Assistant_Eric.PluginAssistantEric.html Sat Apr 24 10:56:08 2021 +0200 @@ -145,7 +145,7 @@ Private method to perform some checks on QSql. </p> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> flag indicating QSql is ok (boolean) </dd> @@ -172,7 +172,7 @@ Public method to activate this plugin. </p> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> tuple of None and activation status (boolean) </dd> @@ -199,7 +199,7 @@ </dd> </dl> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> the requested refactoring setting </dd> @@ -240,7 +240,7 @@ </dd> </dl> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> reference to the configuration page </dd> @@ -263,7 +263,7 @@ </dd> </dl> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> reference to the configuration page </dd> @@ -279,7 +279,7 @@ Module function returning data as required by the configuration dialog. </p> <dl> -<dt>Returns:</dt> +<dt>Return:</dt> <dd> dictionary containing the relevant data </dd>
--- a/ChangeLog Tue Apr 13 17:39:32 2021 +0200 +++ b/ChangeLog Sat Apr 24 10:56:08 2021 +0200 @@ -1,5 +1,9 @@ ChangeLog --------- +Version 5.3.0: +- applied some code simplifications +- dropped support for some obsolete eric6 versions + Version 5.2.1: - bug fixes
--- a/PluginAssistantEric.py Tue Apr 13 17:39:32 2021 +0200 +++ b/PluginAssistantEric.py Sat Apr 24 10:56:08 2021 +0200 @@ -7,8 +7,6 @@ Module implementing the Eric assistant plugin. """ -from __future__ import unicode_literals - import os from PyQt5.QtCore import QObject, QTranslator, QCoreApplication @@ -24,7 +22,7 @@ author = "Detlev Offenbach <detlev@die-offenbachs.de>" autoactivate = True deactivateable = True -version = "5.2.1" +version = "5.3.0" className = "AssistantEricPlugin" packageName = "AssistantEric" shortDescription = "Alternative autocompletion and calltips provider." @@ -82,10 +80,7 @@ palette = e5App().palette() lightness = palette.color(QPalette.ColorRole.Window).lightness() usesDarkPalette = lightness <= 128 - if usesDarkPalette: - iconSuffix = "dark" - else: - iconSuffix = "light" + iconSuffix = "dark" if usesDarkPalette else "light" return { "ericAutoCompletionPage": [
--- a/PluginEricAssistant.epj Tue Apr 13 17:39:32 2021 +0200 +++ b/PluginEricAssistant.epj Sat Apr 24 10:56:08 2021 +0200 @@ -8,8 +8,21 @@ "CHECKERSPARMS": { "Pep8Checker": { "AnnotationsChecker": { + "AllowUntypedDefs": false, + "AllowUntypedNested": false, + "DispatchDecorators": [ + "singledispatch", + "singledispatchmethod" + ], "MaximumComplexity": 3, - "MinimumCoverage": 75 + "MaximumLength": 7, + "MinimumCoverage": 75, + "MypyInitReturn": false, + "OverloadDecorators": [ + "overload" + ], + "SuppressDummyArgs": false, + "SuppressNoneReturning": false }, "BlankLines": [ 2, @@ -27,20 +40,35 @@ ] }, "CommentedCodeChecker": { - "Aggressive": false + "Aggressive": false, + "WhiteList": [ + "pylint", + "pyright", + "noqa", + "type:\\s*ignore", + "fmt:\\s*(on|off)", + "TODO", + "FIXME", + "WARNING", + "NOTE", + "TEST", + "DOCU", + "XXX", + "- " + ] }, "CopyrightAuthor": "", "CopyrightMinFileSize": 0, "DocstringType": "eric", - "EnabledCheckerCategories": "C, D, E, M, N, S, W", - "ExcludeFiles": "*/Ui_*.py, */*_rc.py,", - "ExcludeMessages": "C101,E265,E266,E305,E402,M811,N802,N803,N807,N808,N821,W293,M201,W504", + "EnabledCheckerCategories": "C, D, E, M, N, Y, W", + "ExcludeFiles": "*/Ui_*.py, */*_rc.py", + "ExcludeMessages": "C101,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,W504,Y401,Y402", "FixCodes": "", "FixIssues": false, - "FutureChecker": "unicode_literals", + "FutureChecker": "", "HangClosing": false, "IncludeMessages": "", - "LineComplexity": 20, + "LineComplexity": 25, "LineComplexityScore": 10, "MaxCodeComplexity": 10, "MaxDocLineLength": 79, @@ -134,7 +162,7 @@ "MakeTarget": "", "MakeTestOnly": true }, - "MIXEDLANGUAGE": false, + "MIXEDLANGUAGE": 0, "OTHERS": [ ".hgignore", "AssistantEric/ConfigurationPages/eric-dark.svg", @@ -144,8 +172,7 @@ "ChangeLog", "PKGLIST", "PluginAssistantEric.zip", - "PluginEricAssistant.e4p", - "PluginEricAssistant.epj" + "PluginEricAssistant.e4p" ], "OTHERTOOLSPARMS": {}, "PACKAGERSPARMS": {},