MCPcopy Index your code
hub / github.com/python/mypy / ast3_parse

Function ast3_parse

mypy/fastparse.py:136–150  ·  view source on GitHub ↗
(
    source: str | bytes, filename: str, mode: str, feature_version: int = PY_MINOR_VERSION
)

Source from the content-addressed store, hash-verified

134
135
136def ast3_parse(
137 source: str | bytes, filename: str, mode: str, feature_version: int = PY_MINOR_VERSION
138) -> AST:
139 # Ignore warnings that look like:
140 # <type_comment>:1: SyntaxWarning: invalid escape sequence '\.'
141 # because `source` could be anything, including literals like r'(re\.match)'
142 with warnings.catch_warnings():
143 warnings.simplefilter("ignore", SyntaxWarning)
144 return ast3.parse(
145 source,
146 filename,
147 mode,
148 type_comments=True, # This works the magic
149 feature_version=feature_version,
150 )
151
152
153AstNode = ast3.expr | ast3.stmt | ast3.pattern | ast3.ExceptHandler

Callers 3

parseFunction · 0.85
parse_type_commentFunction · 0.85
do_func_defMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…