MCPcopy Index your code
hub / github.com/modelscope/modelscope / validate_py_syntax

Function validate_py_syntax

modelscope/utils/import_utils.py:135–143  ·  view source on GitHub ↗
(filename)

Source from the content-addressed store, hash-verified

133
134
135def validate_py_syntax(filename):
136 with open(filename, 'r', encoding='utf-8') as f:
137 # Setting encoding explicitly to resolve coding issue on windows
138 content = f.read()
139 try:
140 ast.parse(content)
141 except SyntaxError as e:
142 raise SyntaxError('There are syntax errors in config '
143 f'file {filename}: {e}')
144
145
146# following code borrows implementation from huggingface/transformers

Callers 1

import_modules_from_fileFunction · 0.85

Calls 1

readMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…