mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-28 15:33:50 +00:00
Move Literal
flag detection into recurse phase (#5768)
## Summary The AST pass is broken up into three phases: pre-visit (which includes analysis), recurse (visit all members), and post-visit (clean-up). We're not supposed to edit semantic model flags in the pre-visit phase, but it looks like we were for literal detection. This didn't matter in practice, but I'm looking into some AST refactors for which this _does_ cause issues. No behavior changes expected. ## Test Plan Good test coverage on these.
This commit is contained in:
parent
7c32e98d10
commit
3dc73395ea
3 changed files with 40 additions and 16 deletions
|
@ -182,6 +182,11 @@ pub fn is_pep_593_generic_type(call_path: &[&str]) -> bool {
|
|||
matches!(call_path, ["typing" | "typing_extensions", "Annotated"])
|
||||
}
|
||||
|
||||
/// Returns `true` if a call path is `Literal`.
|
||||
pub fn is_standard_library_literal(call_path: &[&str]) -> bool {
|
||||
matches!(call_path, ["typing" | "typing_extensions", "Literal"])
|
||||
}
|
||||
|
||||
/// Returns `true` if a name matches that of a generic from the Python standard library (e.g.
|
||||
/// `list` or `Set`).
|
||||
///
|
||||
|
@ -267,6 +272,11 @@ pub fn is_pep_593_generic_member(member: &str) -> bool {
|
|||
matches!(member, "Annotated")
|
||||
}
|
||||
|
||||
/// Returns `true` if a name matches that of the `Literal` generic.
|
||||
pub fn is_literal_member(member: &str) -> bool {
|
||||
matches!(member, "Literal")
|
||||
}
|
||||
|
||||
/// Returns `true` if a call path represents that of an immutable, non-generic type from the Python
|
||||
/// standard library (e.g. `int` or `str`).
|
||||
pub fn is_immutable_non_generic_type(call_path: &[&str]) -> bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue