Reformatted source code with 'Black'. eric7

Wed, 21 Sep 2022 10:52:53 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 21 Sep 2022 10:52:53 +0200
branch
eric7
changeset 63
3f3062df2e91
parent 62
9edcff55904f
child 64
023600ebd385

Reformatted source code with 'Black'.

.hgignore file | annotate | diff | comparison | revisions
PluginPySide2PyQt.py file | annotate | diff | comparison | revisions
PySide2PyQt.epj file | annotate | diff | comparison | revisions
--- a/.hgignore	Thu Dec 30 12:55:51 2021 +0100
+++ b/.hgignore	Wed Sep 21 10:52:53 2022 +0200
@@ -1,6 +1,7 @@
 glob:.eric7project
 glob:.eric6project
 glob:.ropeproject
+glob:.jedi
 glob:.directory
 glob:**.pyc
 glob:**.pyo
--- a/PluginPySide2PyQt.py	Thu Dec 30 12:55:51 2021 +0100
+++ b/PluginPySide2PyQt.py	Wed Sep 21 10:52:53 2022 +0200
@@ -40,36 +40,37 @@
     """
     Class implementing the PySide to PyQt (and vice versa) plugin.
     """
+
     def __init__(self, ui):
         """
         Constructor
-        
+
         @param ui reference to the user interface object
         @type UserInterface
         """
         super().__init__(ui)
         self.__ui = ui
-        
+
         self.__translator = None
         self.__loadTranslator()
-        
+
         self.__initMenu()
-        
+
         self.__editors = {}
         self.__mainActions = []
-    
+
     def activate(self):
         """
         Public method to activate this plugin.
-        
+
         @return tuple of None and activation status
         @rtype (None, bool)
         """
         global error
-        error = ""     # clear previous error
-        
+        error = ""  # clear previous error
+
         self.__ui.showMenu.connect(self.__populateMenu)
-        
+
         menu = self.__ui.getMenu("plugin_tools")
         if menu is not None:
             if not menu.isEmpty():
@@ -77,23 +78,21 @@
                 self.__mainActions.append(act)
             act = menu.addMenu(self.__menu)
             self.__mainActions.append(act)
-        
-        ericApp().getObject("ViewManager").editorOpenedEd.connect(
-            self.__editorOpened)
-        ericApp().getObject("ViewManager").editorClosedEd.connect(
-            self.__editorClosed)
-        
+
+        ericApp().getObject("ViewManager").editorOpenedEd.connect(self.__editorOpened)
+        ericApp().getObject("ViewManager").editorClosedEd.connect(self.__editorClosed)
+
         for editor in ericApp().getObject("ViewManager").getOpenEditors():
             self.__editorOpened(editor)
-        
+
         return None, True
-    
+
     def deactivate(self):
         """
         Public method to deactivate this plugin.
         """
         self.__ui.showMenu.disconnect(self.__populateMenu)
-        
+
         menu = self.__ui.getMenu("plugin_tools")
         if menu is not None:
             for act in self.__mainActions:
@@ -101,10 +100,12 @@
         self.__mainActions = []
 
         ericApp().getObject("ViewManager").editorOpenedEd.disconnect(
-            self.__editorOpened)
+            self.__editorOpened
+        )
         ericApp().getObject("ViewManager").editorClosedEd.disconnect(
-            self.__editorClosed)
-        
+            self.__editorClosed
+        )
+
         for editor, acts in self.__editors.items():
             editor.showMenu.disconnect(self.__editorShowMenu)
             menu = editor.getMenu("Tools")
@@ -112,7 +113,7 @@
                 for act in acts:
                     menu.removeAction(act)
         self.__editors = {}
-    
+
     def __loadTranslator(self):
         """
         Private method to load the translation file.
@@ -121,7 +122,8 @@
             loc = self.__ui.getLocale()
             if loc and loc != "C":
                 locale_dir = os.path.join(
-                    os.path.dirname(__file__), "PySide2PyQt", "i18n")
+                    os.path.dirname(__file__), "PySide2PyQt", "i18n"
+                )
                 translation = "pyside2pyqt_{0}".format(loc)
                 translator = QTranslator(None)
                 loaded = translator.load(translation, locale_dir)
@@ -129,30 +131,36 @@
                     self.__translator = translator
                     ericApp().installTranslator(self.__translator)
                 else:
-                    print("Warning: translation file '{0}' could not be"
-                          " loaded.".format(translation))
+                    print(
+                        "Warning: translation file '{0}' could not be"
+                        " loaded.".format(translation)
+                    )
                     print("Using default.")
-    
+
     def __initMenu(self):
         """
         Private method to initialize the menu.
         """
         self.__menu = QMenu(self.tr("PySide to/from PyQt"))
-        self.__menu.addAction(self.tr("PySide2 to PyQt5"),
-                              lambda: self.__pyside2Pyqt("pyside2", "pyqt5"))
-        self.__menu.addAction(self.tr("PyQt5 to PySide2"),
-                              lambda: self.__pyqt2Pyside("pyqt5", "pyside2"))
+        self.__menu.addAction(
+            self.tr("PySide2 to PyQt5"), lambda: self.__pyside2Pyqt("pyside2", "pyqt5")
+        )
+        self.__menu.addAction(
+            self.tr("PyQt5 to PySide2"), lambda: self.__pyqt2Pyside("pyqt5", "pyside2")
+        )
         self.__menu.addSeparator()
-        self.__menu.addAction(self.tr("PySide6 to PyQt6"),
-                              lambda: self.__pyside2Pyqt("pyside6", "pyqt6"))
-        self.__menu.addAction(self.tr("PyQt6 to PySide6"),
-                              lambda: self.__pyqt2Pyside("pyqt6", "pyside6"))
+        self.__menu.addAction(
+            self.tr("PySide6 to PyQt6"), lambda: self.__pyside2Pyqt("pyside6", "pyqt6")
+        )
+        self.__menu.addAction(
+            self.tr("PyQt6 to PySide6"), lambda: self.__pyqt2Pyside("pyqt6", "pyside6")
+        )
         self.__menu.setEnabled(False)
-    
+
     def __populateMenu(self, name, menu):
         """
         Private slot to populate the tools menu with our entries.
-        
+
         @param name name of the menu
         @type str
         @param menu reference to the menu to be populated
@@ -160,9 +168,9 @@
         """
         if name not in ["Tools", "PluginTools"]:
             return
-        
+
         editor = ericApp().getObject("ViewManager").activeWindow()
-        
+
         if name == "Tools":
             if not menu.isEmpty():
                 menu.addSeparator()
@@ -170,11 +178,11 @@
             act.setEnabled(editor is not None)
         elif name == "PluginTools" and self.__mainActions:
             self.__mainActions[-1].setEnabled(editor is not None)
-    
+
     def __editorOpened(self, editor):
         """
         Private slot called, when a new editor was opened.
-        
+
         @param editor reference to the new editor
         @type Editor
         """
@@ -188,11 +196,11 @@
             self.__editors[editor].append(act)
             self.__menu.setEnabled(True)
             editor.showMenu.connect(self.__editorShowMenu)
-    
+
     def __editorClosed(self, editor):
         """
         Private slot called, when an editor was closed.
-        
+
         @param editor reference to the editor
         @type Editor
         """
@@ -200,12 +208,12 @@
             del self.__editors[editor]
             if not self.__editors:
                 self.__menu.setEnabled(False)
-    
+
     def __editorShowMenu(self, menuName, menu, editor):
         """
         Private slot called, when the the editor context menu or a submenu is
         about to be shown.
-        
+
         @param menuName name of the menu to be shown
         @type str
         @param menu reference to the menu
@@ -213,10 +221,7 @@
         @param editor reference to the editor
         @type Editor
         """
-        if (
-            menuName == "Tools" and
-            self.__menu.menuAction() not in menu.actions()
-        ):
+        if menuName == "Tools" and self.__menu.menuAction() not in menu.actions():
             # Re-add our menu
             self.__editors[editor] = []
             if not menu.isEmpty():
@@ -224,12 +229,12 @@
                 self.__editors[editor].append(act)
             act = menu.addMenu(self.__menu)
             self.__editors[editor].append(act)
-    
+
     def __pyside2Pyqt(self, pyside, pyqt):
         """
         Private slot to convert the code of the current editor from PySide
         to PyQt.
-        
+
         @param pyside PySide variant (pyside2 or pyside6)
         @type str
         @param pyqt PyQt variant (pyqt5 or pyqt6)
@@ -238,12 +243,11 @@
         editor = ericApp().getObject("ViewManager").activeWindow()
         if editor is None:
             return
-        
+
         text = editor.text()
         if pyqt == "pyqt5" and pyside == "pyside2":
             newText = (
-                text
-                .replace("PySide2", "PyQt5")
+                text.replace("PySide2", "PyQt5")
                 .replace("Signal", "pyqtSignal")
                 .replace("Slot", "pyqtSlot")
                 .replace("Property", "pyqtProperty")
@@ -253,8 +257,7 @@
             )
         elif pyqt == "pyqt6" and pyside == "pyside6":
             newText = (
-                text
-                .replace("PySide6", "PyQt6")
+                text.replace("PySide6", "PyQt6")
                 .replace("Signal", "pyqtSignal")
                 .replace("Slot", "pyqtSlot")
                 .replace("Property", "pyqtProperty")
@@ -263,18 +266,18 @@
             )
         else:
             return
-        
+
         if newText != text:
             editor.beginUndoAction()
             editor.selectAll()
             editor.replaceSelectedText(newText)
             editor.endUndoAction()
-    
+
     def __pyqt2Pyside(self, pyqt, pyside):
         """
         Private slot to convert the code of the current editor from PyQt
         to PySide.
-        
+
         @param pyqt PyQt variant (pyqt5 or pyqt6)
         @type str
         @param pyside PySide variant (pyside2 or pyside6)
@@ -283,12 +286,11 @@
         editor = ericApp().getObject("ViewManager").activeWindow()
         if editor is None:
             return
-        
+
         text = editor.text()
         if pyqt == "pyqt5" and pyside == "pyside2":
             newText = (
-                text
-                .replace("PyQt5", "PySide2")
+                text.replace("PyQt5", "PySide2")
                 .replace("pyqtSignal", "Signal")
                 .replace("pyqtSlot", "Slot")
                 .replace("pyqtProperty", "Property")
@@ -298,8 +300,7 @@
             )
         elif pyqt == "pyqt6" and pyside == "pyside6":
             newText = (
-                text
-                .replace("PyQt6", "PySide6")
+                text.replace("PyQt6", "PySide6")
                 .replace("pyqtSignal", "Signal")
                 .replace("pyqtSlot", "Slot")
                 .replace("pyqtProperty", "Property")
@@ -308,12 +309,13 @@
             )
         else:
             return
-        
+
         if newText != text:
             editor.beginUndoAction()
             editor.selectAll()
             editor.replaceSelectedText(newText)
             editor.endUndoAction()
 
+
 #
 # eflag: noqa = M801
--- a/PySide2PyQt.epj	Thu Dec 30 12:55:51 2021 +0100
+++ b/PySide2PyQt.epj	Wed Sep 21 10:52:53 2022 +0200
@@ -1,19 +1,21 @@
 {
   "header": {
     "comment": "eric project file for project PySide2PyQt",
-    "copyright": "Copyright (C) 2021 Detlev Offenbach, detlev@die-offenbachs.de"
+    "copyright": "Copyright (C) 2022 Detlev Offenbach, detlev@die-offenbachs.de"
   },
   "project": {
     "AUTHOR": "Detlev Offenbach",
     "CHECKERSPARMS": {
       "Pep8Checker": {
         "AnnotationsChecker": {
+          "AllowStarArgAny": false,
           "AllowUntypedDefs": false,
           "AllowUntypedNested": false,
           "DispatchDecorators": [
             "singledispatch",
             "singledispatchmethod"
           ],
+          "ForceFutureAnnotations": false,
           "MaximumComplexity": 3,
           "MaximumLength": 7,
           "MinimumCoverage": 75,
@@ -59,20 +61,25 @@
         },
         "CopyrightAuthor": "",
         "CopyrightMinFileSize": 0,
-        "DocstringType": "eric",
+        "DocstringType": "eric_black",
         "EnabledCheckerCategories": "C, D, E, M, N, S, 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,Y119,Y401,Y402",
+        "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,W503,Y119,Y401,Y402",
         "FixCodes": "",
         "FixIssues": false,
         "FutureChecker": "",
         "HangClosing": false,
+        "ImportsChecker": {
+          "ApplicationPackageNames": [],
+          "BanRelativeImports": "",
+          "BannedModules": []
+        },
         "IncludeMessages": "",
         "LineComplexity": 25,
         "LineComplexityScore": 10,
         "MaxCodeComplexity": 10,
-        "MaxDocLineLength": 79,
-        "MaxLineLength": 79,
+        "MaxDocLineLength": 88,
+        "MaxLineLength": 88,
         "NoFixCodes": "E501",
         "RepeatMessages": true,
         "SecurityChecker": {
@@ -130,6 +137,7 @@
       }
     },
     "EMAIL": "detlev@die-offenbachs.de",
+    "EMBEDDED_VENV": false,
     "EOL": 1,
     "FILETYPES": {
       "*.epj": "OTHERS",
@@ -161,6 +169,7 @@
     },
     "INTERFACES": [],
     "LEXERASSOCS": {},
+    "LICENSE": "GNU General Public License v3 or later (GPLv3+)",
     "MAINSCRIPT": "PluginPySide2PyQt.py",
     "MAKEPARAMS": {
       "MakeEnabled": false,
@@ -176,11 +185,28 @@
       "ChangeLog",
       "PKGLIST",
       "PluginPySide2PyQt.zip",
+      "PySide2PyQt.epj",
       "PySide2PyQt/Documentation/LICENSE.GPL3",
-      "PySide2PyQt/Documentation/source",
-      "PySide2PyQt.epj"
+      "PySide2PyQt/Documentation/source"
     ],
-    "OTHERTOOLSPARMS": {},
+    "OTHERTOOLSPARMS": {
+      "Black": {
+        "exclude": "/(\\.direnv|\\.eggs|\\.git|\\.hg|\\.mypy_cache|\\.nox|\\.tox|\\.venv|venv|\\.svn|_build|buck-out|build|dist|__pypackages__)/",
+        "extend-exclude": "",
+        "force-exclude": "",
+        "line-length": 88,
+        "skip-magic-trailing-comma": false,
+        "skip-string-normalization": false,
+        "source": "project",
+        "target-version": [
+          "py311",
+          "py310",
+          "py39",
+          "py38",
+          "py37"
+        ]
+      }
+    },
     "PACKAGERSPARMS": {},
     "PROGLANGUAGE": "Python3",
     "PROJECTTYPE": "E7Plugin",
@@ -201,6 +227,7 @@
     "SPELLEXCLUDES": "",
     "SPELLLANGUAGE": "en_US",
     "SPELLWORDS": "",
+    "TESTING_FRAMEWORK": "",
     "TRANSLATIONEXCEPTIONS": [],
     "TRANSLATIONPATTERN": "PySide2PyQt/i18n/pyside2pyqt_%language%.ts",
     "TRANSLATIONS": [

eric ide

mercurial