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

Method parse_match_pattern_target

crates/ruff_python_parser/src/parser/pattern.rs:293–304  ·  view source on GitHub ↗

Parses a binding target in an `as` or mapping pattern.

(&mut self)

Source from the content-addressed store, hash-verified

291
292 /// Parses a binding target in an `as` or mapping pattern.
293 fn parse_match_pattern_target(&mut self) -> ast::Identifier {
294 // test_err invalid_match_pattern_target
295 // match value:
296 // case 1 as _: ...
297 // case {**_}: ...
298 // after = 1
299 let identifier = self.parse_identifier();
300 if identifier.is_valid() && identifier.id == "_" {
301 self.add_error(ParseErrorType::InvalidMatchPatternTarget, &identifier);
302 }
303 identifier
304 }
305
306 /// Parses a parenthesized pattern or a sequence pattern.
307 ///

Callers 2

parse_match_patternMethod · 0.80

Calls 3

parse_identifierMethod · 0.80
is_validMethod · 0.80
add_errorMethod · 0.45

Tested by

no test coverage detected