MCPcopy
hub / github.com/marimo-team/marimo / check_file

Function check_file

scripts/check_docstring_backticks.py:34–59  ·  view source on GitHub ↗

Return a list of `path:line: message` errors for one file.

(path: str)

Source from the content-addressed store, hash-verified

32
33
34def check_file(path: str) -> list[str]:
35 """Return a list of `path:line: message` errors for one file."""
36 try:
37 with open(path, encoding="utf-8") as f:
38 source = f.read()
39 except (OSError, UnicodeDecodeError) as e:
40 return [f"{path}: could not read file ({e})"]
41
42 try:
43 tree = ast.parse(source, filename=path)
44 except SyntaxError:
45 # Leave syntax errors to other tools (ruff, the compiler).
46 return []
47
48 errors: list[str] = []
49 for node in ast.walk(tree):
50 if not isinstance(node, _DOCSTRINGABLE):
51 continue
52 docstring = ast.get_docstring(node, clean=False)
53 if docstring and _DOUBLE_BACKTICK.search(docstring):
54 # ast.Module has no lineno; its docstring starts the file.
55 lineno = getattr(node, "lineno", 1)
56 errors.append(
57 f"{path}:{lineno}: double backticks in docstring"
58 )
59 return errors
60
61
62def main(argv: list[str]) -> int:

Callers 1

mainFunction · 0.85

Calls 5

walkMethod · 0.80
parseMethod · 0.65
readMethod · 0.45
searchMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…