# Buggy code
def commands(self):
    def _dup(lib, opts, args):
        self.config.set_args(opts)
        fmt = self.config["format"].get()
        album = self.config["album"].get(bool)
        full = self.config["full"].get(bool)
        strict = self.config["strict"].get(bool)
        keys = self.config["keys"].get()
        checksum = self.config["checksum"].get()
        copy = self.config["copy"].get()
        move = self.config["move"].get()
        delete = self.config["delete"].get(bool)
        tag = self.config["tag"].get()

        if album:
            keys = ["mb_albumid"]
            items = lib.albums(decargs(args))
        else:
            items = lib.items(decargs(args))

        if self.config["path"]:
            fmt = "$path"

        # Default format string for count mode.
        if self.config["count"] and not fmt:
            if album:
                fmt = "$albumartist - $album"
            else:
                fmt = "$albumartist - $album - $title"
            fmt += ": {0}"

        if checksum:
            if not isinstance(checksum, basestring):
                raise UserError('duplicates: "checksum" option must be a command')
            for i in items:
                k, _ = self._checksum(i, checksum)
            keys = [k]

        for obj_id, obj_count, objs in self._duplicates(
            items, keys=keys, full=full, strict=strict
        ):
            if obj_id:  # Skip empty IDs.
                for o in objs:
                    self._process_item(
                        o,
                        lib,
                        copy=copy,
                        move=move,
                        delete=delete,
                        tag=tag,
                        fmt=fmt.format(obj_count),
                    )

    self._command.func = _dup
    return [self._command]


# Traceback (AttributeError)
$ beet dup
Warning: top-level configuration of `color` is deprecated. Configure color use under `ui`. See documentation for more info.
Traceback (most recent call last):
File "/usr/local/bin/beet", line 9, in <module>
load_entry_point('beets==1.3.14', 'console_scripts', 'beet')()
File "/usr/local/lib/python2.7/site-packages/beets/ui/__init__.py", line 1104, in main
_raw_main(args)
File "/usr/local/lib/python2.7/site-packages/beets/ui/__init__.py", line 1094, in _raw_main
subcommand.func(lib, suboptions, subargs)
File "/usr/local/lib/python2.7/site-packages/beetsplug/duplicates.py", line 148, in _dup
fmt=fmt.format(obj_count))
File "/usr/local/lib/python2.7/site-packages/beetsplug/duplicates.py", line 161, in _process_item
item.move(basedir=move, copy=False)
File "/usr/local/lib/python2.7/site-packages/beets/library.py", line 713, in move
dest = self.destination(basedir=basedir)
File "/usr/local/lib/python2.7/site-packages/beets/library.py", line 808, in destination
return normpath(os.path.join(basedir, subpath))
File "/usr/local/lib/python2.7/posixpath.py", line 77, in join
elif path == '' or path.endswith('/'):
AttributeError: 'bool' object has no attribute 'endswith'

# Fixed code
def commands(self):
    def _dup(lib, opts, args):
        self.config.set_args(opts)
        album = self.config["album"].get(bool)
        checksum = self.config["checksum"].get(str)
        copy = self.config["copy"].get(str)
        count = self.config["count"].get(bool)
        delete = self.config["delete"].get(bool)
        fmt = self.config["format"].get(str)
        full = self.config["full"].get(bool)
        keys = self.config["keys"].get(list)
        move = self.config["move"].get(str)
        path = self.config["path"].get(bool)
        strict = self.config["strict"].get(bool)
        tag = self.config["tag"].get(str)

        if album:
            keys = ["mb_albumid"]
            items = lib.albums(decargs(args))
        else:
            items = lib.items(decargs(args))

        if path:
            fmt = "$path"

        # Default format string for count mode.
        if count and not fmt:
            if album:
                fmt = "$albumartist - $album"
            else:
                fmt = "$albumartist - $album - $title"
            fmt += ": {0}"

        if checksum:
            for i in items:
                k, _ = self._checksum(i, checksum)
            keys = [k]

        for obj_id, obj_count, objs in self._duplicates(
            items, keys=keys, full=full, strict=strict
        ):
            if obj_id:  # Skip empty IDs.
                for o in objs:
                    self._process_item(
                        o,
                        lib,
                        copy=copy,
                        move=move,
                        delete=delete,
                        tag=tag,
                        fmt=fmt.format(obj_count),
                    )

    self._command.func = _dup
    return [self._command]