Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_empty_exclude(self) -> None:
path = THIS_DIR / "data" / "include_exclude_tests"
report = black.Report()
gitignore = PathSpec.from_lines("gitwildmatch", [])
empty = re.compile(r"")
sources: List[Path] = []
expected = [
Path(path / "b/dont_exclude/a.py"),
Path(path / "b/dont_exclude/a.pyi"),
Path(path / "b/exclude/a.py"),
Path(path / "b/exclude/a.pyi"),
Path(path / "b/.definitely_exclude/a.py"),
Path(path / "b/.definitely_exclude/a.pyi"),
]
this_abs = THIS_DIR.resolve()
sources.extend(
black.gen_python_files_in_dir(
path,
this_abs,
re.compile(black.DEFAULT_INCLUDES),
def validate_rule_conf(rule, conf):
if conf is False or conf == 'disable':
return False
elif conf == 'enable':
conf = {}
if type(conf) == dict:
if ('ignore' in conf and
type(conf['ignore']) != pathspec.pathspec.PathSpec):
if type(conf['ignore']) != str:
raise YamlLintConfigError(
'invalid config: ignore should contain file patterns')
conf['ignore'] = pathspec.PathSpec.from_lines(
'gitwildmatch', conf['ignore'].splitlines())
if 'level' not in conf:
conf['level'] = 'error'
elif conf['level'] not in ('error', 'warning'):
raise YamlLintConfigError(
'invalid config: level should be "error" or "warning"')
options = getattr(rule, 'CONF', {})
for optkey in conf:
if optkey in ('ignore', 'level'):
continue
if optkey not in options:
raise YamlLintConfigError(
'invalid config: unknown option "%s" for rule "%s"' %
(optkey, rule.ID))
def descend(path, parent, ignores):
if not os.path.exists(path): return
ignores = ignores[:]
ignores += get_ignores(path)
spec = pathspec.PathSpec.from_lines('gitwildmatch', ignores)
names = [n for n in os.listdir(path) if not spec.match_file(os.path.relpath(os.path.join(path, n),
directory))]
if "service.yaml" in names:
candidate = os.path.join(path, "service.yaml")
if is_service_descriptor(candidate):
svc = Service(self.forge, candidate, shallow=shallow)
if svc.name not in self.services:
self.services[svc.name] = svc
found.append(svc)
parent = svc
if "Dockerfile" in names and parent:
parent.dockerfiles.append(os.path.relpath(os.path.join(path, "Dockerfile"), parent.root))
for n in names: