mirror of https://github.com/astral-sh/ruff
Reorder
This commit is contained in:
parent
bcec2f0c4c
commit
b6d41b9560
File diff suppressed because it is too large
Load Diff
|
|
@ -1,14 +1,6 @@
|
||||||
---
|
---
|
||||||
source: crates/ruff/src/rules/flake8_future_annotations/mod.rs
|
source: crates/ruff/src/rules/flake8_future_annotations/mod.rs
|
||||||
---
|
---
|
||||||
no_future_import_uses_union.py:2:13: FA102 Missing `from __future__ import annotations`, but uses PEP 604 union
|
|
||||||
|
|
|
||||||
1 | def main() -> None:
|
|
||||||
2 | a_list: list[str] | None = []
|
|
||||||
| ^^^^^^^^^^^^^^^^ FA102
|
|
||||||
3 | a_list.append("hello")
|
|
||||||
|
|
|
||||||
|
|
||||||
no_future_import_uses_union.py:2:13: FA102 Missing `from __future__ import annotations`, but uses PEP 585 collection
|
no_future_import_uses_union.py:2:13: FA102 Missing `from __future__ import annotations`, but uses PEP 585 collection
|
||||||
|
|
|
|
||||||
1 | def main() -> None:
|
1 | def main() -> None:
|
||||||
|
|
@ -17,11 +9,12 @@ no_future_import_uses_union.py:2:13: FA102 Missing `from __future__ import annot
|
||||||
3 | a_list.append("hello")
|
3 | a_list.append("hello")
|
||||||
|
|
|
|
||||||
|
|
||||||
no_future_import_uses_union.py:6:14: FA102 Missing `from __future__ import annotations`, but uses PEP 604 union
|
no_future_import_uses_union.py:2:13: FA102 Missing `from __future__ import annotations`, but uses PEP 604 union
|
||||||
|
|
|
|
||||||
6 | def hello(y: dict[str, int] | None) -> None:
|
1 | def main() -> None:
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^ FA102
|
2 | a_list: list[str] | None = []
|
||||||
7 | del y
|
| ^^^^^^^^^^^^^^^^ FA102
|
||||||
|
3 | a_list.append("hello")
|
||||||
|
|
|
|
||||||
|
|
||||||
no_future_import_uses_union.py:6:14: FA102 Missing `from __future__ import annotations`, but uses PEP 585 collection
|
no_future_import_uses_union.py:6:14: FA102 Missing `from __future__ import annotations`, but uses PEP 585 collection
|
||||||
|
|
@ -31,4 +24,11 @@ no_future_import_uses_union.py:6:14: FA102 Missing `from __future__ import annot
|
||||||
7 | del y
|
7 | del y
|
||||||
|
|
|
|
||||||
|
|
||||||
|
no_future_import_uses_union.py:6:14: FA102 Missing `from __future__ import annotations`, but uses PEP 604 union
|
||||||
|
|
|
||||||
|
6 | def hello(y: dict[str, int] | None) -> None:
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^ FA102
|
||||||
|
7 | del y
|
||||||
|
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,11 @@ pub(crate) fn lambda_assignment(
|
||||||
// See: https://github.com/astral-sh/ruff/issues/3046
|
// See: https://github.com/astral-sh/ruff/issues/3046
|
||||||
// See: https://github.com/astral-sh/ruff/issues/5421
|
// See: https://github.com/astral-sh/ruff/issues/5421
|
||||||
if (annotation.is_some() && checker.semantic().scope().kind.is_class())
|
if (annotation.is_some() && checker.semantic().scope().kind.is_class())
|
||||||
|| checker.semantic().scope().has(id)
|
|| checker
|
||||||
|
.semantic()
|
||||||
|
.scope()
|
||||||
|
.get_all(id)
|
||||||
|
.any(|binding_id| checker.semantic().binding(binding_id).kind.is_annotation())
|
||||||
{
|
{
|
||||||
diagnostic.set_fix(Fix::manual(Edit::range_replacement(indented, stmt.range())));
|
diagnostic.set_fix(Fix::manual(Edit::range_replacement(indented, stmt.range())));
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -139,9 +143,9 @@ fn extract_types(annotation: &Expr, semantic: &SemanticModel) -> Option<(Vec<Exp
|
||||||
let Expr::Tuple(ast::ExprTuple { elts, .. }) = slice.as_ref() else {
|
let Expr::Tuple(ast::ExprTuple { elts, .. }) = slice.as_ref() else {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
if elts.len() != 2 {
|
let [param_types, return_type] = elts.as_slice() else {
|
||||||
return None;
|
return None;
|
||||||
}
|
};
|
||||||
|
|
||||||
if !semantic
|
if !semantic
|
||||||
.resolve_call_path(value)
|
.resolve_call_path(value)
|
||||||
|
|
@ -155,7 +159,7 @@ fn extract_types(annotation: &Expr, semantic: &SemanticModel) -> Option<(Vec<Exp
|
||||||
|
|
||||||
// The first argument to `Callable` must be a list of types, parameter
|
// The first argument to `Callable` must be a list of types, parameter
|
||||||
// specification, or ellipsis.
|
// specification, or ellipsis.
|
||||||
let args = match &elts[0] {
|
let params = match param_types {
|
||||||
Expr::List(ast::ExprList { elts, .. }) => elts.clone(),
|
Expr::List(ast::ExprList { elts, .. }) => elts.clone(),
|
||||||
Expr::Constant(ast::ExprConstant {
|
Expr::Constant(ast::ExprConstant {
|
||||||
value: Constant::Ellipsis,
|
value: Constant::Ellipsis,
|
||||||
|
|
@ -165,9 +169,9 @@ fn extract_types(annotation: &Expr, semantic: &SemanticModel) -> Option<(Vec<Exp
|
||||||
};
|
};
|
||||||
|
|
||||||
// The second argument to `Callable` must be a type.
|
// The second argument to `Callable` must be a type.
|
||||||
let return_type = elts[1].clone();
|
let return_type = return_type.clone();
|
||||||
|
|
||||||
Some((args, return_type))
|
Some((params, return_type))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn function(
|
fn function(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue