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

Method check_fstring_comments

crates/ruff_python_parser/src/parser/expression.rs:1672–1691  ·  view source on GitHub ↗

Check `range` for comment tokens, report an `UnsupportedSyntaxError` for each one found, and return whether any comments were found.

(&mut self, range: TextRange)

Source from the content-addressed store, hash-verified

1670 /// Check `range` for comment tokens, report an `UnsupportedSyntaxError` for each one found,
1671 /// and return whether any comments were found.
1672 fn check_fstring_comments(&mut self, range: TextRange) -> bool {
1673 let mut has_comments = false;
1674
1675 self.unsupported_syntax_errors.extend(
1676 self.tokens
1677 .in_range(range)
1678 .iter()
1679 .filter(|token| token.kind().is_comment())
1680 .map(|token| {
1681 has_comments = true;
1682 UnsupportedSyntaxError {
1683 kind: UnsupportedSyntaxErrorKind::Pep701FString(FStringKind::Comment),
1684 range: token.range(),
1685 target_version: self.options.target_version,
1686 }
1687 }),
1688 );
1689
1690 has_comments
1691 }
1692
1693 /// Parses a list of f/t-string elements.
1694 ///

Callers 1

Calls 8

extendMethod · 0.45
mapMethod · 0.45
filterMethod · 0.45
iterMethod · 0.45
in_rangeMethod · 0.45
is_commentMethod · 0.45
kindMethod · 0.45
rangeMethod · 0.45

Tested by

no test coverage detected