(
vm: &VirtualMachine,
source_file: &SourceFile,
expression: ast::ExprTString,
)
| 923 | } |
| 924 | |
| 925 | pub(super) fn tstring_to_object( |
| 926 | vm: &VirtualMachine, |
| 927 | source_file: &SourceFile, |
| 928 | expression: ast::ExprTString, |
| 929 | ) -> PyObjectRef { |
| 930 | let ast::ExprTString { |
| 931 | range, |
| 932 | mut value, |
| 933 | node_index: _, |
| 934 | } = expression; |
| 935 | let default_tstring = ast::TString { |
| 936 | node_index: Default::default(), |
| 937 | range: Default::default(), |
| 938 | elements: Default::default(), |
| 939 | flags: ast::TStringFlags::empty(), |
| 940 | }; |
| 941 | let mut values = Vec::new(); |
| 942 | for i in 0..value.as_slice().len() { |
| 943 | let tstring = core::mem::replace(value.iter_mut().nth(i).unwrap(), default_tstring.clone()); |
| 944 | for element in ruff_fstring_element_into_iter(tstring.elements) { |
| 945 | values.push(ruff_tstring_element_to_template_str_part( |
| 946 | element, |
| 947 | source_file, |
| 948 | )); |
| 949 | } |
| 950 | } |
| 951 | let values = normalize_template_str_parts(values); |
| 952 | let c = TemplateStr { |
| 953 | range, |
| 954 | values: values.into_boxed_slice(), |
| 955 | }; |
| 956 | c.ast_to_object(vm, source_file) |
| 957 | } |
no test coverage detected