human
I wrote the below code

    assert ((not dir) or (not key))
    if (not dir):
        dirkey = (key + 'Directory')
        dir = aqt.mw.pm.profile.get(dirkey, '')
    else:
        dirkey = None
    d = QFileDialog(parent)
    d.setFileMode(QFileDialog.ExistingFile)
    if os.path.exists(dir):
        d.setDirectory(dir)
    d.setWindowTitle(title)
    d.setNameFilter(filter)
    ret = []
    def accept():
        file = str(list(d.selectedFiles())[0])
        if dirkey:
            dir = os.path.dirname(file)
            aqt.mw.pm.profile[dirkey] = dir
        if cb:
            cb(file)
        ret.append(file)
    d.accepted.connect(accept)
    d.exec_()
    return (ret and ret[0])

What's a good function header?

=====
Here's a good function header?
assistant
#Here's a good function header.

def getFile(parent, title, cb, filter='*.*', dir=None, key=None):