mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-07 21:25:08 +00:00
[flake8-use-pathlib
] Fix PTH123
false positive when open
is passed a file descriptor from a function call (#17705)
## Summary Includes minor changes to the semantic type inference to help detect the return type of function call. Fixes #17691 ## Test Plan Snapshot tests
This commit is contained in:
parent
93d6a3567b
commit
8c68d30c3a
3 changed files with 58 additions and 5 deletions
|
@ -639,6 +639,18 @@ pub fn check_type<T: TypeChecker>(binding: &Binding, semantic: &SemanticModel) -
|
|||
_ => false,
|
||||
},
|
||||
|
||||
BindingKind::FunctionDefinition(_) => match binding.statement(semantic) {
|
||||
// ```python
|
||||
// def foo() -> int:
|
||||
// ...
|
||||
// ```
|
||||
Some(Stmt::FunctionDef(ast::StmtFunctionDef { returns, .. })) => returns
|
||||
.as_ref()
|
||||
.is_some_and(|return_ann| T::match_annotation(return_ann, semantic)),
|
||||
|
||||
_ => false,
|
||||
},
|
||||
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue