def load_ignores(workspace_root: Path) -> SyncRules:
    ignores: Dict[(str, List[str])] = defaultdict(list)
    ignores['both'].extend(BASE_IGNORES)
    ignore_file = (workspace_root / IGNORE_FILE_NAME)
    if (not ignore_file.exists()):
        return _postprocess(ignores)
    active_section = 'both'
    is_new_format = None
    for line in ignore_file.read_text().splitlines():
        line = line.strip()
        if ((not line) or line.startswith('#')):
            continue
        matcher = IGNORE_SECTION_REGEX.match(line)
        if (matcher is None):
            if (is_new_format is None):
                is_new_format = False
            ignores[active_section].append(line)
        else:
            if (is_new_format is None):
                is_new_format = True
            elif (not is_new_format):
                raise ConfigurationError(f'Few ignore patters were listed in {IGNORE_FILE_NAME} before the first section {matcher.group(1)} appeared. Please list all ignored files after a section declaration if you use new ignore format')
            active_section = matcher.group(1)
    return _postprocess(ignores)
def load_ignores(workspace_root: Path) -> SyncRules:
    ignores: Dict[(str, List[str])] = defaultdict(list)
    ignores['both'].extend(BASE_IGNORES)
    ignore_file = (workspace_root / IGNORE_FILE_NAME)
    if (not ignore_file.exists()):
        return _postprocess(ignores)
    active_section = 'both'
    is_new_format = None
    for line in ignore_file.read_text().splitlines():
        line = line.strip()
        if ((not line) or line.startswith('#')):
            continue
        matcher = IGNORE_SECTION_REGEX.match(line)
        if (matcher is None):
            if (is_new_format is None):
                is_new_format = False
            ignores[active_section].append(line)
        else:
            if (is_new_format is None):
                is_new_format = True
            elif (not is_new_format):
                raise ConfigurationError(f'Few ignore patters were listed in {IGNORE_FILE_NAME} before the first section {matcher.group(1)} appeared. Please list all ignored files after a section declaration if you use new ignore format')
            active_section = matcher.group(1)
    return _postprocess(ignores)