diff --git a/scripts/.pylintrc b/scripts/.pylintrc index 428a9e556e903ef115d06feb9b166d49c527b51c..66ddb84e4f2003e4193cb53eabd99d57a6106aed 100644 --- a/scripts/.pylintrc +++ b/scripts/.pylintrc @@ -60,6 +60,15 @@ confidence= # --enable=similarities". If you want to run only the classes checker, but have # no Warning level messages displayed, use "--disable=all --enable=classes # --disable=W". +# +# NOTE about C0330: +# Ignoring pylint's C0330 "Wrong hanging indentation before block" error +# here because it erronously reports indentation issues, and conflicts with +# the black tool. See this issue on the black gitHub +# page: https://github.com/psf/black/issues/48, and this issue on pylints +# GitHub page referenced by the first issue: +# https://github.com/PyCQA/pylint/issues/289 + disable=print-statement, parameter-unpacking, unpacking-in-except, @@ -142,7 +151,8 @@ disable=print-statement, E0611, I1101, E1101, - R0901 + R0901, + C0330 # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option diff --git a/soitool/codebook.py b/soitool/codebook.py index ef80ce72731baf21dbfac1f1caaa9cbf6d640203..bdc0725d0c7f989bbe780a2357b854e69dc8a3bf 100644 --- a/soitool/codebook.py +++ b/soitool/codebook.py @@ -10,8 +10,8 @@ from soitool.database import DBPATH # , Database from soitool.style import CODEBOOK_HEADER_FONT, CODEBOOK_HEADER_BACKGROUND_CSS # Name and type of database -CONNAME = 'SOIDB' -DBTYPE = 'QSQLITE' +CONNAME = "SOIDB" +DBTYPE = "QSQLITE" class CodeBookTableView(QTableView): @@ -30,7 +30,7 @@ class CodeBookTableView(QTableView): db.setDatabaseName(DBPATH) if not db.open(): - raise RuntimeError('Could not open database.') + raise RuntimeError("Could not open database.") # Enable sorting and sort by column 'Word' self.setSortingEnabled(True) @@ -101,7 +101,7 @@ class CodeBookTableModel(QSqlTableModel): def __init__(self): super().__init__(None, QSqlDatabase.database(CONNAME)) self.setEditStrategy(QSqlTableModel.OnFieldChange) - self.setTable('CodeBook') + self.setTable("CodeBook") self.setSort(0, Qt.AscendingOrder) self.select() @@ -142,10 +142,10 @@ class CodeBookTableModel(QSqlTableModel): # If a change is made to column 'Type' if index.column() == 2: # If correct string, replace with correctly cased str - if value.lower() == 'liten': - value = 'Liten' - elif value.lower() == 'stor': - value = 'Stor' + if value.lower() == "liten": + value = "Liten" + elif value.lower() == "stor": + value = "Stor" else: return False diff --git a/soitool/codebook_row_adder.py b/soitool/codebook_row_adder.py index 412a59b7aa44f3ddabed9d9826c3927572e10300..39cc45fe93d85ee91aa93011579d2a286321d274 100644 --- a/soitool/codebook_row_adder.py +++ b/soitool/codebook_row_adder.py @@ -1,7 +1,14 @@ """Includes functionality for inserting rows into database-table CodeBook.""" from sqlite3 import IntegrityError -from PySide2.QtWidgets import QHBoxLayout, QVBoxLayout, QLabel, \ - QLineEdit, QComboBox, QPushButton, QWidget +from PySide2.QtWidgets import ( + QHBoxLayout, + QVBoxLayout, + QLabel, + QLineEdit, + QComboBox, + QPushButton, + QWidget, +) from PySide2.QtCore import Qt from soitool.database import Database from soitool.codebook import CodeBookTableView, CodeBookTableModel @@ -34,10 +41,13 @@ class CodebookRowAdder(QWidget): super().__init__() # Raise error if argument is invalid - if codebook_view is not None and \ - not isinstance(codebook_view, CodeBookTableView): - raise ValueError("Invalid value for argument 'codebook_view': " - + "'{}'".format(codebook_view)) + if codebook_view is not None and not isinstance( + codebook_view, CodeBookTableView + ): + raise ValueError( + "Invalid value for argument 'codebook_view': " + + "'{}'".format(codebook_view) + ) self.codebook_view = codebook_view @@ -71,13 +81,15 @@ class CodebookRowAdder(QWidget): # Match width of widgets to columnwidths of the view if it is used if self.codebook_view is not None: self.text_field_word.setFixedWidth( - self.codebook_view.columnWidth(0) - 12) + self.codebook_view.columnWidth(0) - 12 + ) self.text_field_category.setFixedWidth( - self.codebook_view.columnWidth(1) - 10) + self.codebook_view.columnWidth(1) - 10 + ) self.combo_type.setFixedWidth( - self.codebook_view.columnWidth(2) - 5) - self.button.setFixedWidth( - self.codebook_view.columnWidth(3) - 5) + self.codebook_view.columnWidth(2) - 5 + ) + self.button.setFixedWidth(self.codebook_view.columnWidth(3) - 5) # Set standard witdh of widgets if a view is not used else: self.text_field_word.setFixedWidth(140) @@ -162,10 +174,13 @@ class CodebookRowAdder(QWidget): self.codebook_view.setModel(None) # Try to add row to database - stmt = "INSERT INTO CodeBook(Word, Category, Type)" \ - + "VALUES(?, ?, ?)" - db.conn.execute(stmt, (word_input, category_input, - type_input,)) + stmt = ( + "INSERT INTO CodeBook(Word, Category, Type)" + + "VALUES(?, ?, ?)" + ) + db.conn.execute( + stmt, (word_input, category_input, type_input,) + ) # Add unique code to row and commit changes db.add_code_to(word_input) diff --git a/soitool/style.py b/soitool/style.py index d35ab094d9e71691c6169977cabf9f4452249457..61195a2c2fb1253a52be992f3ad6b0fcfc1c6475 100644 --- a/soitool/style.py +++ b/soitool/style.py @@ -4,8 +4,9 @@ from PySide2.QtGui import QFont # Font and background-color for horizontal header in codebook-view. CODEBOOK_HEADER_FONT = QFont() -CODEBOOK_HEADER_FONT.setFamily('Arial') +CODEBOOK_HEADER_FONT.setFamily("Arial") CODEBOOK_HEADER_FONT.setPointSize(14) CODEBOOK_HEADER_FONT.setWeight(50) -CODEBOOK_HEADER_BACKGROUND_CSS = "QHeaderView::section " \ - "{background-color:rgb(240, 240, 240)}" +CODEBOOK_HEADER_BACKGROUND_CSS = ( + "QHeaderView::section " "{background-color:rgb(240, 240, 240)}" +)