Enable auto-return-type involving Optional and Union annotations (#8885)

## Summary

Previously, this was only supported for Python 3.10 and later, since we
always use the PEP 604-style unions.
This commit is contained in:
Charlie Marsh 2023-11-28 18:35:55 -08:00 committed by GitHub
parent ec7456bac0
commit 6435e4e4aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 526 additions and 69 deletions

View file

@ -399,7 +399,7 @@ IpyHelpEndEscapeCommandStatement: ast::Stmt = {
_ => {
return Err(LexicalError {
error: LexicalErrorType::OtherError("only Name, Subscript and Attribute expressions are allowed in help end escape command".to_string()),
location: expr.range().start(),
location: expr.start(),
});
}
}
@ -1642,12 +1642,12 @@ FStringReplacementField: ast::Expr = {
} else {
format_spec.as_ref().map_or_else(
|| end_location - "}".text_len(),
|spec| spec.range().start() - ":".text_len(),
|spec| spec.start() - ":".text_len(),
)
};
ast::DebugText {
leading: source_code[TextRange::new(start_offset, value.range().start())].to_string(),
trailing: source_code[TextRange::new(value.range().end(), end_offset)].to_string(),
leading: source_code[TextRange::new(start_offset, value.start())].to_string(),
trailing: source_code[TextRange::new(value.end(), end_offset)].to_string(),
}
});
Ok(