Skip to content

Commit

Permalink
Temporarily patch typeshed to avoid cycles
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp committed Dec 17, 2024
1 parent b349b04 commit 0e49dc7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
18 changes: 1 addition & 17 deletions crates/red_knot_python_semantic/src/types/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,28 +158,12 @@ pub(crate) fn infer_deferred_types<'db>(
TypeInferenceBuilder::new(db, InferenceRegion::Deferred(definition), index).finish()
}

/// TODO: get rid of this? if not, at least build a cycle-recovery-variant of [`infer_expression_types`],
/// which is only used in static visibility analysis.
pub(crate) fn infer_expression_types_cycle_recovery<'db>(
db: &'db dyn Db,
_cycle: &salsa::Cycle,
expr: Expression<'db>,
) -> TypeInference<'db> {
tracing::trace!("infer_expression_types_cycle_recovery");
let mut inference = TypeInference::empty(expr.scope(db));
inference.expressions.insert(
expr.node_ref(db).scoped_expression_id(db, expr.scope(db)),
Type::Unknown,
);
inference
}

/// Infer all types for an [`Expression`] (including sub-expressions).
/// Use rarely; only for cases where we'd otherwise risk double-inferring an expression: RHS of an
/// assignment, which might be unpacking/multi-target and thus part of multiple definitions, or a
/// type narrowing guard expression (e.g. if statement test node).
#[allow(unused)]
#[salsa::tracked(return_ref, recovery_fn=infer_expression_types_cycle_recovery)]
#[salsa::tracked(return_ref)]
pub(crate) fn infer_expression_types<'db>(
db: &'db dyn Db,
expression: Expression<'db>,
Expand Down
4 changes: 2 additions & 2 deletions crates/red_knot_vendored/vendor/typeshed/stdlib/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1931,8 +1931,8 @@ class OSError(Exception):

EnvironmentError = OSError
IOError = OSError
if sys.platform == "win32":
WindowsError = OSError
# if sys.platform == "win32":
# WindowsError = OSError

class ArithmeticError(Exception): ...
class AssertionError(Exception): ...
Expand Down

0 comments on commit 0e49dc7

Please sign in to comment.