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

Method from_str

crates/ruff_python_formatter/src/string/normalize.rs:321–334  ·  view source on GitHub ↗
(text: &str, flags: AnyStringFlags, preferred_quote: Quote)

Source from the content-addressed store, hash-verified

319 }
320
321 fn from_str(text: &str, flags: AnyStringFlags, preferred_quote: Quote) -> Self {
322 let kind = if flags.is_raw_string() {
323 QuoteMetadataKind::raw(text, preferred_quote, flags.triple_quotes())
324 } else if flags.is_triple_quoted() {
325 QuoteMetadataKind::triple_quoted(text, preferred_quote)
326 } else {
327 QuoteMetadataKind::regular(text)
328 };
329
330 Self {
331 kind,
332 source_style: flags.quote_style(),
333 }
334 }
335
336 pub(super) fn choose(&self, preferred_quote: Quote) -> Quote {
337 match self.kind {

Callers

nothing calls this directly

Calls 6

rawFunction · 0.85
regularFunction · 0.85
is_raw_stringMethod · 0.45
triple_quotesMethod · 0.45
is_triple_quotedMethod · 0.45
quote_styleMethod · 0.45

Tested by

no test coverage detected