Visitar URL original
[ty] Respect `@no_type_check` when combined with other decorators by charliermarsh · Pull Request #23177 · astral-sh/ruff · GitHub
Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Avoid panic
  • Loading branch information
charliermarsh committed Feb 9, 2026
commit f18b3648d787192ea48a299dca4964cc47058b78
9 changes: 4 additions & 5 deletions crates/ty_python_semantic/src/types/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use ruff_db::{
};
use ruff_text_size::{Ranged, TextRange};

use super::{TypeCheckDiagnostics, infer_definition_types};
use super::{Type, TypeCheckDiagnostics, infer_definition_types};

use crate::diagnostic::DiagnosticGuard;
use crate::lint::LintSource;
Expand Down Expand Up @@ -194,15 +194,14 @@ impl<'db, 'ast> InferContext<'db, 'ast> {
// if any is decorated with `@no_type_check`. We use the undecorated type
// rather than the binding type because other decorators (e.g. unknown ones)
// may transform the function type into a non-`FunctionLiteral`.
// `undecorated_type()` can be `None` during cycle recovery.
index
.ancestor_scopes(scope_id)
.filter_map(|(_, scope)| scope.node().as_function())
.map(|node| {
.filter_map(|node| {
infer_definition_types(self.db, index.expect_single_definition(node))
.undecorated_type()
.expect("function should have undecorated type")
.as_function_literal()
.expect("undecorated function type should be a FunctionLiteral")
.and_then(Type::as_function_literal)
})
.any(|function_ty| {
function_ty.has_known_decorator(self.db, FunctionDecorators::NO_TYPE_CHECK)
Expand Down