Remove unused flags and functions from the semantic model (#14318)
This commit is contained in:
@@ -1742,12 +1742,6 @@ impl<'a> SemanticModel<'a> {
|
||||
.intersects(SemanticModelFlags::NAMED_EXPRESSION_ASSIGNMENT)
|
||||
}
|
||||
|
||||
/// Return `true` if the model is in a comprehension assignment (e.g., `_ for x in y`).
|
||||
pub const fn in_comprehension_assignment(&self) -> bool {
|
||||
self.flags
|
||||
.intersects(SemanticModelFlags::COMPREHENSION_ASSIGNMENT)
|
||||
}
|
||||
|
||||
/// Return `true` if the model is visiting the r.h.s. of an `__all__` definition
|
||||
/// (e.g. `"foo"` in `__all__ = ["foo"]`)
|
||||
pub const fn in_dunder_all_definition(&self) -> bool {
|
||||
@@ -2141,14 +2135,6 @@ bitflags! {
|
||||
/// ```
|
||||
const NAMED_EXPRESSION_ASSIGNMENT = 1 << 19;
|
||||
|
||||
/// The model is in a comprehension variable assignment.
|
||||
///
|
||||
/// For example, the model could be visiting `x` in:
|
||||
/// ```python
|
||||
/// [_ for x in range(10)]
|
||||
/// ```
|
||||
const COMPREHENSION_ASSIGNMENT = 1 << 20;
|
||||
|
||||
/// The model is in a docstring as described in [PEP 257].
|
||||
///
|
||||
/// For example, the model could be visiting either the module, class,
|
||||
@@ -2168,7 +2154,7 @@ bitflags! {
|
||||
/// ```
|
||||
///
|
||||
/// [PEP 257]: https://peps.python.org/pep-0257/#what-is-a-docstring
|
||||
const PEP_257_DOCSTRING = 1 << 21;
|
||||
const PEP_257_DOCSTRING = 1 << 20;
|
||||
|
||||
/// The model is visiting the r.h.s. of a module-level `__all__` definition.
|
||||
///
|
||||
@@ -2180,7 +2166,7 @@ bitflags! {
|
||||
/// __all__ = ("bar",)
|
||||
/// __all__ += ("baz,")
|
||||
/// ```
|
||||
const DUNDER_ALL_DEFINITION = 1 << 22;
|
||||
const DUNDER_ALL_DEFINITION = 1 << 21;
|
||||
|
||||
/// The model is in an f-string replacement field.
|
||||
///
|
||||
@@ -2189,7 +2175,7 @@ bitflags! {
|
||||
/// ```python
|
||||
/// f"first {x} second {y}"
|
||||
/// ```
|
||||
const F_STRING_REPLACEMENT_FIELD = 1 << 23;
|
||||
const F_STRING_REPLACEMENT_FIELD = 1 << 22;
|
||||
|
||||
/// The model is visiting the bases tuple of a class.
|
||||
///
|
||||
@@ -2199,11 +2185,11 @@ bitflags! {
|
||||
/// class Baz(Foo, Bar):
|
||||
/// pass
|
||||
/// ```
|
||||
const CLASS_BASE = 1 << 24;
|
||||
const CLASS_BASE = 1 << 23;
|
||||
|
||||
/// The model is visiting a class base that was initially deferred
|
||||
/// while traversing the AST. (This only happens in stub files.)
|
||||
const DEFERRED_CLASS_BASE = 1 << 25;
|
||||
const DEFERRED_CLASS_BASE = 1 << 24;
|
||||
|
||||
/// The model is in an attribute docstring.
|
||||
///
|
||||
@@ -2228,7 +2214,7 @@ bitflags! {
|
||||
/// static-analysis tools.
|
||||
///
|
||||
/// [PEP 257]: https://peps.python.org/pep-0257/#what-is-a-docstring
|
||||
const ATTRIBUTE_DOCSTRING = 1 << 26;
|
||||
const ATTRIBUTE_DOCSTRING = 1 << 25;
|
||||
|
||||
/// The context is in any type annotation.
|
||||
const ANNOTATION = Self::TYPING_ONLY_ANNOTATION.bits() | Self::RUNTIME_EVALUATED_ANNOTATION.bits() | Self::RUNTIME_REQUIRED_ANNOTATION.bits();
|
||||
|
||||
@@ -63,28 +63,10 @@ impl ResolvedReference {
|
||||
.intersects(SemanticModelFlags::RUNTIME_EVALUATED_ANNOTATION)
|
||||
}
|
||||
|
||||
/// Return `true` if the context is in a "simple" string type definition.
|
||||
pub const fn in_simple_string_type_definition(&self) -> bool {
|
||||
/// Return `true` if the context is in a string type definition.
|
||||
pub const fn in_string_type_definition(&self) -> bool {
|
||||
self.flags
|
||||
.intersects(SemanticModelFlags::SIMPLE_STRING_TYPE_DEFINITION)
|
||||
}
|
||||
|
||||
/// Return `true` if the context is in a "complex" string type definition.
|
||||
pub const fn in_complex_string_type_definition(&self) -> bool {
|
||||
self.flags
|
||||
.intersects(SemanticModelFlags::COMPLEX_STRING_TYPE_DEFINITION)
|
||||
}
|
||||
|
||||
/// Return `true` if the context is in a `__future__` type definition.
|
||||
pub const fn in_future_type_definition(&self) -> bool {
|
||||
self.flags
|
||||
.intersects(SemanticModelFlags::FUTURE_TYPE_DEFINITION)
|
||||
}
|
||||
|
||||
/// Return `true` if the context is in any kind of deferred type definition.
|
||||
pub const fn in_deferred_type_definition(&self) -> bool {
|
||||
self.flags
|
||||
.intersects(SemanticModelFlags::DEFERRED_TYPE_DEFINITION)
|
||||
.intersects(SemanticModelFlags::STRING_TYPE_DEFINITION)
|
||||
}
|
||||
|
||||
/// Return `true` if the context is in any kind of type definition.
|
||||
|
||||
Reference in New Issue
Block a user