Commit a07786cc authored by Matt Harbison's avatar Matt Harbison

cleanup: eliminate mutable default argument values

Flagged by PyCharm.
parent b8b7e7bb84c7
......@@ -16,14 +16,18 @@ def setup():
_tempdir = helpers.mktmpdir(__name__)
def newrconfig(vals={}):
def newrconfig(vals=None):
if vals is None:
vals = {}
c = config.config()
for k, v in isinstance(vals, dict) and vals.items() or vals:
sec, it = k.split('.', 1)
c.set(sec, it, v)
return c
def newwconfig(vals={}):
def newwconfig(vals=None):
if vals is None:
vals = {}
return wconfig.config(newrconfig(vals))
def written(c):
......
......@@ -71,8 +71,10 @@ def _suggesteddest(src, basedest):
class CloneWidget(cmdui.AbstractCmdWidget):
def __init__(self, ui, cmdagent, args=None, opts={}, parent=None):
def __init__(self, ui, cmdagent, args=None, opts=None, parent=None):
super(CloneWidget, self).__init__(parent)
if opts is None:
opts = {}
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self._cmdagent = cmdagent
self.ui = ui
......
......@@ -727,12 +727,14 @@ class CustomToolConfigDialog(CustomConfigDialog):
]
_defaulticonstring = _('<default icon>')
def __init__(self, parent=None, toolname=None, toolconfig={}):
def __init__(self, parent=None, toolname=None, toolconfig=None):
super(CustomToolConfigDialog, self).__init__(parent,
dialogname='customtools',
windowTitle=_('Configure Custom Tool'),
windowIcon=qtlib.geticon(DEFAULTICONNAME))
if toolconfig is None:
toolconfig = {}
vbox = self.formvbox
command = toolconfig.get('command', '')
......
......@@ -784,7 +784,9 @@ def getfont(name):
return _fontcache[name]
def CommonMsgBox(icon, title, main, text='', buttons=QMessageBox.Ok,
labels=[], parent=None, defaultbutton=None):
labels=None, parent=None, defaultbutton=None):
if labels is None:
labels = []
msg = QMessageBox(parent)
msg.setIcon(icon)
msg.setWindowTitle(title)
......
......@@ -837,8 +837,10 @@ class RepoWidget(QWidget):
## End workbench event forwards
@pyqtSlot(str, dict)
def grep(self, pattern='', opts={}):
def grep(self, pattern='', opts=None):
"""Open grep task tab"""
if opts is None:
opts = {}
opts = dict((str(k), str(v)) for k, v in opts.items())
self.taskTabsWidget.setCurrentIndex(self._namedTabs['grep'])
self.grepDemand.setSearch(pattern, **opts)
......
......@@ -497,7 +497,9 @@ class PathBrowser(QWidget):
def isDirty(self):
return self.value() != self.curvalue
def genEditCombo(opts, defaults=[]):
def genEditCombo(opts, defaults=None):
if defaults is None:
defaults = []
opts['canedit'] = True
opts['defaults'] = defaults
return SettingsCombo(**opts)
......@@ -521,8 +523,10 @@ def genTextEntry(opts):
'Generate a multi-line text input entry box'
return TextEntry(**opts)
def genDefaultCombo(opts, defaults=[]):
def genDefaultCombo(opts, defaults=None):
'user must select from a list'
if defaults is None:
defaults = []
opts['defaults'] = defaults
opts['nohist'] = True
return SettingsCombo(**opts)
......
......@@ -35,8 +35,10 @@ from . import (
class SignDialog(QDialog):
def __init__(self, repoagent, rev='tip', parent=None, opts={}):
def __init__(self, repoagent, rev='tip', parent=None, opts=None):
super(SignDialog, self).__init__(parent)
if opts is None:
opts = {}
self.setWindowFlags(self.windowFlags() &
~Qt.WindowContextHelpButtonHint)
......
......@@ -45,8 +45,10 @@ keep = i18n.keepgettext()
class TagDialog(QDialog):
def __init__(self, repoagent, tag='', rev='tip', parent=None, opts={}):
def __init__(self, repoagent, tag='', rev='tip', parent=None, opts=None):
super(TagDialog, self).__init__(parent)
if opts is None:
opts = {}
self.setWindowFlags(self.windowFlags() &
~Qt.WindowContextHelpButtonHint)
......
......@@ -38,8 +38,10 @@ from . import (
class StripWidget(cmdui.AbstractCmdWidget):
"""Command widget to strip changesets"""
def __init__(self, repoagent, rev=None, parent=None, opts={}):
def __init__(self, repoagent, rev=None, parent=None, opts=None):
super(StripWidget, self).__init__(parent)
if opts is None:
opts = {}
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self._repoagent = repoagent
......@@ -188,7 +190,9 @@ class StripWidget(cmdui.AbstractCmdWidget):
return self._repoagent.runCommand(cmdline, self)
def createStripDialog(repoagent, rev=None, parent=None, opts={}):
def createStripDialog(repoagent, rev=None, parent=None, opts=None):
if opts is None:
opts = {}
dlg = cmdui.CmdControlDialog(parent)
dlg.setWindowIcon(qtlib.geticon('hg-strip'))
dlg.setWindowTitle(_('Strip - %s') % repoagent.displayName())
......
......@@ -40,8 +40,10 @@ from . import (
class UpdateWidget(cmdui.AbstractCmdWidget):
def __init__(self, repoagent, rev=None, parent=None, opts={}):
def __init__(self, repoagent, rev=None, parent=None, opts=None):
super(UpdateWidget, self).__init__(parent)
if opts is None:
opts = {}
self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
self._repoagent = repoagent
repo = repoagent.rawRepo()
......@@ -401,8 +403,10 @@ class UpdateWidget(cmdui.AbstractCmdWidget):
class UpdateDialog(cmdui.CmdControlDialog):
def __init__(self, repoagent, rev=None, parent=None, opts={}):
def __init__(self, repoagent, rev=None, parent=None, opts=None):
super(UpdateDialog, self).__init__(parent)
if opts is None:
opts = {}
self._repoagent = repoagent
self.setWindowTitle(_('Update - %s') % repoagent.displayName())
......
......@@ -855,8 +855,13 @@ class Workbench(QMainWindow):
getattr(w, name)(checked)
return forwarder
def _repofwd(self, name, params=[], namedparams={}):
def _repofwd(self, name, params=None, namedparams=None):
"""Return function to forward action to the current repo tab"""
if params is None:
params = []
if namedparams is None:
namedparams = {}
def forwarder():
w = self._currentRepoWidget()
if w:
......
......@@ -114,8 +114,10 @@ class TortoiseMenu(object):
class TortoiseSubmenu(TortoiseMenu):
def __init__(self, menutext, helptext, menus=[], icon=None):
def __init__(self, menutext, helptext, menus=None, icon=None):
TortoiseMenu.__init__(self, menutext, helptext, None, icon)
if menus is None:
menus = []
self.menus = menus[:]
def add_menu(self, menutext, helptext, hgcmd, icon=None, state=True):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment