Skip to content

Commit 56581b6

Browse files
committed
Cosmetics and Napoleon docstrings
1 parent 71beb77 commit 56581b6

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

Qt.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -826,10 +826,10 @@ def _wrapinstance(func, ptr, base=None):
826826

827827

828828
def _reassign_misplaced_members(binding):
829-
"""Parse `_misplaced_members` dict and remap
830-
values based on the underlying binding.
829+
"""Apply misplaced members from `binding` to Qt.py
831830
832-
:param str binding: Top level binding in _misplaced_members.
831+
Arguments:
832+
binding (dict): Misplaced members
833833
834834
"""
835835

@@ -855,9 +855,8 @@ def _reassign_misplaced_members(binding):
855855
)
856856

857857

858-
def _build_compatibility_members(binding, decorators={}):
859-
""" Parse `_compatibility_members` dict and construct _QtCompat classes
860-
based on the underlying binding.
858+
def _build_compatibility_members(binding, decorators=None):
859+
"""Apply `binding` to QtCompat
861860
862861
Arguments:
863862
binding (str): Top level binding in _compatibility_members.
@@ -866,7 +865,11 @@ def _build_compatibility_members(binding, decorators={}):
866865
to change the returned value to a standard value. The key should
867866
be the classname, the value is a dict where the keys are the
868867
target method names, and the values are the decorator functions.
868+
869869
"""
870+
871+
decorators = decorators or dict()
872+
870873
# Allow optional site-level customization of the compatibility members.
871874
# This method does not need to be implemented in QtSiteConfig.
872875
try:
@@ -877,6 +880,8 @@ def _build_compatibility_members(binding, decorators={}):
877880
if hasattr(QtSiteConfig, 'update_compatibility_decorators'):
878881
QtSiteConfig.update_compatibility_decorators(binding, decorators)
879882

883+
_QtCompat = type("QtCompat", (object,), {})
884+
880885
for classname, bindings in _compatibility_members[binding].items():
881886
attrs = {}
882887
for target, binding in bindings.items():
@@ -890,6 +895,7 @@ def _build_compatibility_members(binding, decorators={}):
890895
# rename a member that didn't exist, for example
891896
# if QtWidgets isn't available on the target platform.
892897
continue
898+
893899
# Walk down any remaining namespace getting the object assuming
894900
# that if the first namespace exists the rest will exist.
895901
for namespace in namespaces[1:]:
@@ -906,7 +912,7 @@ def _build_compatibility_members(binding, decorators={}):
906912
attrs[target] = src_object
907913

908914
# Create the QtCompat class and install it into the namespace
909-
compat_class = type(classname, tuple([_QtCompat]), attrs)
915+
compat_class = type(classname, (_QtCompat,), attrs)
910916
setattr(Qt.QtCompat, classname, compat_class)
911917

912918

@@ -1114,17 +1120,18 @@ def _pyqt4():
11141120

11151121
# QFileDialog QtCompat decorator
11161122
def _standardizeQFileDialog(some_function):
1117-
""" decorator that makes PyQt4 return conform to other bindings
1118-
"""
1123+
"""Decorator that makes PyQt4 return conform to other bindings"""
11191124
def wrapper(*args, **kwargs):
11201125
ret = (some_function(*args, **kwargs))
1126+
11211127
# PyQt4 only returns the selected filename, force it to a
11221128
# standard return of the selected filename, and a empty string
11231129
# for the selected filter
1124-
return (ret, '')
1125-
# preserve docstring and name of original method
1130+
return ret, ''
1131+
11261132
wrapper.__doc__ = some_function.__doc__
11271133
wrapper.__name__ = some_function.__name__
1134+
11281135
return wrapper
11291136

11301137
decorators = {
@@ -1260,10 +1267,6 @@ def createWidget(self, class_name, parent=None, name=""):
12601267
raise NotImplementedError("No implementation available for loadUi")
12611268

12621269

1263-
class _QtCompat(object):
1264-
""" Baseclass for QtCompat namespace objects."""
1265-
pass
1266-
12671270
def _convert(lines):
12681271
"""Convert compiled .ui file from PySide2 to Qt.py
12691272

0 commit comments

Comments
 (0)