Add 2 blank lines between import & classes in pyuic5 output

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Add 2 blank lines between import & classes in pyuic5 output

addisonElliott
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

_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: Add 2 blank lines between import & classes in pyuic5 output

addisonElliott
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 <[hidden email]> 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

_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt