mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-22 11:25:26 +00:00
Unify enums used for internal representation of quoting style (#10383)
This commit is contained in:
parent
d59433b12e
commit
c2e15f38ee
16 changed files with 148 additions and 228 deletions
|
@ -1,8 +1,8 @@
|
|||
use crate::comments::Comments;
|
||||
use crate::other::f_string::FStringContext;
|
||||
use crate::string::QuoteChar;
|
||||
use crate::PyFormatOptions;
|
||||
use ruff_formatter::{Buffer, FormatContext, GroupId, IndentWidth, SourceCode};
|
||||
use ruff_python_ast::str::Quote;
|
||||
use ruff_source_file::Locator;
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
@ -22,7 +22,7 @@ pub struct PyFormatContext<'a> {
|
|||
/// works. For example, multi-line strings will always be written with a
|
||||
/// quote style that is inverted from the one here in order to ensure that
|
||||
/// the formatted Python code will be valid.
|
||||
docstring: Option<QuoteChar>,
|
||||
docstring: Option<Quote>,
|
||||
/// The state of the formatter with respect to f-strings.
|
||||
f_string_state: FStringState,
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ impl<'a> PyFormatContext<'a> {
|
|||
///
|
||||
/// The quote character returned corresponds to the quoting used for the
|
||||
/// docstring containing the code snippet currently being formatted.
|
||||
pub(crate) fn docstring(&self) -> Option<QuoteChar> {
|
||||
pub(crate) fn docstring(&self) -> Option<Quote> {
|
||||
self.docstring
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ impl<'a> PyFormatContext<'a> {
|
|||
///
|
||||
/// The quote character given should correspond to the quote character used
|
||||
/// for the docstring containing the code snippets.
|
||||
pub(crate) fn in_docstring(self, quote: QuoteChar) -> PyFormatContext<'a> {
|
||||
pub(crate) fn in_docstring(self, quote: Quote) -> PyFormatContext<'a> {
|
||||
PyFormatContext {
|
||||
docstring: Some(quote),
|
||||
..self
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue