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

Method choose

crates/ruff_python_formatter/src/string/normalize.rs:336–361  ·  view source on GitHub ↗
(&self, preferred_quote: Quote)

Source from the content-addressed store, hash-verified

334 }
335
336 pub(super) fn choose(&self, preferred_quote: Quote) -> Quote {
337 match self.kind {
338 QuoteMetadataKind::Raw { contains_preferred } => {
339 if contains_preferred {
340 self.source_style
341 } else {
342 preferred_quote
343 }
344 }
345 QuoteMetadataKind::Triple { contains_preferred } => {
346 if contains_preferred {
347 self.source_style
348 } else {
349 preferred_quote
350 }
351 }
352 QuoteMetadataKind::Regular {
353 single_quotes,
354 double_quotes,
355 } => match single_quotes.cmp(&double_quotes) {
356 Ordering::Less => Quote::Single,
357 Ordering::Equal => preferred_quote,
358 Ordering::Greater => Quote::Double,
359 },
360 }
361 }
362
363 /// Merges the quotes metadata of different literals.
364 ///

Callers 5

choose_quotesMethod · 0.80
merge_flagsMethod · 0.80
arbitrary_core_typeFunction · 0.80
arbitrary_typeFunction · 0.80
arbitrary_parameter_listFunction · 0.80

Calls 1

cmpMethod · 0.45

Tested by

no test coverage detected