def lint_paths( self, paths: Tuple[str, ...], fix: bool = False, ignore_non_existent_files: bool = False, ignore_files: bool = True, parallel: int = 1, ) -> LintingResult: """Lint an iterable of paths.""" # If no paths specified - assume local if len(paths) == 0: paths = (os.getcwd(), ) # Set up the result to hold what we get back result = LintingResult() for path in paths: # Iterate through files recursively in the specified directory (if it's a directory) # or read the file directly if it's not result.add( self.lint_path( path, fix=fix, ignore_non_existent_files=ignore_non_existent_files, ignore_files=ignore_files, parallel=parallel, )) return result
def lint_string_wrapped(self, string: str, fname: str = "<string input>", fix: bool = False) -> LintingResult: """Lint strings directly.""" result = LintingResult() linted_path = LintedDir(fname) linted_path.add(self.lint_string(string, fname=fname, fix=fix)) result.add(linted_path) return result
def lint_paths( self, paths: Tuple[str, ...], fix: bool = False, ignore_non_existent_files: bool = False, ignore_files: bool = True, processes: Optional[int] = None, ) -> LintingResult: """Lint an iterable of paths.""" paths_count = len(paths) # If no paths specified - assume local if not paths_count: # pragma: no cover paths = (os.getcwd(), ) # Set up the result to hold what we get back result = LintingResult() progress_bar_paths = tqdm( total=paths_count, desc="path", leave=False, disable=paths_count <= 1 or progress_bar_configuration.disable_progress_bar, ) for path in paths: progress_bar_paths.set_description(f"path {path}") # Iterate through files recursively in the specified directory (if it's a # directory) or read the file directly if it's not result.add( self.lint_path( path, fix=fix, ignore_non_existent_files=ignore_non_existent_files, ignore_files=ignore_files, processes=processes, )) progress_bar_paths.update(1) result.stop_timer() return result