[PyQt] Add 2 blank lines between import & classes in pyuic5 output

Addison Elliott addison.elliott at gmail.com
Mon Jan 7 16:53:03 GMT 2019


Noticed that *pyuic5* also includes two newlines at the end of the file
that reports an error in flake8.

On Tue, Jan 1, 2019 at 10:04 PM Addison Elliott <addison.elliott at gmail.com>
wrote:

> Hello everyone,
>
> I want to start by stating this is a minor issue that I don't *believe* has
> a fix without changes to the source code. With that in mind, I think it's
> worthwhile and simple to fix.
>
> When generating Python files from .ui files using *pyuic5, *the Python
> file only includes one space between the imports & beginning of classes.
> For example:
> # -*- coding: utf-8 -*-
>
> # Form implementation generated from reading ui file 'mainWindow.ui'
> #
> # Created by: PyQt5 UI code generator 5.9
> #
> # WARNING! All changes made in this file will be lost!
>
> from PyQt5 import QtCore, QtGui, QtWidgets
>
> class Ui_MainWindow(object):
> def setupUi(self, MainWindow):
> MainWindow.setObjectName("MainWindow")
> MainWindow.resize(837, 727)
> self.centralwidget = QtWidgets.QWidget(MainWindow)
> self.centralwidget.setObjectName("centralwidget")
> ...
>
> I use *flake8 *in my project to automatically lint and detect whitespace
> issues in my project. These auto-generated files are giving the following
> error:
>
> *E0302 - Expected 2 blank lines, found 1*
>
>
> Here is the PEP8 reference that explains that there should be two spaces
> between the import statements and class definition:
> https://www.python.org/dev/peps/pep-0008/#blank-lines
>
> Thanks,
> Addison
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20190107/1d9b7725/attachment.html>


More information about the PyQt mailing list