Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def apply_fix(
*,
ls_files_cmd: Sequence[str],
sed_cmd: Sequence[str],
) -> None:
filenames_b = zsplit(subprocess.check_output(ls_files_cmd))
filenames = [f.decode() for f in filenames_b]
filenames = [f for f in filenames if tags_from_path(f) & {'file', 'text'}]
autofix_lib.run(*sed_cmd, *filenames)
def _filenames(
files_re: Pattern[str],
exclude_re: Pattern[str],
tests_re: Pattern[str],
) -> Generator[Tuple[str, bool], None, None]:
# TODO: zsplit is more correct than splitlines
out = subprocess.check_output(('git', 'ls-files')).decode()
for filename in out.splitlines():
if (
not files_re.search(filename) or
exclude_re.search(filename) or
'python' not in tags_from_path(filename)
):
continue
yield filename, bool(tests_re.search(filename))
def _types_for_file(self, filename):
try:
return self._types_cache[filename]
except KeyError:
ret = self._types_cache[filename] = tags_from_path(filename)
return ret