mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-20 18:40:28 +00:00
22 lines
1.1 KiB
Rust
22 lines
1.1 KiB
Rust
//! Helpers to test if a specific preview style is enabled or not.
|
|
//!
|
|
//! The motivation for these functions isn't to avoid code duplication but to ease promoting preview styles
|
|
//! to stable. The challenge with directly using [`is_preview`](PyFormatContext::is_preview) is that it is unclear
|
|
//! for which specific feature this preview check is for. Having named functions simplifies the promotion:
|
|
//! Simply delete the function and let Rust tell you which checks you have to remove.
|
|
|
|
use crate::PyFormatContext;
|
|
|
|
/// Returns `true` if the [`hug_parens_with_braces_and_square_brackets`](https://github.com/astral-sh/ruff/issues/8279) preview style is enabled.
|
|
pub(crate) const fn is_hug_parens_with_braces_and_square_brackets_enabled(
|
|
context: &PyFormatContext,
|
|
) -> bool {
|
|
context.is_preview()
|
|
}
|
|
|
|
/// Returns `true` if the bugfix for single-with items with a trailing comment targeting Python 3.9 or newer is enabled.
|
|
///
|
|
/// See [#14001](https://github.com/astral-sh/ruff/issues/14001)
|
|
pub(crate) fn is_with_single_target_parentheses_enabled(context: &PyFormatContext) -> bool {
|
|
context.is_preview()
|
|
}
|