Skip to content

Commit 3fc81ab

Browse files
committed
revert unnecessary changes
1 parent de6e9db commit 3fc81ab

File tree

5 files changed

+50
-52
lines changed

5 files changed

+50
-52
lines changed

crates/ty_python_semantic/src/place.rs

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ use crate::semantic_index::definition::{Definition, DefinitionState};
66
use crate::semantic_index::place::{PlaceExprRef, ScopedPlaceId};
77
use crate::semantic_index::scope::ScopeId;
88
use crate::semantic_index::{
9-
BindingWithConstraints, BindingWithConstraintsIterator, BoundnessAnalysis,
10-
ConsideredDefinitions, DeclarationsIterator, place_table,
9+
BindingWithConstraints, BindingWithConstraintsIterator, DeclarationsIterator, place_table,
1110
};
1211
use crate::semantic_index::{DeclarationWithConstraint, global_scope, use_def_map};
1312
use crate::types::{
@@ -1511,6 +1510,48 @@ impl RequiresExplicitReExport {
15111510
}
15121511
}
15131512

1513+
/// Specifies which definitions should be considered when looking up a place.
1514+
///
1515+
/// In the example below, the `EndOfScope` variant would consider the `x = 2` and `x = 3` definitions,
1516+
/// while the `AllReachable` variant would also consider the `x = 1` definition.
1517+
/// ```py
1518+
/// def _():
1519+
/// x = 1
1520+
///
1521+
/// x = 2
1522+
///
1523+
/// if flag():
1524+
/// x = 3
1525+
/// ```
1526+
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, salsa::Update)]
1527+
pub(crate) enum ConsideredDefinitions {
1528+
/// Consider only the definitions that are "live" at the end of the scope, i.e. those
1529+
/// that have not been shadowed or deleted.
1530+
EndOfScope,
1531+
/// Consider all definitions that are reachable from the start of the scope.
1532+
AllReachable,
1533+
}
1534+
1535+
/// Specifies how the boundness of a place should be determined.
1536+
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, salsa::Update)]
1537+
pub(crate) enum BoundnessAnalysis {
1538+
/// The place is always considered bound.
1539+
AssumeBound,
1540+
/// The boundness of the place is determined based on the visibility of the implicit
1541+
/// `unbound` binding. In the example below, when analyzing the visibility of the
1542+
/// `x = <unbound>` binding from the position of the end of the scope, it would be
1543+
/// `Truthiness::Ambiguous`, because it could either be visible or not, depending on the
1544+
/// `flag()` return value. This would result in a `Boundness::PossiblyUnbound` for `x`.
1545+
///
1546+
/// ```py
1547+
/// x = <unbound>
1548+
///
1549+
/// if flag():
1550+
/// x = 1
1551+
/// ```
1552+
BasedOnUnboundVisibility,
1553+
}
1554+
15141555
/// Computes a possibly-widened type `Unknown | T_inferred` from the inferred type `T_inferred`
15151556
/// of a symbol, unless the type is a known-instance type (e.g. `typing.Any`) or the symbol is
15161557
/// considered non-modifiable (e.g. when the symbol is `@Final`). We need this for public uses

crates/ty_python_semantic/src/semantic_index.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ use crate::semantic_index::scope::{
2626
NodeWithScopeKey, NodeWithScopeRef, Scope, ScopeId, ScopeKind, ScopeLaziness,
2727
};
2828
use crate::semantic_index::symbol::ScopedSymbolId;
29-
pub(crate) use crate::semantic_index::use_def::{BoundnessAnalysis, ConsideredDefinitions};
3029
use crate::semantic_index::use_def::{EnclosingSnapshotKey, ScopedEnclosingSnapshotId, UseDefMap};
3130
use crate::semantic_model::HasTrackedScope;
3231

crates/ty_python_semantic/src/semantic_index/use_def.rs

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ use ruff_index::{IndexVec, newtype_index};
244244
use rustc_hash::FxHashMap;
245245

246246
use crate::node_key::NodeKey;
247+
use crate::place::BoundnessAnalysis;
247248
use crate::semantic_index::ast_ids::ScopedUseId;
248249
use crate::semantic_index::definition::{Definition, DefinitionState};
249250
use crate::semantic_index::member::ScopedMemberId;
@@ -269,48 +270,6 @@ use crate::types::{IntersectionBuilder, Truthiness, Type, infer_narrowing_constr
269270

270271
mod place_state;
271272

272-
/// Specifies how the boundness of a place should be determined.
273-
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
274-
pub(crate) enum BoundnessAnalysis {
275-
/// The place is always considered bound.
276-
AssumeBound,
277-
/// The boundness of the place is determined based on the visibility of the implicit
278-
/// `unbound` binding. In the example below, when analyzing the visibility of the
279-
/// `x = <unbound>` binding from the position of the end of the scope, it would be
280-
/// `Truthiness::Ambiguous`, because it could either be visible or not, depending on the
281-
/// `flag()` return value. This would result in a `Boundness::PossiblyUnbound` for `x`.
282-
///
283-
/// ```py
284-
/// x = <unbound>
285-
///
286-
/// if flag():
287-
/// x = 1
288-
/// ```
289-
BasedOnUnboundVisibility,
290-
}
291-
292-
/// Specifies which definitions should be considered when looking up a place.
293-
///
294-
/// In the example below, the `EndOfScope` variant would consider the `x = 2` and `x = 3` definitions,
295-
/// while the `AllReachable` variant would also consider the `x = 1` definition.
296-
/// ```py
297-
/// def _():
298-
/// x = 1
299-
///
300-
/// x = 2
301-
///
302-
/// if flag():
303-
/// x = 3
304-
/// ```
305-
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, salsa::Update)]
306-
pub(crate) enum ConsideredDefinitions {
307-
/// Consider only the definitions that are "live" at the end of the scope, i.e. those
308-
/// that have not been shadowed or deleted.
309-
EndOfScope,
310-
/// Consider all definitions that are reachable from the start of the scope.
311-
AllReachable,
312-
}
313-
314273
/// Applicable definitions and constraints for every use of a name.
315274
#[derive(Debug, PartialEq, Eq, salsa::Update, get_size2::GetSize)]
316275
pub(crate) struct UseDefMap<'db> {

crates/ty_python_semantic/src/semantic_index/use_def/place_state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ impl EnclosingSnapshot {
206206
/// Live bindings for a single place at some point in control flow. Each live binding comes
207207
/// with a set of narrowing constraints and a reachability constraint.
208208
#[derive(Clone, Debug, Default, PartialEq, Eq, salsa::Update, get_size2::GetSize)]
209-
pub(crate) struct Bindings {
209+
pub(super) struct Bindings {
210210
/// The narrowing constraint applicable to the "unbound" binding, if we need access to it even
211211
/// when it's not visible. This happens in class scopes, where local name bindings are not visible
212212
/// to nested scopes, but we still need to know what narrowing constraints were applied to the

crates/ty_python_semantic/src/types/infer.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ use crate::module_resolver::{
6969
};
7070
use crate::node_key::NodeKey;
7171
use crate::place::{
72-
Boundness, LookupError, Place, PlaceAndQualifiers, builtins_module_scope, builtins_symbol,
73-
explicit_global_symbol, global_symbol, module_type_implicit_global_declaration,
74-
module_type_implicit_global_symbol, place, place_from_bindings, place_from_declarations,
75-
typing_extensions_symbol,
72+
Boundness, ConsideredDefinitions, LookupError, Place, PlaceAndQualifiers,
73+
builtins_module_scope, builtins_symbol, explicit_global_symbol, global_symbol,
74+
module_type_implicit_global_declaration, module_type_implicit_global_symbol, place,
75+
place_from_bindings, place_from_declarations, typing_extensions_symbol,
7676
};
7777
use crate::semantic_index::ast_ids::node_key::ExpressionNodeKey;
7878
use crate::semantic_index::ast_ids::{HasScopedUseId, ScopedUseId};
@@ -89,8 +89,7 @@ use crate::semantic_index::scope::{
8989
};
9090
use crate::semantic_index::symbol::ScopedSymbolId;
9191
use crate::semantic_index::{
92-
ApplicableConstraints, ConsideredDefinitions, EnclosingSnapshotResult, SemanticIndex,
93-
place_table, semantic_index,
92+
ApplicableConstraints, EnclosingSnapshotResult, SemanticIndex, place_table, semantic_index,
9493
};
9594
use crate::types::call::{Binding, Bindings, CallArguments, CallError, CallErrorKind};
9695
use crate::types::class::{CodeGeneratorKind, FieldKind, MetaclassErrorKind, MethodDecorator};

0 commit comments

Comments
 (0)