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

Function main

utils/apply_code_fixes.py:385–544  ·  view source on GitHub ↗

Run the script.

()

Source from the content-addressed store, hash-verified

383
384
385def main():
386 """Run the script."""
387 parser = argparse.ArgumentParser(
388 description="Fix common flake8 and pycodestyle issues in Python files."
389 )
390 parser.add_argument(
391 "paths", nargs="+", help="Paths to files or directories to process."
392 )
393 parser.add_argument(
394 "--exclude",
395 nargs="+",
396 default=["__pycache__", ".git", "venv", "env", ".venv", ".env"],
397 help="Directories to exclude from processing.",
398 )
399 parser.add_argument(
400 "--mode",
401 choices=["auto", "pycodestyle", "tools"],
402 default="auto",
403 help=(
404 "Mode of operation: 'auto' uses both methods, 'pycodestyle' uses "
405 "pycodestyle output parsing, 'tools' uses external formatting tools."
406 ),
407 )
408 parser.add_argument(
409 "--no-black", action="store_true", help="Don't use black for formatting."
410 )
411 parser.add_argument(
412 "--no-isort", action="store_true", help="Don't use isort for import sorting."
413 )
414 parser.add_argument(
415 "--no-autopep8",
416 action="store_true",
417 help="Don't use autopep8 for PEP 8 compliance.",
418 )
419 parser.add_argument(
420 "-v", "--verbose", action="store_true", help="Print verbose output."
421 )
422
423 args = parser.parse_args()
424
425 # Check if pycodestyle is installed
426 if args.mode in ["auto", "pycodestyle"]:
427 try:
428 subprocess.run(
429 ["which", "pycodestyle"],
430 check=True,
431 stdout=subprocess.PIPE,
432 stderr=subprocess.PIPE,
433 )
434 except subprocess.CalledProcessError:
435 print("Error: pycodestyle is not installed. Please install it using pip:")
436 print(" pip install pycodestyle")
437 if args.mode == "pycodestyle":
438 return 1
439 print("Falling back to tools-only mode.")
440 args.mode = "tools"
441
442 # For tools mode, check if required tools are installed

Callers 1

Calls 8

run_pycodestyleFunction · 0.85
parse_pycodestyle_outputFunction · 0.85
fix_from_pycodestyleFunction · 0.85
find_python_filesFunction · 0.85
fix_fileFunction · 0.85
appendMethod · 0.80
runMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…