Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename semantic model flag LITERAL to TYPING_LITERAL #8997

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/ruff_linter/src/checkers/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ where
fn visit_expr(&mut self, expr: &'b Expr) {
// Step 0: Pre-processing
if !self.semantic.in_f_string()
&& !self.semantic.in_literal()
&& !self.semantic.in_typing_literal()
&& !self.semantic.in_deferred_type_definition()
&& self.semantic.in_type_definition()
&& self.semantic.future_annotations()
Expand Down Expand Up @@ -1198,7 +1198,7 @@ where
) {
// Ex) Literal["Class"]
Some(typing::SubscriptKind::Literal) => {
self.semantic.flags |= SemanticModelFlags::LITERAL;
self.semantic.flags |= SemanticModelFlags::TYPING_LITERAL;

self.visit_expr(slice);
self.visit_expr_context(ctx);
Expand Down Expand Up @@ -1239,7 +1239,7 @@ where
}
Expr::StringLiteral(ast::ExprStringLiteral { value, .. }) => {
if self.semantic.in_type_definition()
&& !self.semantic.in_literal()
&& !self.semantic.in_typing_literal()
&& !self.semantic.in_f_string()
{
self.deferred.string_type_definitions.push((
Expand Down
6 changes: 3 additions & 3 deletions crates/ruff_python_semantic/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1359,8 +1359,8 @@ impl<'a> SemanticModel<'a> {
}

/// Return `true` if the model is in a `typing::Literal` annotation.
pub const fn in_literal(&self) -> bool {
self.flags.intersects(SemanticModelFlags::LITERAL)
pub const fn in_typing_literal(&self) -> bool {
self.flags.intersects(SemanticModelFlags::TYPING_LITERAL)
}

/// Return `true` if the model is in a subscript expression.
Expand Down Expand Up @@ -1576,7 +1576,7 @@ bitflags! {
/// def f(x: Literal["A", "B", "C"]):
/// ...
/// ```
const LITERAL = 1 << 9;
const TYPING_LITERAL = 1 << 9;

/// The model is in a subscript expression.
///
Expand Down
Loading