MCPcopy Create free account
hub / github.com/FSoft-AI4Code/CodeWiki / flake8

Function flake8

codewiki/src/be/agent_tools/str_replace_editor.py:211–219  ·  view source on GitHub ↗

Run flake8 on a given file and return the output as a string

(file_path: str)

Source from the content-addressed store, hash-verified

209
210
211def flake8(file_path: str) -> str:
212 """Run flake8 on a given file and return the output as a string"""
213 if Path(file_path).suffix != ".py":
214 return ""
215 cmd = "flake8 --isolated --select=F821,F822,F831,E111,E112,E113,E999,E902 {file_path}"
216 # don't use capture_output because it's not compatible with python3.6
217 out = subprocess.run(cmd.format(file_path=file_path), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
218 # Use errors="replace" so non-UTF-8 bytes (e.g. GBK-encoded paths on Windows) don't crash decoding.
219 return out.stdout.decode("utf-8", errors="replace")
220
221
222class Filemap:

Callers 1

str_replaceMethod · 0.85

Calls 2

runMethod · 0.80
formatMethod · 0.80

Tested by

no test coverage detected