MCPcopy Create free account
hub / github.com/espnet/espnet / run_pycodestyle

Function run_pycodestyle

utils/apply_code_fixes.py:48–76  ·  view source on GitHub ↗

Run pycodestyle on the specified paths and return the output. Args: paths: List of file or directory paths to check. exclude: List of patterns to exclude. Returns: The output from pycodestyle.

(paths: List[str], exclude: Optional[List[str]] = None)

Source from the content-addressed store, hash-verified

46
47
48def run_pycodestyle(paths: List[str], exclude: Optional[List[str]] = None) -> str:
49 """Run pycodestyle on the specified paths and return the output.
50
51 Args:
52 paths: List of file or directory paths to check.
53 exclude: List of patterns to exclude.
54
55 Returns:
56 The output from pycodestyle.
57 """
58 exclude_str = ",".join(exclude) if exclude else ""
59 cmd = ["pycodestyle", "--show-source", "--show-pep8"]
60
61 if exclude_str:
62 cmd.extend(["--exclude", exclude_str])
63
64 cmd.extend(paths)
65
66 try:
67 result = subprocess.run(
68 cmd,
69 check=False, # Don't raise an exception if pycodestyle finds issues
70 capture_output=True,
71 text=True,
72 )
73 return result.stdout
74 except subprocess.CalledProcessError as e:
75 print(f"Error running pycodestyle: {e}", file=sys.stderr)
76 return e.stdout if e.stdout else ""
77
78
79def parse_pycodestyle_output(output: str) -> Dict[str, List[Dict[str, str]]]:

Callers 1

mainFunction · 0.85

Calls 2

extendMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…