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

Method try_into_module

crates/ruff_python_parser/src/lib.rs:494–504  ·  view source on GitHub ↗

Attempts to convert the [`Parsed `] into a [`Parsed `]. This method checks if the `syntax` field of the output is a [`Mod::Module`]. If it is, the method returns [`Some(Parsed )`] with the contained module. Otherwise, it returns [`None`]. [`Some(Parsed )`]: Some

(self)

Source from the content-addressed store, hash-verified

492 ///
493 /// [`Some(Parsed<ModModule>)`]: Some
494 pub fn try_into_module(self) -> Option<Parsed<ModModule>> {
495 match self.syntax {
496 Mod::Module(module) => Some(Parsed {
497 syntax: module,
498 tokens: self.tokens,
499 errors: self.errors,
500 unsupported_syntax_errors: self.unsupported_syntax_errors,
501 }),
502 Mod::Expression(_) => None,
503 }
504 }
505
506 /// Attempts to convert the [`Parsed<Mod>`] into a [`Parsed<ModExpression>`].
507 ///

Callers 13

parsed_module_implFunction · 0.80
checkMethod · 0.80
parse_moduleFunction · 0.80
parse_unchecked_sourceFunction · 0.80
parse_cells_uncheckedFunction · 0.80
test_valid_syntaxFunction · 0.80
test_invalid_syntaxFunction · 0.80
parse_unchecked_sourceFunction · 0.80

Calls

no outgoing calls