import fnmatch


def rule_settings_match(rule, filepath):
    """Return whether rule should be executed on file."""
    should_be_included = any(
        fnmatch.fnmatch(filepath, included_pattern)
        for included_pattern in rule.settings.included
    )
    should_be_excluded = any(
        fnmatch.fnmatch(filepath, excluded_pattern)
        for excluded_pattern in rule.settings.excluded
    )
    return should_be_included and not should_be_excluded