MCPcopy Create free account
hub / github.com/astral-sh/ruff / parse_unchecked_source

Function parse_unchecked_source

crates/ruff_python_parser/src/lib.rs:294–300  ·  view source on GitHub ↗

Parse the given Python source code using the specified [`PySourceType`].

(source: &str, source_type: PySourceType)

Source from the content-addressed store, hash-verified

292
293/// Parse the given Python source code using the specified [`PySourceType`].
294pub fn parse_unchecked_source(source: &str, source_type: PySourceType) -> Parsed<ModModule> {
295 // SAFETY: Safe because `PySourceType` always parses to a `ModModule`
296 Parser::new(source, ParseOptions::from(source_type))
297 .parse()
298 .try_into_module()
299 .unwrap()
300}
301
302/// Parses each `range` of `source` as an independent module and concatenates the results into a
303/// single [`Parsed<ModModule>`] whose nodes keep their offsets into `source`.

Callers

nothing calls this directly

Calls 2

try_into_moduleMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected