-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create dedicated
is_*_enabled
functions for each preview style (#8988)
- Loading branch information
1 parent
7e390d3
commit 0bda191
Showing
7 changed files
with
39 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//! 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 [`fix_power_op_line_length`](https://github.com/astral-sh/ruff/issues/8938) preview style is enabled. | ||
pub(crate) const fn is_fix_power_op_line_length_enabled(context: &PyFormatContext) -> bool { | ||
context.is_preview() | ||
} | ||
|
||
/// 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() | ||
} |