def filtered_attrs(module, *, modules=False, private=False, dunder=False,
                   common=False):
    """Return a collection of attributes on 'module'.

    If 'modules' is false then module instances are excluded. If 'private' is
    false then attributes starting with, but not ending in, '_' will be
    excluded. With 'dunder' set to false then attributes starting and ending
    with '_' are left out. The 'common' argument controls whether attributes
    found in STANDARD_MODULE_ATTRS are returned.

    """
    attr_names = set()
    for name, value in module.__dict__.items():
        if not common and name in STANDARD_MODULE_ATTRS:
            continue
        if name.startswith('_'):
            if name.endswith('_'):
                if not dunder:
                    continue
            elif not private:
                continue
        if not modules and isinstance(value, types.ModuleType):
            continue
        attr_names.add(name)
    return frozenset(attr_names)
Return a collection of attributes on 'module'.

    If 'modules' is false then module instances are excluded. If 'private' is
    false then attributes starting with, but not ending in, '_' will be
    excluded. With 'dunder' set to false then attributes starting and ending
    with '_' are left out. The 'common' argument controls whether attributes
    found in STANDARD_MODULE_ATTRS are returned.