From 0575f89ae9bea09dbb4f69d1f418ab437794af6b Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Fri, 25 Jun 2021 23:20:15 +0200 Subject: [PATCH] Remove alignments in arguments for format statements --- CONTRIBUTING.md | 5 +--- nw/__init__.py | 6 ++--- nw/core/project.py | 6 ++--- nw/core/tohtml.py | 6 ++--- nw/core/toodt.py | 6 ++--- nw/dialogs/about.py | 24 ++++++++--------- nw/dialogs/preferences.py | 10 +++---- nw/error.py | 22 +++++++-------- nw/gui/docviewer.py | 42 ++++++++++++++--------------- setup.cfg | 2 +- tests/test_core/test_core_tohtml.py | 4 +-- 11 files changed, 65 insertions(+), 68 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b594dc14..9e89ca84 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -98,7 +98,7 @@ Some `flake8` error codes are ignored for this project for various reasons. The camelCase function and variable names. This is the standard for the Qt libraries novelWriter integrates with. It also happens to be the author's personal preferences. (Yay!) -The reason behind the other ignored error codes are listed below. Most of them are due to PEP8 not +The reason behind the other ignored error codes are listed below. Two of them are due to PEP8 not permitting column alignment as opposed to many other coding styles, like for instance for Go. I find them useful in regions of bulk value assignments. There's a reason why tables are more readable than lists. They should be used sparingly though. @@ -122,6 +122,3 @@ strings. Use formatting instead. **E241:** multiple spaces after ‘,’ **Reason:** Column alignment. - -**E251:** unexpected spaces around keyword / parameter equals -**Reason:** Column alignment. diff --git a/nw/__init__.py b/nw/__init__.py index cc126822..937a675b 100644 --- a/nw/__init__.py +++ b/nw/__init__.py @@ -149,9 +149,9 @@ def main(sysArgs=None): " --config= Alternative config file.\n" " --data= Alternative user data path.\n" ).format( - version = __version__, - copyright = __copyright__, - date = __date__, + version=__version__, + copyright=__copyright__, + date=__date__, ) # Defaults diff --git a/nw/core/project.py b/nw/core/project.py index c5a1d4bb..f2abd0dd 100644 --- a/nw/core/project.py +++ b/nw/core/project.py @@ -677,9 +677,9 @@ class NWProject(): with open(tempFile, mode="wb") as outFile: outFile.write(etree.tostring( nwXML, - pretty_print = True, - encoding = "utf-8", - xml_declaration = True + pretty_print=True, + encoding="utf-8", + xml_declaration=True )) except Exception as e: self.makeAlert([ diff --git a/nw/core/tohtml.py b/nw/core/tohtml.py index 3837d020..d4a7b13c 100644 --- a/nw/core/tohtml.py +++ b/nw/core/tohtml.py @@ -291,9 +291,9 @@ class ToHtml(Tokenizer): "\n" "\n" ).format( - projTitle = self.theProject.projName, - htmlStyle = "\n".join(theStyle), - bodyText = bodyText, + projTitle=self.theProject.projName, + htmlStyle="\n".join(theStyle), + bodyText=bodyText, ) outFile.write(theHtml) diff --git a/nw/core/toodt.py b/nw/core/toodt.py index d097ca16..ba508f24 100644 --- a/nw/core/toodt.py +++ b/nw/core/toodt.py @@ -450,9 +450,9 @@ class ToOdt(Tokenizer): with open(savePath, mode="wb") as outFile: outFile.write(etree.tostring( self._dFlat, - pretty_print = True, - encoding = "utf-8", - xml_declaration = True + pretty_print=True, + encoding="utf-8", + xml_declaration=True )) return diff --git a/nw/dialogs/about.py b/nw/dialogs/about.py index 28ed76d7..736ab969 100644 --- a/nw/dialogs/about.py +++ b/nw/dialogs/about.py @@ -142,31 +142,31 @@ class GuiAbout(QDialog): "

{title2}

" "

{credits}

" ).format( - title1 = self.tr("About novelWriter"), - copy = nw.__copyright__, - link = self.tr("Website: {0}").format(f"{nw.__domain__}"), - title2 = self.tr("Credits"), - credits = self._wrapTable([ + title1=self.tr("About novelWriter"), + copy=nw.__copyright__, + link=self.tr("Website: {0}").format(f"{nw.__domain__}"), + title2=self.tr("Credits"), + credits=self._wrapTable([ (self.tr("Developer"), "Veronica Berglyd Olsen"), (self.tr("Concept"), "Veronica Berglyd Olsen, Marian Lückhof"), (self.tr("i18n"), "Bruno Meneguello"), ]), - intro = self.tr( + intro=self.tr( "novelWriter is a markdown-like text editor designed for organising and " "writing novels. It is written in Python 3 with a Qt5 GUI, using PyQt5." ), - license1 = self.tr( + license1=self.tr( "novelWriter is free software: you can redistribute it and/or modify it " "under the terms of the GNU General Public License as published by the " "Free Software Foundation, either version 3 of the License, or (at your " "option) any later version." ), - license2 = self.tr( + license2=self.tr( "novelWriter is distributed in the hope that it will be useful, but " "WITHOUT ANY WARRANTY; without even the implied warranty of " "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." ), - license3 = self.tr( + license3=self.tr( "See the Licence tab for the full licence text, or visit the " "GNU website at {0} for more details." ).format( @@ -271,9 +271,9 @@ class GuiAbout(QDialog): " padding-right: 0.8em;" "}}\n" ).format( - hColR = self.theParent.theTheme.colHead[0], - hColG = self.theParent.theTheme.colHead[1], - hColB = self.theParent.theTheme.colHead[2], + hColR=self.theParent.theTheme.colHead[0], + hColG=self.theParent.theTheme.colHead[1], + hColB=self.theParent.theTheme.colHead[2], ) self.pageAbout.document().setDefaultStyleSheet(styleSheet) self.pageNotes.document().setDefaultStyleSheet(styleSheet) diff --git a/nw/dialogs/preferences.py b/nw/dialogs/preferences.py index 1b2f162c..e68cd158 100644 --- a/nw/dialogs/preferences.py +++ b/nw/dialogs/preferences.py @@ -223,7 +223,7 @@ class GuiPreferencesGeneral(QWidget): self.tr("Font family"), self.guiFont, self.tr("Changing this requires restarting novelWriter."), - theButton = self.fontButton + theButton=self.fontButton ) # Font Size @@ -236,7 +236,7 @@ class GuiPreferencesGeneral(QWidget): self.tr("Font size"), self.guiFontSize, self.tr("Changing this requires restarting novelWriter."), - theUnit = self.tr("pt") + theUnit=self.tr("pt") ) # GUI Settings @@ -512,7 +512,7 @@ class GuiPreferencesDocuments(QWidget): self.tr("Font family"), self.textFont, self.tr("Font for the document editor and viewer."), - theButton = self.fontButton + theButton=self.fontButton ) # Font Size @@ -525,7 +525,7 @@ class GuiPreferencesDocuments(QWidget): self.tr("Font size"), self.textSize, self.tr("Font size for the document editor and viewer."), - theUnit = self.tr("pt") + theUnit=self.tr("pt") ) # Text Flow @@ -788,7 +788,7 @@ class GuiPreferencesEditor(QWidget): self.tr("Minimum position for Typewriter scrolling"), self.autoScrollPos, self.tr("Percentage of the editor height from the top."), - theUnit = "%" + theUnit="%" ) return diff --git a/nw/error.py b/nw/error.py index 74a7c8ea..fee52ab7 100644 --- a/nw/error.py +++ b/nw/error.py @@ -104,7 +104,7 @@ class NWErrorMessage(QDialog): "message and traceback shown below.

" "

URL: {issueUrl}

" ).format( - issueUrl = __issuesurl__, + issueUrl=__issuesurl__, )) try: @@ -124,16 +124,16 @@ class NWErrorMessage(QDialog): "\n" "Traceback:\n{exTrace}\n" ).format( - nwVersion = __version__, - osType = sys.platform, - osKernel = kernelVersion, - pyVersion = sys.version.split()[0], - pyHexVer = sys.hexversion, - qtVers = QT_VERSION_STR, - pyqtVers = PYQT_VERSION_STR, - exType = exType.__name__, - exMessage = str(exValue), - exTrace = "\n".join(format_tb(exTrace)), + nwVersion=__version__, + osType=sys.platform, + osKernel=kernelVersion, + pyVersion=sys.version.split()[0], + pyHexVer=sys.hexversion, + qtVers=QT_VERSION_STR, + pyqtVers=PYQT_VERSION_STR, + exType=exType.__name__, + exMessage=str(exValue), + exTrace="\n".join(format_tb(exTrace)), )) except Exception: self.msgBody.setPlainText("Failed to generate error report ...") diff --git a/nw/gui/docviewer.py b/nw/gui/docviewer.py index 2a82816f..f82e98f8 100644 --- a/nw/gui/docviewer.py +++ b/nw/gui/docviewer.py @@ -543,27 +543,27 @@ class GuiDocViewer(QTextBrowser): " color: rgb({mColR}, {mColG}, {mColB});" "}}\n" ).format( - tColR = self.theTheme.colText[0], - tColG = self.theTheme.colText[1], - tColB = self.theTheme.colText[2], - hColR = self.theTheme.colHead[0], - hColG = self.theTheme.colHead[1], - hColB = self.theTheme.colHead[2], - aColR = self.theTheme.colVal[0], - aColG = self.theTheme.colVal[1], - aColB = self.theTheme.colVal[2], - eColR = self.theTheme.colEmph[0], - eColG = self.theTheme.colEmph[1], - eColB = self.theTheme.colEmph[2], - kColR = self.theTheme.colKey[0], - kColG = self.theTheme.colKey[1], - kColB = self.theTheme.colKey[2], - cColR = self.theTheme.colHidden[0], - cColG = self.theTheme.colHidden[1], - cColB = self.theTheme.colHidden[2], - mColR = self.theTheme.colMod[0], - mColG = self.theTheme.colMod[1], - mColB = self.theTheme.colMod[2], + tColR=self.theTheme.colText[0], + tColG=self.theTheme.colText[1], + tColB=self.theTheme.colText[2], + hColR=self.theTheme.colHead[0], + hColG=self.theTheme.colHead[1], + hColB=self.theTheme.colHead[2], + aColR=self.theTheme.colVal[0], + aColG=self.theTheme.colVal[1], + aColB=self.theTheme.colVal[2], + eColR=self.theTheme.colEmph[0], + eColG=self.theTheme.colEmph[1], + eColB=self.theTheme.colEmph[2], + kColR=self.theTheme.colKey[0], + kColG=self.theTheme.colKey[1], + kColB=self.theTheme.colKey[2], + cColR=self.theTheme.colHidden[0], + cColG=self.theTheme.colHidden[1], + cColB=self.theTheme.colHidden[2], + mColR=self.theTheme.colMod[0], + mColG=self.theTheme.colMod[1], + mColB=self.theTheme.colMod[2], ) self._qDocument.setDefaultStyleSheet(styleSheet) diff --git a/setup.cfg b/setup.cfg index 3218fb90..248304da 100644 --- a/setup.cfg +++ b/setup.cfg @@ -49,6 +49,6 @@ gui_scripts = universal = 0 [flake8] -ignore = E221,E226,E228,E241,E251 +ignore = E221,E226,E228,E241 max-line-length = 99 exclude = docs/* diff --git a/tests/test_core/test_core_tohtml.py b/tests/test_core/test_core_tohtml.py index 947ed3f0..cff7798f 100644 --- a/tests/test_core/test_core_tohtml.py +++ b/tests/test_core/test_core_tohtml.py @@ -409,8 +409,8 @@ def testCoreToHtml_Complex(dummyGUI, fncDir): "\n" "\n" ).format( - htmlStyle = "\n".join(theStyle), - bodyText = "".join(resText).rstrip() + htmlStyle="\n".join(theStyle), + bodyText="".join(resText).rstrip() ) saveFile = os.path.join(fncDir, "outFile.htm")