From c5eb0f3b2fe813261f31114178ca4c8aec0dedcc Mon Sep 17 00:00:00 2001 From: Glyphack Date: Wed, 25 Oct 2023 21:12:37 +0200 Subject: [PATCH 1/6] (parser) type var --- ...hot_test_lexer_and_errors@class.py-10.snap | 95 +++++++++++++++ ...hot_test_lexer_and_errors@class.py-11.snap | 59 +++++++++ ...hot_test_lexer_and_errors@class.py-12.snap | 73 +++++++++++ ...hot_test_lexer_and_errors@class.py-13.snap | 87 +++++++++++++ ...hot_test_lexer_and_errors@class.py-14.snap | 115 ++++++++++++++++++ ...hot_test_lexer_and_errors@class.py-15.snap | 59 +++++++++ ...hot_test_lexer_and_errors@class.py-16.snap | 73 +++++++++++ ...hot_test_lexer_and_errors@class.py-17.snap | 87 +++++++++++++ ...hot_test_lexer_and_errors@class.py-18.snap | 115 ++++++++++++++++++ ...hot_test_lexer_and_errors@class.py-19.snap | 93 ++++++++++++++ ...shot_test_lexer_and_errors@class.py-2.snap | 59 +++++++++ ...hot_test_lexer_and_errors@class.py-20.snap | 113 +++++++++++++++++ ...hot_test_lexer_and_errors@class.py-21.snap | 113 +++++++++++++++++ ...shot_test_lexer_and_errors@class.py-3.snap | 67 ++++++++++ ...shot_test_lexer_and_errors@class.py-4.snap | 93 ++++++++++++++ ...shot_test_lexer_and_errors@class.py-5.snap | 81 ++++++++++++ ...shot_test_lexer_and_errors@class.py-6.snap | 53 ++++++++ ...shot_test_lexer_and_errors@class.py-7.snap | 53 ++++++++ ...shot_test_lexer_and_errors@class.py-8.snap | 67 ++++++++++ ...shot_test_lexer_and_errors@class.py-9.snap | 67 ++++++++++ ...apshot_test_lexer_and_errors@class.py.snap | 33 +++++ parser/src/parser/ast.rs | 45 +++++++ parser/src/parser/parser.rs | 115 ++++++++++++++---- ..._parser__tests__class_def_statement-2.snap | 1 + ..._parser__tests__class_def_statement-3.snap | 1 + ..._parser__tests__class_def_statement-4.snap | 1 + ..._parser__tests__class_def_statement-5.snap | 1 + ..._parser__tests__class_def_statement-6.snap | 1 + ...r__parser__tests__class_def_statement.snap | 1 + ...er__parser__parser__tests__comment-10.snap | 1 + ...ser__parser__parser__tests__comment-8.snap | 1 + ...ser__parser__parser__tests__comment-9.snap | 1 + ..._parser__tests__complete@functions.py.snap | 3 + ...ser__tests__complete@input_program.py.snap | 14 +++ ...ests__complete@separate_statements.py.snap | 2 + ...__parser__tests__ellipsis_statement-2.snap | 1 + ...er__parser__tests__ellipsis_statement.snap | 1 + ...parser__tests__one_liners@class.py-10.snap | 77 ++++++++++++ ...parser__tests__one_liners@class.py-11.snap | 46 +++++++ ...parser__tests__one_liners@class.py-12.snap | 56 +++++++++ ...parser__tests__one_liners@class.py-13.snap | 66 ++++++++++ ...parser__tests__one_liners@class.py-14.snap | 86 +++++++++++++ ...parser__tests__one_liners@class.py-15.snap | 46 +++++++ ...parser__tests__one_liners@class.py-16.snap | 56 +++++++++ ...parser__tests__one_liners@class.py-17.snap | 66 ++++++++++ ...parser__tests__one_liners@class.py-18.snap | 86 +++++++++++++ ...parser__tests__one_liners@class.py-19.snap | 65 ++++++++++ ..._parser__tests__one_liners@class.py-2.snap | 36 ++++++ ...parser__tests__one_liners@class.py-20.snap | 75 ++++++++++++ ...parser__tests__one_liners@class.py-21.snap | 75 ++++++++++++ ..._parser__tests__one_liners@class.py-3.snap | 55 +++++++++ ..._parser__tests__one_liners@class.py-4.snap | 80 ++++++++++++ ..._parser__tests__one_liners@class.py-5.snap | 64 ++++++++++ ..._parser__tests__one_liners@class.py-6.snap | 46 +++++++ ..._parser__tests__one_liners@class.py-7.snap | 47 +++++++ ..._parser__tests__one_liners@class.py-8.snap | 57 +++++++++ ..._parser__tests__one_liners@class.py-9.snap | 57 +++++++++ ...r__parser__tests__one_liners@class.py.snap | 36 ++++++ ..._tests__one_liners@function_def.py-10.snap | 1 + ..._tests__one_liners@function_def.py-11.snap | 1 + ...__tests__one_liners@function_def.py-2.snap | 1 + ...__tests__one_liners@function_def.py-3.snap | 1 + ...__tests__one_liners@function_def.py-4.snap | 1 + ...__tests__one_liners@function_def.py-5.snap | 1 + ...__tests__one_liners@function_def.py-6.snap | 1 + ...__tests__one_liners@function_def.py-7.snap | 1 + ...__tests__one_liners@function_def.py-8.snap | 1 + ...__tests__one_liners@function_def.py-9.snap | 1 + ...er__tests__one_liners@function_def.py.snap | 1 + parser/test_data/inputs/one_liners/class.py | 43 +++++++ 70 files changed, 3150 insertions(+), 27 deletions(-) create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-10.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-11.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-12.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-13.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-14.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-15.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-16.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-17.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-18.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-19.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-2.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-20.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-21.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-3.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-4.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-5.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-6.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-7.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-8.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-9.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-10.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-11.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-12.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-13.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-14.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-15.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-16.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-17.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-18.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-19.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-2.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-20.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-21.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-3.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-4.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-5.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-6.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-7.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-8.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-9.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py.snap create mode 100644 parser/test_data/inputs/one_liners/class.py diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-10.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-10.snap new file mode 100644 index 00000000..afc619e2 --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-10.snap @@ -0,0 +1,95 @@ +--- +source: parser/src/lexer/lexer.rs +description: "class a[T: U, V: W]: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +[ + Token { + kind: Class, + value: None, + start: 0, + end: 5, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 6, + end: 7, + }, + Token { + kind: LeftBrace, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Identifier, + value: Str( + "T", + ), + start: 8, + end: 9, + }, + Token { + kind: Colon, + value: None, + start: 9, + end: 10, + }, + Token { + kind: Identifier, + value: Str( + "U", + ), + start: 11, + end: 12, + }, + Token { + kind: Comma, + value: None, + start: 12, + end: 13, + }, + Token { + kind: Identifier, + value: Str( + "V", + ), + start: 14, + end: 15, + }, + Token { + kind: Colon, + value: None, + start: 15, + end: 16, + }, + Token { + kind: Identifier, + value: Str( + "W", + ), + start: 17, + end: 18, + }, + Token { + kind: RightBrace, + value: None, + start: 18, + end: 19, + }, + Token { + kind: Colon, + value: None, + start: 19, + end: 20, + }, + Token { + kind: Pass, + value: None, + start: 21, + end: 25, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-11.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-11.snap new file mode 100644 index 00000000..743f1c92 --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-11.snap @@ -0,0 +1,59 @@ +--- +source: parser/src/lexer/lexer.rs +description: "class a[*T]: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +[ + Token { + kind: Class, + value: None, + start: 0, + end: 5, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 6, + end: 7, + }, + Token { + kind: LeftBrace, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Mul, + value: None, + start: 8, + end: 9, + }, + Token { + kind: Identifier, + value: Str( + "T", + ), + start: 9, + end: 10, + }, + Token { + kind: RightBrace, + value: None, + start: 10, + end: 11, + }, + Token { + kind: Colon, + value: None, + start: 11, + end: 12, + }, + Token { + kind: Pass, + value: None, + start: 13, + end: 17, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-12.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-12.snap new file mode 100644 index 00000000..3a9c0a05 --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-12.snap @@ -0,0 +1,73 @@ +--- +source: parser/src/lexer/lexer.rs +description: "class a[T, *U]: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +[ + Token { + kind: Class, + value: None, + start: 0, + end: 5, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 6, + end: 7, + }, + Token { + kind: LeftBrace, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Identifier, + value: Str( + "T", + ), + start: 8, + end: 9, + }, + Token { + kind: Comma, + value: None, + start: 9, + end: 10, + }, + Token { + kind: Mul, + value: None, + start: 11, + end: 12, + }, + Token { + kind: Identifier, + value: Str( + "U", + ), + start: 12, + end: 13, + }, + Token { + kind: RightBrace, + value: None, + start: 13, + end: 14, + }, + Token { + kind: Colon, + value: None, + start: 14, + end: 15, + }, + Token { + kind: Pass, + value: None, + start: 16, + end: 20, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-13.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-13.snap new file mode 100644 index 00000000..d2f4bc16 --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-13.snap @@ -0,0 +1,87 @@ +--- +source: parser/src/lexer/lexer.rs +description: "class a[T: U, *V]: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +[ + Token { + kind: Class, + value: None, + start: 0, + end: 5, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 6, + end: 7, + }, + Token { + kind: LeftBrace, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Identifier, + value: Str( + "T", + ), + start: 8, + end: 9, + }, + Token { + kind: Colon, + value: None, + start: 9, + end: 10, + }, + Token { + kind: Identifier, + value: Str( + "U", + ), + start: 11, + end: 12, + }, + Token { + kind: Comma, + value: None, + start: 12, + end: 13, + }, + Token { + kind: Mul, + value: None, + start: 14, + end: 15, + }, + Token { + kind: Identifier, + value: Str( + "V", + ), + start: 15, + end: 16, + }, + Token { + kind: RightBrace, + value: None, + start: 16, + end: 17, + }, + Token { + kind: Colon, + value: None, + start: 17, + end: 18, + }, + Token { + kind: Pass, + value: None, + start: 19, + end: 23, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-14.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-14.snap new file mode 100644 index 00000000..56bba3ce --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-14.snap @@ -0,0 +1,115 @@ +--- +source: parser/src/lexer/lexer.rs +description: "class a[T: U, V: W, *X]: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +[ + Token { + kind: Class, + value: None, + start: 0, + end: 5, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 6, + end: 7, + }, + Token { + kind: LeftBrace, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Identifier, + value: Str( + "T", + ), + start: 8, + end: 9, + }, + Token { + kind: Colon, + value: None, + start: 9, + end: 10, + }, + Token { + kind: Identifier, + value: Str( + "U", + ), + start: 11, + end: 12, + }, + Token { + kind: Comma, + value: None, + start: 12, + end: 13, + }, + Token { + kind: Identifier, + value: Str( + "V", + ), + start: 14, + end: 15, + }, + Token { + kind: Colon, + value: None, + start: 15, + end: 16, + }, + Token { + kind: Identifier, + value: Str( + "W", + ), + start: 17, + end: 18, + }, + Token { + kind: Comma, + value: None, + start: 18, + end: 19, + }, + Token { + kind: Mul, + value: None, + start: 20, + end: 21, + }, + Token { + kind: Identifier, + value: Str( + "X", + ), + start: 21, + end: 22, + }, + Token { + kind: RightBrace, + value: None, + start: 22, + end: 23, + }, + Token { + kind: Colon, + value: None, + start: 23, + end: 24, + }, + Token { + kind: Pass, + value: None, + start: 25, + end: 29, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-15.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-15.snap new file mode 100644 index 00000000..acaf589b --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-15.snap @@ -0,0 +1,59 @@ +--- +source: parser/src/lexer/lexer.rs +description: "class a[**T]: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +[ + Token { + kind: Class, + value: None, + start: 0, + end: 5, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 6, + end: 7, + }, + Token { + kind: LeftBrace, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Pow, + value: None, + start: 8, + end: 10, + }, + Token { + kind: Identifier, + value: Str( + "T", + ), + start: 10, + end: 11, + }, + Token { + kind: RightBrace, + value: None, + start: 11, + end: 12, + }, + Token { + kind: Colon, + value: None, + start: 12, + end: 13, + }, + Token { + kind: Pass, + value: None, + start: 14, + end: 18, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-16.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-16.snap new file mode 100644 index 00000000..f6c70d8e --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-16.snap @@ -0,0 +1,73 @@ +--- +source: parser/src/lexer/lexer.rs +description: "class a[T, **U]: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +[ + Token { + kind: Class, + value: None, + start: 0, + end: 5, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 6, + end: 7, + }, + Token { + kind: LeftBrace, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Identifier, + value: Str( + "T", + ), + start: 8, + end: 9, + }, + Token { + kind: Comma, + value: None, + start: 9, + end: 10, + }, + Token { + kind: Pow, + value: None, + start: 11, + end: 13, + }, + Token { + kind: Identifier, + value: Str( + "U", + ), + start: 13, + end: 14, + }, + Token { + kind: RightBrace, + value: None, + start: 14, + end: 15, + }, + Token { + kind: Colon, + value: None, + start: 15, + end: 16, + }, + Token { + kind: Pass, + value: None, + start: 17, + end: 21, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-17.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-17.snap new file mode 100644 index 00000000..15a779bc --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-17.snap @@ -0,0 +1,87 @@ +--- +source: parser/src/lexer/lexer.rs +description: "class a[T: U, **V]: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +[ + Token { + kind: Class, + value: None, + start: 0, + end: 5, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 6, + end: 7, + }, + Token { + kind: LeftBrace, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Identifier, + value: Str( + "T", + ), + start: 8, + end: 9, + }, + Token { + kind: Colon, + value: None, + start: 9, + end: 10, + }, + Token { + kind: Identifier, + value: Str( + "U", + ), + start: 11, + end: 12, + }, + Token { + kind: Comma, + value: None, + start: 12, + end: 13, + }, + Token { + kind: Pow, + value: None, + start: 14, + end: 16, + }, + Token { + kind: Identifier, + value: Str( + "V", + ), + start: 16, + end: 17, + }, + Token { + kind: RightBrace, + value: None, + start: 17, + end: 18, + }, + Token { + kind: Colon, + value: None, + start: 18, + end: 19, + }, + Token { + kind: Pass, + value: None, + start: 20, + end: 24, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-18.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-18.snap new file mode 100644 index 00000000..ecc625ae --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-18.snap @@ -0,0 +1,115 @@ +--- +source: parser/src/lexer/lexer.rs +description: "class a[T: U, V: W, **X]: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +[ + Token { + kind: Class, + value: None, + start: 0, + end: 5, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 6, + end: 7, + }, + Token { + kind: LeftBrace, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Identifier, + value: Str( + "T", + ), + start: 8, + end: 9, + }, + Token { + kind: Colon, + value: None, + start: 9, + end: 10, + }, + Token { + kind: Identifier, + value: Str( + "U", + ), + start: 11, + end: 12, + }, + Token { + kind: Comma, + value: None, + start: 12, + end: 13, + }, + Token { + kind: Identifier, + value: Str( + "V", + ), + start: 14, + end: 15, + }, + Token { + kind: Colon, + value: None, + start: 15, + end: 16, + }, + Token { + kind: Identifier, + value: Str( + "W", + ), + start: 17, + end: 18, + }, + Token { + kind: Comma, + value: None, + start: 18, + end: 19, + }, + Token { + kind: Pow, + value: None, + start: 20, + end: 22, + }, + Token { + kind: Identifier, + value: Str( + "X", + ), + start: 22, + end: 23, + }, + Token { + kind: RightBrace, + value: None, + start: 23, + end: 24, + }, + Token { + kind: Colon, + value: None, + start: 24, + end: 25, + }, + Token { + kind: Pass, + value: None, + start: 26, + end: 30, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-19.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-19.snap new file mode 100644 index 00000000..fa1cbc0a --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-19.snap @@ -0,0 +1,93 @@ +--- +source: parser/src/lexer/lexer.rs +description: "class a[T, *U, **V]: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +[ + Token { + kind: Class, + value: None, + start: 0, + end: 5, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 6, + end: 7, + }, + Token { + kind: LeftBrace, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Identifier, + value: Str( + "T", + ), + start: 8, + end: 9, + }, + Token { + kind: Comma, + value: None, + start: 9, + end: 10, + }, + Token { + kind: Mul, + value: None, + start: 11, + end: 12, + }, + Token { + kind: Identifier, + value: Str( + "U", + ), + start: 12, + end: 13, + }, + Token { + kind: Comma, + value: None, + start: 13, + end: 14, + }, + Token { + kind: Pow, + value: None, + start: 15, + end: 17, + }, + Token { + kind: Identifier, + value: Str( + "V", + ), + start: 17, + end: 18, + }, + Token { + kind: RightBrace, + value: None, + start: 18, + end: 19, + }, + Token { + kind: Colon, + value: None, + start: 19, + end: 20, + }, + Token { + kind: Pass, + value: None, + start: 21, + end: 25, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-2.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-2.snap new file mode 100644 index 00000000..00f7139f --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-2.snap @@ -0,0 +1,59 @@ +--- +source: parser/src/lexer/lexer.rs +description: "class a():\n pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +[ + Token { + kind: Class, + value: None, + start: 0, + end: 5, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 6, + end: 7, + }, + Token { + kind: LeftParen, + value: None, + start: 7, + end: 8, + }, + Token { + kind: RightParen, + value: None, + start: 8, + end: 9, + }, + Token { + kind: Colon, + value: None, + start: 9, + end: 10, + }, + Token { + kind: NewLine, + value: None, + start: 10, + end: 11, + }, + Token { + kind: Indent, + value: Indent( + 1, + ), + start: 11, + end: 15, + }, + Token { + kind: Pass, + value: None, + start: 15, + end: 19, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-20.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-20.snap new file mode 100644 index 00000000..f2ad90ad --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-20.snap @@ -0,0 +1,113 @@ +--- +source: parser/src/lexer/lexer.rs +description: "class a[T: U, *V, **W]: pass\n" +input_file: parser/test_data/inputs/one_liners/class.py +--- +[ + Token { + kind: Class, + value: None, + start: 0, + end: 5, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 6, + end: 7, + }, + Token { + kind: LeftBrace, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Identifier, + value: Str( + "T", + ), + start: 8, + end: 9, + }, + Token { + kind: Colon, + value: None, + start: 9, + end: 10, + }, + Token { + kind: Identifier, + value: Str( + "U", + ), + start: 11, + end: 12, + }, + Token { + kind: Comma, + value: None, + start: 12, + end: 13, + }, + Token { + kind: Mul, + value: None, + start: 14, + end: 15, + }, + Token { + kind: Identifier, + value: Str( + "V", + ), + start: 15, + end: 16, + }, + Token { + kind: Comma, + value: None, + start: 16, + end: 17, + }, + Token { + kind: Pow, + value: None, + start: 18, + end: 20, + }, + Token { + kind: Identifier, + value: Str( + "W", + ), + start: 20, + end: 21, + }, + Token { + kind: RightBrace, + value: None, + start: 21, + end: 22, + }, + Token { + kind: Colon, + value: None, + start: 22, + end: 23, + }, + Token { + kind: Pass, + value: None, + start: 24, + end: 28, + }, + Token { + kind: NewLine, + value: None, + start: 28, + end: 29, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-21.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-21.snap new file mode 100644 index 00000000..f2ad90ad --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-21.snap @@ -0,0 +1,113 @@ +--- +source: parser/src/lexer/lexer.rs +description: "class a[T: U, *V, **W]: pass\n" +input_file: parser/test_data/inputs/one_liners/class.py +--- +[ + Token { + kind: Class, + value: None, + start: 0, + end: 5, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 6, + end: 7, + }, + Token { + kind: LeftBrace, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Identifier, + value: Str( + "T", + ), + start: 8, + end: 9, + }, + Token { + kind: Colon, + value: None, + start: 9, + end: 10, + }, + Token { + kind: Identifier, + value: Str( + "U", + ), + start: 11, + end: 12, + }, + Token { + kind: Comma, + value: None, + start: 12, + end: 13, + }, + Token { + kind: Mul, + value: None, + start: 14, + end: 15, + }, + Token { + kind: Identifier, + value: Str( + "V", + ), + start: 15, + end: 16, + }, + Token { + kind: Comma, + value: None, + start: 16, + end: 17, + }, + Token { + kind: Pow, + value: None, + start: 18, + end: 20, + }, + Token { + kind: Identifier, + value: Str( + "W", + ), + start: 20, + end: 21, + }, + Token { + kind: RightBrace, + value: None, + start: 21, + end: 22, + }, + Token { + kind: Colon, + value: None, + start: 22, + end: 23, + }, + Token { + kind: Pass, + value: None, + start: 24, + end: 28, + }, + Token { + kind: NewLine, + value: None, + start: 28, + end: 29, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-3.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-3.snap new file mode 100644 index 00000000..70f81394 --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-3.snap @@ -0,0 +1,67 @@ +--- +source: parser/src/lexer/lexer.rs +description: "class a(b, c): pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +[ + Token { + kind: Class, + value: None, + start: 0, + end: 5, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 6, + end: 7, + }, + Token { + kind: LeftParen, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Identifier, + value: Str( + "b", + ), + start: 8, + end: 9, + }, + Token { + kind: Comma, + value: None, + start: 9, + end: 10, + }, + Token { + kind: Identifier, + value: Str( + "c", + ), + start: 11, + end: 12, + }, + Token { + kind: RightParen, + value: None, + start: 12, + end: 13, + }, + Token { + kind: Colon, + value: None, + start: 13, + end: 14, + }, + Token { + kind: Pass, + value: None, + start: 15, + end: 19, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-4.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-4.snap new file mode 100644 index 00000000..7d548322 --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-4.snap @@ -0,0 +1,93 @@ +--- +source: parser/src/lexer/lexer.rs +description: "class a(b, *c, **d): pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +[ + Token { + kind: Class, + value: None, + start: 0, + end: 5, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 6, + end: 7, + }, + Token { + kind: LeftParen, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Identifier, + value: Str( + "b", + ), + start: 8, + end: 9, + }, + Token { + kind: Comma, + value: None, + start: 9, + end: 10, + }, + Token { + kind: Mul, + value: None, + start: 11, + end: 12, + }, + Token { + kind: Identifier, + value: Str( + "c", + ), + start: 12, + end: 13, + }, + Token { + kind: Comma, + value: None, + start: 13, + end: 14, + }, + Token { + kind: Pow, + value: None, + start: 15, + end: 17, + }, + Token { + kind: Identifier, + value: Str( + "d", + ), + start: 17, + end: 18, + }, + Token { + kind: RightParen, + value: None, + start: 18, + end: 19, + }, + Token { + kind: Colon, + value: None, + start: 19, + end: 20, + }, + Token { + kind: Pass, + value: None, + start: 21, + end: 25, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-5.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-5.snap new file mode 100644 index 00000000..4f75409d --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-5.snap @@ -0,0 +1,81 @@ +--- +source: parser/src/lexer/lexer.rs +description: "class a(b,\nc,\nd): pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +[ + Token { + kind: Class, + value: None, + start: 0, + end: 5, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 6, + end: 7, + }, + Token { + kind: LeftParen, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Identifier, + value: Str( + "b", + ), + start: 8, + end: 9, + }, + Token { + kind: Comma, + value: None, + start: 9, + end: 10, + }, + Token { + kind: Identifier, + value: Str( + "c", + ), + start: 11, + end: 12, + }, + Token { + kind: Comma, + value: None, + start: 12, + end: 13, + }, + Token { + kind: Identifier, + value: Str( + "d", + ), + start: 14, + end: 15, + }, + Token { + kind: RightParen, + value: None, + start: 15, + end: 16, + }, + Token { + kind: Colon, + value: None, + start: 16, + end: 17, + }, + Token { + kind: Pass, + value: None, + start: 18, + end: 22, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-6.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-6.snap new file mode 100644 index 00000000..35da4820 --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-6.snap @@ -0,0 +1,53 @@ +--- +source: parser/src/lexer/lexer.rs +description: "@decor\nclass a: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +[ + Token { + kind: MatrixMul, + value: None, + start: 0, + end: 1, + }, + Token { + kind: Identifier, + value: Str( + "decor", + ), + start: 1, + end: 6, + }, + Token { + kind: NewLine, + value: None, + start: 6, + end: 7, + }, + Token { + kind: Class, + value: None, + start: 7, + end: 12, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 13, + end: 14, + }, + Token { + kind: Colon, + value: None, + start: 14, + end: 15, + }, + Token { + kind: Pass, + value: None, + start: 16, + end: 20, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-7.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-7.snap new file mode 100644 index 00000000..1c76ee7e --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-7.snap @@ -0,0 +1,53 @@ +--- +source: parser/src/lexer/lexer.rs +description: "class a[T]: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +[ + Token { + kind: Class, + value: None, + start: 0, + end: 5, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 6, + end: 7, + }, + Token { + kind: LeftBrace, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Identifier, + value: Str( + "T", + ), + start: 8, + end: 9, + }, + Token { + kind: RightBrace, + value: None, + start: 9, + end: 10, + }, + Token { + kind: Colon, + value: None, + start: 10, + end: 11, + }, + Token { + kind: Pass, + value: None, + start: 12, + end: 16, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-8.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-8.snap new file mode 100644 index 00000000..5903ec6e --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-8.snap @@ -0,0 +1,67 @@ +--- +source: parser/src/lexer/lexer.rs +description: "class a[T, U]: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +[ + Token { + kind: Class, + value: None, + start: 0, + end: 5, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 6, + end: 7, + }, + Token { + kind: LeftBrace, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Identifier, + value: Str( + "T", + ), + start: 8, + end: 9, + }, + Token { + kind: Comma, + value: None, + start: 9, + end: 10, + }, + Token { + kind: Identifier, + value: Str( + "U", + ), + start: 11, + end: 12, + }, + Token { + kind: RightBrace, + value: None, + start: 12, + end: 13, + }, + Token { + kind: Colon, + value: None, + start: 13, + end: 14, + }, + Token { + kind: Pass, + value: None, + start: 15, + end: 19, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-9.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-9.snap new file mode 100644 index 00000000..21be8b9b --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py-9.snap @@ -0,0 +1,67 @@ +--- +source: parser/src/lexer/lexer.rs +description: "class a[T: U]: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +[ + Token { + kind: Class, + value: None, + start: 0, + end: 5, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 6, + end: 7, + }, + Token { + kind: LeftBrace, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Identifier, + value: Str( + "T", + ), + start: 8, + end: 9, + }, + Token { + kind: Colon, + value: None, + start: 9, + end: 10, + }, + Token { + kind: Identifier, + value: Str( + "U", + ), + start: 11, + end: 12, + }, + Token { + kind: RightBrace, + value: None, + start: 12, + end: 13, + }, + Token { + kind: Colon, + value: None, + start: 13, + end: 14, + }, + Token { + kind: Pass, + value: None, + start: 15, + end: 19, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py.snap new file mode 100644 index 00000000..f343fac0 --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@class.py.snap @@ -0,0 +1,33 @@ +--- +source: parser/src/lexer/lexer.rs +description: "class a: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +[ + Token { + kind: Class, + value: None, + start: 0, + end: 5, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 6, + end: 7, + }, + Token { + kind: Colon, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Pass, + value: None, + start: 9, + end: 13, + }, +] diff --git a/parser/src/parser/ast.rs b/parser/src/parser/ast.rs index 3c1019b3..c91fb36c 100644 --- a/parser/src/parser/ast.rs +++ b/parser/src/parser/ast.rs @@ -69,6 +69,7 @@ pub enum Statement { AsyncFunctionDef(AsyncFunctionDef), ClassDef(ClassDef), Match(Match), + TypeAlias(TypeAlias), } impl GetNode for Statement { @@ -101,6 +102,7 @@ impl GetNode for Statement { Statement::AsyncFunctionDef(s) => s.node, Statement::ClassDef(s) => s.node, Statement::Match(s) => s.node, + Statement::TypeAlias(s) => s.node, } } } @@ -764,6 +766,7 @@ pub struct FunctionDef { pub decorator_list: Vec, pub returns: Option>, pub type_comment: Option, + pub type_params: Vec, } // https://docs.python.org/3/library/ast.html#ast.AsyncFunctionDef @@ -776,6 +779,7 @@ pub struct AsyncFunctionDef { pub decorator_list: Vec, pub returns: Option>, pub type_comment: Option, + pub type_params: Vec, } // https://docs.python.org/3/library/ast.html#ast.ClassDef @@ -787,6 +791,7 @@ pub struct ClassDef { pub keywords: Vec, pub body: Vec, pub decorator_list: Vec, + pub type_params: Vec, } // https://docs.python.org/3/library/ast.html#ast.Match @@ -847,3 +852,43 @@ pub struct MatchClass { pub kwd_attrs: Vec, pub kwd_patterns: Vec, } + +// https://docs.python.org/3/library/ast.html#ast-type-params +#[derive(Debug, Clone)] +pub enum TypeParam { + TypeVar(TypeVar), + ParamSpec(ParamSpec), + TypeVarTuple(TypeVarTuple), +} + + +// https://docs.python.org/3/library/ast.html#ast.TypeVar +#[derive(Debug, Clone)] +pub struct TypeVar { + pub node: Node, + pub name: String, + pub bound: Option, +} + +// https://docs.python.org/3/library/ast.html#ast.ParamSpec +#[derive(Debug, Clone)] +pub struct ParamSpec { + pub node: Node, + pub name: String, +} + +// https://docs.python.org/3/library/ast.html#ast.TypeVarTuple +#[derive(Debug, Clone)] +pub struct TypeVarTuple { + pub node: Node, + pub name: String, +} + +// https://docs.python.org/3/library/ast.html#ast.TypeAlias +#[derive(Debug, Clone)] +pub struct TypeAlias { + pub node: Node, + pub name: String, + pub type_params: Vec, + pub value: Box, +} diff --git a/parser/src/parser/parser.rs b/parser/src/parser/parser.rs index 693306c7..9788592c 100644 --- a/parser/src/parser/parser.rs +++ b/parser/src/parser/parser.rs @@ -694,6 +694,11 @@ impl Parser { self.expect(Kind::Def)?; let name = self.cur_token().value.to_string(); self.expect(Kind::Identifier)?; + let type_params = if self.at(Kind::LeftBrace) { + self.parse_type_parameters()? + } else { + vec![] + }; self.expect(Kind::LeftParen)?; let args = self.parse_parameters(false)?; self.expect(Kind::RightParen)?; @@ -715,6 +720,7 @@ impl Parser { decorator_list: decorators, returns: return_type, type_comment: None, + type_params, })) } else { Ok(Statement::FunctionDef(FunctionDef { @@ -723,10 +729,10 @@ impl Parser { args, body, decorator_list: decorators, - // TODO: return type returns: return_type, // TODO: type comment type_comment: None, + type_params, })) } } @@ -757,6 +763,11 @@ impl Parser { self.expect(Kind::Class)?; let name = self.cur_token().value.to_string(); self.expect(Kind::Identifier)?; + let type_params = if self.at(Kind::LeftBrace) { + self.parse_type_parameters()? + } else { + vec![] + }; let (bases, keywords) = if self.eat(Kind::LeftParen) { let (bases, keywords) = self.parse_argument_list()?; self.expect(Kind::RightParen)?; @@ -774,6 +785,7 @@ impl Parser { keywords, body, decorator_list: decorators, + type_params, })) } @@ -3058,6 +3070,81 @@ impl Parser { fn get_span_on_line(&self, start: usize, end: usize) -> (usize, usize) { (start, end) } + + // https://docs.python.org/3/reference/compound_stmts.html#type-parameter-lists + fn parse_type_parameters(&mut self) -> Result, ParsingError> { + let node = self.start_node(); + self.expect(Kind::LeftBrace)?; + let mut type_params = vec![]; + while !self.eat(Kind::RightBrace) { + match self.cur_kind() { + Kind::Identifier => { + let node = self.start_node(); + let name = self.cur_token().value.to_string(); + self.bump(Kind::Identifier); + let bound = if self.eat(Kind::Colon) { + Some(self.parse_expression_2()?) + } else { + None + }; + type_params.push(TypeParam::TypeVar(TypeVar { + node: self.finish_node(node), + name, + bound, + })); + } + Kind::Pow => { + // param spec + let node = self.start_node(); + self.bump(Kind::Pow); + let name = self.cur_token().value.to_string(); + self.bump(Kind::Identifier); + type_params.push(TypeParam::ParamSpec(ParamSpec { + node: self.finish_node(node), + name, + })); + }, + Kind::Mul => { + // type var tuple + let node = self.start_node(); + self.bump(Kind::Mul); + let name = self.cur_token().value.to_string(); + self.bump(Kind::Identifier); + type_params.push(TypeParam::TypeVarTuple(TypeVarTuple { + node: self.finish_node(node), + name, + })); + }, + _ => { + return Err(self.unexpected_token_new( + node, + vec![ + Kind::Identifier, + Kind::Pow, + Kind::Mul, + Kind::RightBracket, + ], + "", + )); + } + } + if !self.at(Kind::RightBrace) { + self.expect(Kind::Comma)?; + } + } + if type_params.len() == 0 { + return Err(self.unexpected_token_new( + node, + vec![ + Kind::Identifier, + Kind::Pow, + Kind::Mul, + ], + "Type parameter is empty", + )); + } + Ok(type_params) + } } #[cfg(test)] @@ -3664,32 +3751,6 @@ except *Exception as e: } } - #[test] - fn test_class_def_statement() { - for test_case in &[ - "class a: pass", - "class a(): - pass", - "class a(b, c): pass", - "class a(b, *c, **d): pass", - "class a(b, - c, - d): pass", - "@decor -class a: pass", - ] { - let mut parser = Parser::new(test_case.to_string(), String::from("")); - let program = parser.parse(); - - insta::with_settings!({ - description => test_case.to_string(), // the template source code - omit_expression => true // do not include the default expression - }, { - assert_debug_snapshot!(program); - }); - } - } - #[test] fn test_complete() { glob!("../../test_data", "inputs/*.py", |path| { diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__class_def_statement-2.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__class_def_statement-2.snap index 72d44892..e74da5f8 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__class_def_statement-2.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__class_def_statement-2.snap @@ -28,6 +28,7 @@ Module { ), ], decorator_list: [], + type_params: [], }, ), ], diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__class_def_statement-3.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__class_def_statement-3.snap index 41de1574..1fc17fd0 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__class_def_statement-3.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__class_def_statement-3.snap @@ -47,6 +47,7 @@ Module { ), ], decorator_list: [], + type_params: [], }, ), ], diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__class_def_statement-4.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__class_def_statement-4.snap index e29eb852..390e0f7d 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__class_def_statement-4.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__class_def_statement-4.snap @@ -72,6 +72,7 @@ Module { ), ], decorator_list: [], + type_params: [], }, ), ], diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__class_def_statement-5.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__class_def_statement-5.snap index ab9e3b78..2d03252b 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__class_def_statement-5.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__class_def_statement-5.snap @@ -56,6 +56,7 @@ Module { ), ], decorator_list: [], + type_params: [], }, ), ], diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__class_def_statement-6.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__class_def_statement-6.snap index 8aae0057..6c1e4f30 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__class_def_statement-6.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__class_def_statement-6.snap @@ -38,6 +38,7 @@ Module { }, ), ], + type_params: [], }, ), ], diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__class_def_statement.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__class_def_statement.snap index 00c4a7cb..01417dd1 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__class_def_statement.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__class_def_statement.snap @@ -28,6 +28,7 @@ Module { ), ], decorator_list: [], + type_params: [], }, ), ], diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__comment-10.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__comment-10.snap index 0e67e3e9..aaffebea 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__comment-10.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__comment-10.snap @@ -44,6 +44,7 @@ Module { decorator_list: [], returns: None, type_comment: None, + type_params: [], }, ), ], diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__comment-8.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__comment-8.snap index d273c3f0..2d2748e6 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__comment-8.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__comment-8.snap @@ -44,6 +44,7 @@ Module { decorator_list: [], returns: None, type_comment: None, + type_params: [], }, ), ], diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__comment-9.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__comment-9.snap index f84db2ae..dcccf24e 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__comment-9.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__comment-9.snap @@ -44,6 +44,7 @@ Module { decorator_list: [], returns: None, type_comment: None, + type_params: [], }, ), ], diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@functions.py.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@functions.py.snap index 74bdc5a2..7c5748a2 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@functions.py.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@functions.py.snap @@ -334,6 +334,7 @@ Module { decorator_list: [], returns: None, type_comment: None, + type_params: [], }, ), FunctionDef( @@ -664,6 +665,7 @@ Module { ), ), type_comment: None, + type_params: [], }, ), FunctionDef( @@ -1544,6 +1546,7 @@ Module { decorator_list: [], returns: None, type_comment: None, + type_params: [], }, ), ], diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@input_program.py.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@input_program.py.snap index 8c49ec62..28cb79b3 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@input_program.py.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@input_program.py.snap @@ -334,6 +334,7 @@ Module { decorator_list: [], returns: None, type_comment: None, + type_params: [], }, ), FunctionDef( @@ -759,6 +760,7 @@ Module { ), ), type_comment: None, + type_params: [], }, ), FunctionDef( @@ -1185,6 +1187,7 @@ Module { decorator_list: [], returns: None, type_comment: None, + type_params: [], }, ), FunctionDef( @@ -1546,6 +1549,7 @@ Module { decorator_list: [], returns: None, type_comment: None, + type_params: [], }, ), FunctionDef( @@ -1886,6 +1890,7 @@ Module { decorator_list: [], returns: None, type_comment: None, + type_params: [], }, ), FunctionDef( @@ -4695,6 +4700,7 @@ Module { ), ), type_comment: None, + type_params: [], }, ), FunctionDef( @@ -6295,6 +6301,7 @@ Module { ), ), type_comment: None, + type_params: [], }, ), FunctionDef( @@ -7032,6 +7039,7 @@ Module { ], returns: None, type_comment: None, + type_params: [], }, ), FunctionDef( @@ -7950,6 +7958,7 @@ Module { ], returns: None, type_comment: None, + type_params: [], }, ), FunctionDef( @@ -9869,6 +9878,7 @@ Module { ), ), type_comment: None, + type_params: [], }, ), FunctionDef( @@ -11293,6 +11303,7 @@ Module { decorator_list: [], returns: None, type_comment: None, + type_params: [], }, ), FunctionDef( @@ -12453,6 +12464,7 @@ Module { ], returns: None, type_comment: None, + type_params: [], }, ), FunctionDef( @@ -13068,6 +13080,7 @@ Module { decorator_list: [], returns: None, type_comment: None, + type_params: [], }, ), FunctionDef( @@ -14309,6 +14322,7 @@ Module { decorator_list: [], returns: None, type_comment: None, + type_params: [], }, ), ], diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@separate_statements.py.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@separate_statements.py.snap index 51a098e5..6adadd9b 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@separate_statements.py.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@separate_statements.py.snap @@ -127,6 +127,7 @@ Module { decorator_list: [], returns: None, type_comment: None, + type_params: [], }, ), FunctionDef( @@ -247,6 +248,7 @@ Module { decorator_list: [], returns: None, type_comment: None, + type_params: [], }, ), AssignStatement( diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__ellipsis_statement-2.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__ellipsis_statement-2.snap index 3fba2a8d..4efe3687 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__ellipsis_statement-2.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__ellipsis_statement-2.snap @@ -44,6 +44,7 @@ Module { decorator_list: [], returns: None, type_comment: None, + type_params: [], }, ), ], diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__ellipsis_statement.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__ellipsis_statement.snap index 535b50e7..77c47a77 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__ellipsis_statement.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__ellipsis_statement.snap @@ -44,6 +44,7 @@ Module { decorator_list: [], returns: None, type_comment: None, + type_params: [], }, ), ], diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-10.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-10.snap new file mode 100644 index 00000000..0891e125 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-10.snap @@ -0,0 +1,77 @@ +--- +source: parser/src/parser/parser.rs +description: "class a[T: U, V: W]: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +Module { + node: Node { + start: 0, + end: 25, + }, + body: [ + ClassDef( + ClassDef { + node: Node { + start: 0, + end: 25, + }, + name: "a", + bases: [], + keywords: [], + body: [ + Pass( + Pass { + node: Node { + start: 21, + end: 25, + }, + }, + ), + ], + decorator_list: [], + type_params: [ + TypeVar( + TypeVar { + node: Node { + start: 8, + end: 12, + }, + name: "T", + bound: Some( + Name( + Name { + node: Node { + start: 11, + end: 12, + }, + id: "U", + }, + ), + ), + }, + ), + TypeVar( + TypeVar { + node: Node { + start: 14, + end: 18, + }, + name: "V", + bound: Some( + Name( + Name { + node: Node { + start: 17, + end: 18, + }, + id: "W", + }, + ), + ), + }, + ), + ], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-11.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-11.snap new file mode 100644 index 00000000..d9086261 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-11.snap @@ -0,0 +1,46 @@ +--- +source: parser/src/parser/parser.rs +description: "class a[*T]: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +Module { + node: Node { + start: 0, + end: 17, + }, + body: [ + ClassDef( + ClassDef { + node: Node { + start: 0, + end: 17, + }, + name: "a", + bases: [], + keywords: [], + body: [ + Pass( + Pass { + node: Node { + start: 13, + end: 17, + }, + }, + ), + ], + decorator_list: [], + type_params: [ + TypeVarTuple( + TypeVarTuple { + node: Node { + start: 8, + end: 10, + }, + name: "T", + }, + ), + ], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-12.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-12.snap new file mode 100644 index 00000000..c78dd9d7 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-12.snap @@ -0,0 +1,56 @@ +--- +source: parser/src/parser/parser.rs +description: "class a[T, *U]: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +Module { + node: Node { + start: 0, + end: 20, + }, + body: [ + ClassDef( + ClassDef { + node: Node { + start: 0, + end: 20, + }, + name: "a", + bases: [], + keywords: [], + body: [ + Pass( + Pass { + node: Node { + start: 16, + end: 20, + }, + }, + ), + ], + decorator_list: [], + type_params: [ + TypeVar( + TypeVar { + node: Node { + start: 8, + end: 9, + }, + name: "T", + bound: None, + }, + ), + TypeVarTuple( + TypeVarTuple { + node: Node { + start: 11, + end: 13, + }, + name: "U", + }, + ), + ], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-13.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-13.snap new file mode 100644 index 00000000..81dba543 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-13.snap @@ -0,0 +1,66 @@ +--- +source: parser/src/parser/parser.rs +description: "class a[T: U, *V]: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +Module { + node: Node { + start: 0, + end: 23, + }, + body: [ + ClassDef( + ClassDef { + node: Node { + start: 0, + end: 23, + }, + name: "a", + bases: [], + keywords: [], + body: [ + Pass( + Pass { + node: Node { + start: 19, + end: 23, + }, + }, + ), + ], + decorator_list: [], + type_params: [ + TypeVar( + TypeVar { + node: Node { + start: 8, + end: 12, + }, + name: "T", + bound: Some( + Name( + Name { + node: Node { + start: 11, + end: 12, + }, + id: "U", + }, + ), + ), + }, + ), + TypeVarTuple( + TypeVarTuple { + node: Node { + start: 14, + end: 16, + }, + name: "V", + }, + ), + ], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-14.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-14.snap new file mode 100644 index 00000000..1434fc11 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-14.snap @@ -0,0 +1,86 @@ +--- +source: parser/src/parser/parser.rs +description: "class a[T: U, V: W, *X]: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +Module { + node: Node { + start: 0, + end: 29, + }, + body: [ + ClassDef( + ClassDef { + node: Node { + start: 0, + end: 29, + }, + name: "a", + bases: [], + keywords: [], + body: [ + Pass( + Pass { + node: Node { + start: 25, + end: 29, + }, + }, + ), + ], + decorator_list: [], + type_params: [ + TypeVar( + TypeVar { + node: Node { + start: 8, + end: 12, + }, + name: "T", + bound: Some( + Name( + Name { + node: Node { + start: 11, + end: 12, + }, + id: "U", + }, + ), + ), + }, + ), + TypeVar( + TypeVar { + node: Node { + start: 14, + end: 18, + }, + name: "V", + bound: Some( + Name( + Name { + node: Node { + start: 17, + end: 18, + }, + id: "W", + }, + ), + ), + }, + ), + TypeVarTuple( + TypeVarTuple { + node: Node { + start: 20, + end: 22, + }, + name: "X", + }, + ), + ], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-15.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-15.snap new file mode 100644 index 00000000..3571b55e --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-15.snap @@ -0,0 +1,46 @@ +--- +source: parser/src/parser/parser.rs +description: "class a[**T]: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +Module { + node: Node { + start: 0, + end: 18, + }, + body: [ + ClassDef( + ClassDef { + node: Node { + start: 0, + end: 18, + }, + name: "a", + bases: [], + keywords: [], + body: [ + Pass( + Pass { + node: Node { + start: 14, + end: 18, + }, + }, + ), + ], + decorator_list: [], + type_params: [ + ParamSpec( + ParamSpec { + node: Node { + start: 8, + end: 11, + }, + name: "T", + }, + ), + ], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-16.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-16.snap new file mode 100644 index 00000000..b163782a --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-16.snap @@ -0,0 +1,56 @@ +--- +source: parser/src/parser/parser.rs +description: "class a[T, **U]: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +Module { + node: Node { + start: 0, + end: 21, + }, + body: [ + ClassDef( + ClassDef { + node: Node { + start: 0, + end: 21, + }, + name: "a", + bases: [], + keywords: [], + body: [ + Pass( + Pass { + node: Node { + start: 17, + end: 21, + }, + }, + ), + ], + decorator_list: [], + type_params: [ + TypeVar( + TypeVar { + node: Node { + start: 8, + end: 9, + }, + name: "T", + bound: None, + }, + ), + ParamSpec( + ParamSpec { + node: Node { + start: 11, + end: 14, + }, + name: "U", + }, + ), + ], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-17.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-17.snap new file mode 100644 index 00000000..c14e019f --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-17.snap @@ -0,0 +1,66 @@ +--- +source: parser/src/parser/parser.rs +description: "class a[T: U, **V]: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +Module { + node: Node { + start: 0, + end: 24, + }, + body: [ + ClassDef( + ClassDef { + node: Node { + start: 0, + end: 24, + }, + name: "a", + bases: [], + keywords: [], + body: [ + Pass( + Pass { + node: Node { + start: 20, + end: 24, + }, + }, + ), + ], + decorator_list: [], + type_params: [ + TypeVar( + TypeVar { + node: Node { + start: 8, + end: 12, + }, + name: "T", + bound: Some( + Name( + Name { + node: Node { + start: 11, + end: 12, + }, + id: "U", + }, + ), + ), + }, + ), + ParamSpec( + ParamSpec { + node: Node { + start: 14, + end: 17, + }, + name: "V", + }, + ), + ], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-18.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-18.snap new file mode 100644 index 00000000..260f4282 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-18.snap @@ -0,0 +1,86 @@ +--- +source: parser/src/parser/parser.rs +description: "class a[T: U, V: W, **X]: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +Module { + node: Node { + start: 0, + end: 30, + }, + body: [ + ClassDef( + ClassDef { + node: Node { + start: 0, + end: 30, + }, + name: "a", + bases: [], + keywords: [], + body: [ + Pass( + Pass { + node: Node { + start: 26, + end: 30, + }, + }, + ), + ], + decorator_list: [], + type_params: [ + TypeVar( + TypeVar { + node: Node { + start: 8, + end: 12, + }, + name: "T", + bound: Some( + Name( + Name { + node: Node { + start: 11, + end: 12, + }, + id: "U", + }, + ), + ), + }, + ), + TypeVar( + TypeVar { + node: Node { + start: 14, + end: 18, + }, + name: "V", + bound: Some( + Name( + Name { + node: Node { + start: 17, + end: 18, + }, + id: "W", + }, + ), + ), + }, + ), + ParamSpec( + ParamSpec { + node: Node { + start: 20, + end: 23, + }, + name: "X", + }, + ), + ], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-19.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-19.snap new file mode 100644 index 00000000..b3283cbd --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-19.snap @@ -0,0 +1,65 @@ +--- +source: parser/src/parser/parser.rs +description: "class a[T, *U, **V]: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +Module { + node: Node { + start: 0, + end: 25, + }, + body: [ + ClassDef( + ClassDef { + node: Node { + start: 0, + end: 25, + }, + name: "a", + bases: [], + keywords: [], + body: [ + Pass( + Pass { + node: Node { + start: 21, + end: 25, + }, + }, + ), + ], + decorator_list: [], + type_params: [ + TypeVar( + TypeVar { + node: Node { + start: 8, + end: 9, + }, + name: "T", + bound: None, + }, + ), + TypeVarTuple( + TypeVarTuple { + node: Node { + start: 11, + end: 13, + }, + name: "U", + }, + ), + ParamSpec( + ParamSpec { + node: Node { + start: 15, + end: 18, + }, + name: "V", + }, + ), + ], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-2.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-2.snap new file mode 100644 index 00000000..352d3186 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-2.snap @@ -0,0 +1,36 @@ +--- +source: parser/src/parser/parser.rs +description: "class a():\n pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +Module { + node: Node { + start: 0, + end: 19, + }, + body: [ + ClassDef( + ClassDef { + node: Node { + start: 0, + end: 19, + }, + name: "a", + bases: [], + keywords: [], + body: [ + Pass( + Pass { + node: Node { + start: 15, + end: 19, + }, + }, + ), + ], + decorator_list: [], + type_params: [], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-20.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-20.snap new file mode 100644 index 00000000..d8403215 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-20.snap @@ -0,0 +1,75 @@ +--- +source: parser/src/parser/parser.rs +description: "class a[T: U, *V, **W]: pass\n" +input_file: parser/test_data/inputs/one_liners/class.py +--- +Module { + node: Node { + start: 0, + end: 29, + }, + body: [ + ClassDef( + ClassDef { + node: Node { + start: 0, + end: 29, + }, + name: "a", + bases: [], + keywords: [], + body: [ + Pass( + Pass { + node: Node { + start: 24, + end: 28, + }, + }, + ), + ], + decorator_list: [], + type_params: [ + TypeVar( + TypeVar { + node: Node { + start: 8, + end: 12, + }, + name: "T", + bound: Some( + Name( + Name { + node: Node { + start: 11, + end: 12, + }, + id: "U", + }, + ), + ), + }, + ), + TypeVarTuple( + TypeVarTuple { + node: Node { + start: 14, + end: 16, + }, + name: "V", + }, + ), + ParamSpec( + ParamSpec { + node: Node { + start: 18, + end: 21, + }, + name: "W", + }, + ), + ], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-21.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-21.snap new file mode 100644 index 00000000..d8403215 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-21.snap @@ -0,0 +1,75 @@ +--- +source: parser/src/parser/parser.rs +description: "class a[T: U, *V, **W]: pass\n" +input_file: parser/test_data/inputs/one_liners/class.py +--- +Module { + node: Node { + start: 0, + end: 29, + }, + body: [ + ClassDef( + ClassDef { + node: Node { + start: 0, + end: 29, + }, + name: "a", + bases: [], + keywords: [], + body: [ + Pass( + Pass { + node: Node { + start: 24, + end: 28, + }, + }, + ), + ], + decorator_list: [], + type_params: [ + TypeVar( + TypeVar { + node: Node { + start: 8, + end: 12, + }, + name: "T", + bound: Some( + Name( + Name { + node: Node { + start: 11, + end: 12, + }, + id: "U", + }, + ), + ), + }, + ), + TypeVarTuple( + TypeVarTuple { + node: Node { + start: 14, + end: 16, + }, + name: "V", + }, + ), + ParamSpec( + ParamSpec { + node: Node { + start: 18, + end: 21, + }, + name: "W", + }, + ), + ], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-3.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-3.snap new file mode 100644 index 00000000..7cf5be5c --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-3.snap @@ -0,0 +1,55 @@ +--- +source: parser/src/parser/parser.rs +description: "class a(b, c): pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +Module { + node: Node { + start: 0, + end: 19, + }, + body: [ + ClassDef( + ClassDef { + node: Node { + start: 0, + end: 19, + }, + name: "a", + bases: [ + Name( + Name { + node: Node { + start: 8, + end: 9, + }, + id: "b", + }, + ), + Name( + Name { + node: Node { + start: 11, + end: 12, + }, + id: "c", + }, + ), + ], + keywords: [], + body: [ + Pass( + Pass { + node: Node { + start: 15, + end: 19, + }, + }, + ), + ], + decorator_list: [], + type_params: [], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-4.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-4.snap new file mode 100644 index 00000000..f4536a7b --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-4.snap @@ -0,0 +1,80 @@ +--- +source: parser/src/parser/parser.rs +description: "class a(b, *c, **d): pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +Module { + node: Node { + start: 0, + end: 25, + }, + body: [ + ClassDef( + ClassDef { + node: Node { + start: 0, + end: 25, + }, + name: "a", + bases: [ + Name( + Name { + node: Node { + start: 8, + end: 9, + }, + id: "b", + }, + ), + Starred( + Starred { + node: Node { + start: 11, + end: 12, + }, + value: Name( + Name { + node: Node { + start: 12, + end: 13, + }, + id: "c", + }, + ), + }, + ), + ], + keywords: [ + Keyword { + node: Node { + start: 15, + end: 17, + }, + arg: None, + value: Name( + Name { + node: Node { + start: 17, + end: 18, + }, + id: "d", + }, + ), + }, + ], + body: [ + Pass( + Pass { + node: Node { + start: 21, + end: 25, + }, + }, + ), + ], + decorator_list: [], + type_params: [], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-5.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-5.snap new file mode 100644 index 00000000..3bd9f86a --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-5.snap @@ -0,0 +1,64 @@ +--- +source: parser/src/parser/parser.rs +description: "class a(b,\nc,\nd): pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +Module { + node: Node { + start: 0, + end: 22, + }, + body: [ + ClassDef( + ClassDef { + node: Node { + start: 0, + end: 22, + }, + name: "a", + bases: [ + Name( + Name { + node: Node { + start: 8, + end: 9, + }, + id: "b", + }, + ), + Name( + Name { + node: Node { + start: 11, + end: 12, + }, + id: "c", + }, + ), + Name( + Name { + node: Node { + start: 14, + end: 15, + }, + id: "d", + }, + ), + ], + keywords: [], + body: [ + Pass( + Pass { + node: Node { + start: 18, + end: 22, + }, + }, + ), + ], + decorator_list: [], + type_params: [], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-6.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-6.snap new file mode 100644 index 00000000..c50343f8 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-6.snap @@ -0,0 +1,46 @@ +--- +source: parser/src/parser/parser.rs +description: "@decor\nclass a: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +Module { + node: Node { + start: 0, + end: 20, + }, + body: [ + ClassDef( + ClassDef { + node: Node { + start: 7, + end: 20, + }, + name: "a", + bases: [], + keywords: [], + body: [ + Pass( + Pass { + node: Node { + start: 16, + end: 20, + }, + }, + ), + ], + decorator_list: [ + Name( + Name { + node: Node { + start: 1, + end: 6, + }, + id: "decor", + }, + ), + ], + type_params: [], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-7.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-7.snap new file mode 100644 index 00000000..ceb8e650 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-7.snap @@ -0,0 +1,47 @@ +--- +source: parser/src/parser/parser.rs +description: "class a[T]: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +Module { + node: Node { + start: 0, + end: 16, + }, + body: [ + ClassDef( + ClassDef { + node: Node { + start: 0, + end: 16, + }, + name: "a", + bases: [], + keywords: [], + body: [ + Pass( + Pass { + node: Node { + start: 12, + end: 16, + }, + }, + ), + ], + decorator_list: [], + type_params: [ + TypeVar( + TypeVar { + node: Node { + start: 8, + end: 9, + }, + name: "T", + bound: None, + }, + ), + ], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-8.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-8.snap new file mode 100644 index 00000000..3f083dac --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-8.snap @@ -0,0 +1,57 @@ +--- +source: parser/src/parser/parser.rs +description: "class a[T, U]: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +Module { + node: Node { + start: 0, + end: 19, + }, + body: [ + ClassDef( + ClassDef { + node: Node { + start: 0, + end: 19, + }, + name: "a", + bases: [], + keywords: [], + body: [ + Pass( + Pass { + node: Node { + start: 15, + end: 19, + }, + }, + ), + ], + decorator_list: [], + type_params: [ + TypeVar( + TypeVar { + node: Node { + start: 8, + end: 9, + }, + name: "T", + bound: None, + }, + ), + TypeVar( + TypeVar { + node: Node { + start: 11, + end: 12, + }, + name: "U", + bound: None, + }, + ), + ], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-9.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-9.snap new file mode 100644 index 00000000..635514b2 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py-9.snap @@ -0,0 +1,57 @@ +--- +source: parser/src/parser/parser.rs +description: "class a[T: U]: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +Module { + node: Node { + start: 0, + end: 19, + }, + body: [ + ClassDef( + ClassDef { + node: Node { + start: 0, + end: 19, + }, + name: "a", + bases: [], + keywords: [], + body: [ + Pass( + Pass { + node: Node { + start: 15, + end: 19, + }, + }, + ), + ], + decorator_list: [], + type_params: [ + TypeVar( + TypeVar { + node: Node { + start: 8, + end: 12, + }, + name: "T", + bound: Some( + Name( + Name { + node: Node { + start: 11, + end: 12, + }, + id: "U", + }, + ), + ), + }, + ), + ], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py.snap new file mode 100644 index 00000000..d609fb44 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@class.py.snap @@ -0,0 +1,36 @@ +--- +source: parser/src/parser/parser.rs +description: "class a: pass" +input_file: parser/test_data/inputs/one_liners/class.py +--- +Module { + node: Node { + start: 0, + end: 13, + }, + body: [ + ClassDef( + ClassDef { + node: Node { + start: 0, + end: 13, + }, + name: "a", + bases: [], + keywords: [], + body: [ + Pass( + Pass { + node: Node { + start: 9, + end: 13, + }, + }, + ), + ], + decorator_list: [], + type_params: [], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-10.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-10.snap index 1597cbb4..69e2f5b3 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-10.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-10.snap @@ -42,6 +42,7 @@ Module { decorator_list: [], returns: None, type_comment: None, + type_params: [], }, ), ], diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-11.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-11.snap index 8481336f..d2a34685 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-11.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-11.snap @@ -67,6 +67,7 @@ Module { decorator_list: [], returns: None, type_comment: None, + type_params: [], }, ), ], diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-2.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-2.snap index 69e00b23..41def031 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-2.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-2.snap @@ -42,6 +42,7 @@ Module { decorator_list: [], returns: None, type_comment: None, + type_params: [], }, ), ], diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-3.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-3.snap index 1a7e2202..d92f53ae 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-3.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-3.snap @@ -67,6 +67,7 @@ Module { decorator_list: [], returns: None, type_comment: None, + type_params: [], }, ), ], diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-4.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-4.snap index 704d2258..0b551b22 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-4.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-4.snap @@ -69,6 +69,7 @@ Module { decorator_list: [], returns: None, type_comment: None, + type_params: [], }, ), ], diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-5.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-5.snap index 7cf968e6..bf9f3443 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-5.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-5.snap @@ -67,6 +67,7 @@ Module { decorator_list: [], returns: None, type_comment: None, + type_params: [], }, ), ], diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-6.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-6.snap index 83a015bb..9b5e916b 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-6.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-6.snap @@ -52,6 +52,7 @@ Module { ], returns: None, type_comment: None, + type_params: [], }, ), ], diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-7.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-7.snap index 53fb84ef..81b67133 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-7.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-7.snap @@ -154,6 +154,7 @@ Module { ], returns: None, type_comment: None, + type_params: [], }, ), ], diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-8.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-8.snap index 03a50ab2..76e2267a 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-8.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-8.snap @@ -52,6 +52,7 @@ Module { ), ), type_comment: None, + type_params: [], }, ), ], diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-9.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-9.snap index 074fe35f..7314a750 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-9.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-9.snap @@ -42,6 +42,7 @@ Module { decorator_list: [], returns: None, type_comment: None, + type_params: [], }, ), ], diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py.snap index c84d7c5c..7fa011a8 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py.snap @@ -42,6 +42,7 @@ Module { decorator_list: [], returns: None, type_comment: None, + type_params: [], }, ), ], diff --git a/parser/test_data/inputs/one_liners/class.py b/parser/test_data/inputs/one_liners/class.py new file mode 100644 index 00000000..7625a9ba --- /dev/null +++ b/parser/test_data/inputs/one_liners/class.py @@ -0,0 +1,43 @@ +class a: pass + +class a(): + pass + +class a(b, c): pass + +class a(b, *c, **d): pass + +class a(b, +c, +d): pass + +@decor +class a: pass + +class a[T]: pass + +class a[T, U]: pass + +class a[T: U]: pass + +class a[T: U, V: W]: pass + +class a[*T]: pass + +class a[T, *U]: pass + +class a[T: U, *V]: pass + +class a[T: U, V: W, *X]: pass + +class a[**T]: pass + +class a[T, **U]: pass + +class a[T: U, **V]: pass + +class a[T: U, V: W, **X]: pass + +class a[T, *U, **V]: pass + +class a[T: U, *V, **W]: pass From ab39c46f552e49843a76562dc26a438fbcca14a8 Mon Sep 17 00:00:00 2001 From: Glyphack Date: Wed, 25 Oct 2023 21:15:11 +0200 Subject: [PATCH 2/6] (parser) test type var on functions --- ...t_lexer_and_errors@function_def.py-11.snap | 8 +- ...t_lexer_and_errors@function_def.py-12.snap | 65 +++++++++ ...t_lexer_and_errors@function_def.py-13.snap | 79 +++++++++++ ...t_lexer_and_errors@function_def.py-14.snap | 79 +++++++++++ ...t_lexer_and_errors@function_def.py-15.snap | 107 +++++++++++++++ ...t_lexer_and_errors@function_def.py-16.snap | 71 ++++++++++ ...t_lexer_and_errors@function_def.py-17.snap | 85 ++++++++++++ ...t_lexer_and_errors@function_def.py-18.snap | 99 ++++++++++++++ ...t_lexer_and_errors@function_def.py-19.snap | 127 ++++++++++++++++++ ...t_lexer_and_errors@function_def.py-20.snap | 71 ++++++++++ ...t_lexer_and_errors@function_def.py-21.snap | 85 ++++++++++++ ...t_lexer_and_errors@function_def.py-22.snap | 99 ++++++++++++++ ...t_lexer_and_errors@function_def.py-23.snap | 127 ++++++++++++++++++ ...t_lexer_and_errors@function_def.py-24.snap | 105 +++++++++++++++ ...t_lexer_and_errors@function_def.py-25.snap | 125 +++++++++++++++++ ..._tests__one_liners@function_def.py-11.snap | 6 +- ..._tests__one_liners@function_def.py-12.snap | 60 +++++++++ ..._tests__one_liners@function_def.py-13.snap | 70 ++++++++++ ..._tests__one_liners@function_def.py-14.snap | 70 ++++++++++ ..._tests__one_liners@function_def.py-15.snap | 90 +++++++++++++ ..._tests__one_liners@function_def.py-16.snap | 59 ++++++++ ..._tests__one_liners@function_def.py-17.snap | 69 ++++++++++ ..._tests__one_liners@function_def.py-18.snap | 79 +++++++++++ ..._tests__one_liners@function_def.py-19.snap | 99 ++++++++++++++ ..._tests__one_liners@function_def.py-20.snap | 59 ++++++++ ..._tests__one_liners@function_def.py-21.snap | 69 ++++++++++ ..._tests__one_liners@function_def.py-22.snap | 79 +++++++++++ ..._tests__one_liners@function_def.py-23.snap | 99 ++++++++++++++ ..._tests__one_liners@function_def.py-24.snap | 78 +++++++++++ ..._tests__one_liners@function_def.py-25.snap | 88 ++++++++++++ .../inputs/one_liners/function_def.py | 28 ++++ 31 files changed, 2424 insertions(+), 10 deletions(-) create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-12.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-13.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-14.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-15.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-16.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-17.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-18.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-19.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-20.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-21.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-22.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-23.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-24.snap create mode 100644 parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-25.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-12.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-13.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-14.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-15.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-16.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-17.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-18.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-19.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-20.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-21.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-22.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-23.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-24.snap create mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-25.snap diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-11.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-11.snap index 41fc0fd1..14bd6f1e 100644 --- a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-11.snap +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-11.snap @@ -1,6 +1,6 @@ --- source: parser/src/lexer/lexer.rs -description: "async def a(a, b, c): pass\n" +description: "async def a(a, b, c): pass" input_file: parser/test_data/inputs/one_liners/function_def.py --- [ @@ -84,10 +84,4 @@ input_file: parser/test_data/inputs/one_liners/function_def.py start: 22, end: 26, }, - Token { - kind: NewLine, - value: None, - start: 26, - end: 27, - }, ] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-12.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-12.snap new file mode 100644 index 00000000..cfc41b32 --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-12.snap @@ -0,0 +1,65 @@ +--- +source: parser/src/lexer/lexer.rs +description: "def a[T](): pass" +input_file: parser/test_data/inputs/one_liners/function_def.py +--- +[ + Token { + kind: Def, + value: None, + start: 0, + end: 3, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 4, + end: 5, + }, + Token { + kind: LeftBrace, + value: None, + start: 5, + end: 6, + }, + Token { + kind: Identifier, + value: Str( + "T", + ), + start: 6, + end: 7, + }, + Token { + kind: RightBrace, + value: None, + start: 7, + end: 8, + }, + Token { + kind: LeftParen, + value: None, + start: 8, + end: 9, + }, + Token { + kind: RightParen, + value: None, + start: 9, + end: 10, + }, + Token { + kind: Colon, + value: None, + start: 10, + end: 11, + }, + Token { + kind: Pass, + value: None, + start: 12, + end: 16, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-13.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-13.snap new file mode 100644 index 00000000..da82e826 --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-13.snap @@ -0,0 +1,79 @@ +--- +source: parser/src/lexer/lexer.rs +description: "def a[T, U](): pass" +input_file: parser/test_data/inputs/one_liners/function_def.py +--- +[ + Token { + kind: Def, + value: None, + start: 0, + end: 3, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 4, + end: 5, + }, + Token { + kind: LeftBrace, + value: None, + start: 5, + end: 6, + }, + Token { + kind: Identifier, + value: Str( + "T", + ), + start: 6, + end: 7, + }, + Token { + kind: Comma, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Identifier, + value: Str( + "U", + ), + start: 9, + end: 10, + }, + Token { + kind: RightBrace, + value: None, + start: 10, + end: 11, + }, + Token { + kind: LeftParen, + value: None, + start: 11, + end: 12, + }, + Token { + kind: RightParen, + value: None, + start: 12, + end: 13, + }, + Token { + kind: Colon, + value: None, + start: 13, + end: 14, + }, + Token { + kind: Pass, + value: None, + start: 15, + end: 19, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-14.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-14.snap new file mode 100644 index 00000000..6a9e1115 --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-14.snap @@ -0,0 +1,79 @@ +--- +source: parser/src/lexer/lexer.rs +description: "def a[T: U](): pass" +input_file: parser/test_data/inputs/one_liners/function_def.py +--- +[ + Token { + kind: Def, + value: None, + start: 0, + end: 3, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 4, + end: 5, + }, + Token { + kind: LeftBrace, + value: None, + start: 5, + end: 6, + }, + Token { + kind: Identifier, + value: Str( + "T", + ), + start: 6, + end: 7, + }, + Token { + kind: Colon, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Identifier, + value: Str( + "U", + ), + start: 9, + end: 10, + }, + Token { + kind: RightBrace, + value: None, + start: 10, + end: 11, + }, + Token { + kind: LeftParen, + value: None, + start: 11, + end: 12, + }, + Token { + kind: RightParen, + value: None, + start: 12, + end: 13, + }, + Token { + kind: Colon, + value: None, + start: 13, + end: 14, + }, + Token { + kind: Pass, + value: None, + start: 15, + end: 19, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-15.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-15.snap new file mode 100644 index 00000000..2dd93212 --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-15.snap @@ -0,0 +1,107 @@ +--- +source: parser/src/lexer/lexer.rs +description: "def a[T: U, V: W](): pass" +input_file: parser/test_data/inputs/one_liners/function_def.py +--- +[ + Token { + kind: Def, + value: None, + start: 0, + end: 3, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 4, + end: 5, + }, + Token { + kind: LeftBrace, + value: None, + start: 5, + end: 6, + }, + Token { + kind: Identifier, + value: Str( + "T", + ), + start: 6, + end: 7, + }, + Token { + kind: Colon, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Identifier, + value: Str( + "U", + ), + start: 9, + end: 10, + }, + Token { + kind: Comma, + value: None, + start: 10, + end: 11, + }, + Token { + kind: Identifier, + value: Str( + "V", + ), + start: 12, + end: 13, + }, + Token { + kind: Colon, + value: None, + start: 13, + end: 14, + }, + Token { + kind: Identifier, + value: Str( + "W", + ), + start: 15, + end: 16, + }, + Token { + kind: RightBrace, + value: None, + start: 16, + end: 17, + }, + Token { + kind: LeftParen, + value: None, + start: 17, + end: 18, + }, + Token { + kind: RightParen, + value: None, + start: 18, + end: 19, + }, + Token { + kind: Colon, + value: None, + start: 19, + end: 20, + }, + Token { + kind: Pass, + value: None, + start: 21, + end: 25, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-16.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-16.snap new file mode 100644 index 00000000..3c1ef3b5 --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-16.snap @@ -0,0 +1,71 @@ +--- +source: parser/src/lexer/lexer.rs +description: "def a[*T](): pass" +input_file: parser/test_data/inputs/one_liners/function_def.py +--- +[ + Token { + kind: Def, + value: None, + start: 0, + end: 3, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 4, + end: 5, + }, + Token { + kind: LeftBrace, + value: None, + start: 5, + end: 6, + }, + Token { + kind: Mul, + value: None, + start: 6, + end: 7, + }, + Token { + kind: Identifier, + value: Str( + "T", + ), + start: 7, + end: 8, + }, + Token { + kind: RightBrace, + value: None, + start: 8, + end: 9, + }, + Token { + kind: LeftParen, + value: None, + start: 9, + end: 10, + }, + Token { + kind: RightParen, + value: None, + start: 10, + end: 11, + }, + Token { + kind: Colon, + value: None, + start: 11, + end: 12, + }, + Token { + kind: Pass, + value: None, + start: 13, + end: 17, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-17.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-17.snap new file mode 100644 index 00000000..132e24c3 --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-17.snap @@ -0,0 +1,85 @@ +--- +source: parser/src/lexer/lexer.rs +description: "def a[T, *U](): pass" +input_file: parser/test_data/inputs/one_liners/function_def.py +--- +[ + Token { + kind: Def, + value: None, + start: 0, + end: 3, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 4, + end: 5, + }, + Token { + kind: LeftBrace, + value: None, + start: 5, + end: 6, + }, + Token { + kind: Identifier, + value: Str( + "T", + ), + start: 6, + end: 7, + }, + Token { + kind: Comma, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Mul, + value: None, + start: 9, + end: 10, + }, + Token { + kind: Identifier, + value: Str( + "U", + ), + start: 10, + end: 11, + }, + Token { + kind: RightBrace, + value: None, + start: 11, + end: 12, + }, + Token { + kind: LeftParen, + value: None, + start: 12, + end: 13, + }, + Token { + kind: RightParen, + value: None, + start: 13, + end: 14, + }, + Token { + kind: Colon, + value: None, + start: 14, + end: 15, + }, + Token { + kind: Pass, + value: None, + start: 16, + end: 20, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-18.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-18.snap new file mode 100644 index 00000000..39e0ddb4 --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-18.snap @@ -0,0 +1,99 @@ +--- +source: parser/src/lexer/lexer.rs +description: "def a[T: U, *V](): pass" +input_file: parser/test_data/inputs/one_liners/function_def.py +--- +[ + Token { + kind: Def, + value: None, + start: 0, + end: 3, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 4, + end: 5, + }, + Token { + kind: LeftBrace, + value: None, + start: 5, + end: 6, + }, + Token { + kind: Identifier, + value: Str( + "T", + ), + start: 6, + end: 7, + }, + Token { + kind: Colon, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Identifier, + value: Str( + "U", + ), + start: 9, + end: 10, + }, + Token { + kind: Comma, + value: None, + start: 10, + end: 11, + }, + Token { + kind: Mul, + value: None, + start: 12, + end: 13, + }, + Token { + kind: Identifier, + value: Str( + "V", + ), + start: 13, + end: 14, + }, + Token { + kind: RightBrace, + value: None, + start: 14, + end: 15, + }, + Token { + kind: LeftParen, + value: None, + start: 15, + end: 16, + }, + Token { + kind: RightParen, + value: None, + start: 16, + end: 17, + }, + Token { + kind: Colon, + value: None, + start: 17, + end: 18, + }, + Token { + kind: Pass, + value: None, + start: 19, + end: 23, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-19.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-19.snap new file mode 100644 index 00000000..ca651dc1 --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-19.snap @@ -0,0 +1,127 @@ +--- +source: parser/src/lexer/lexer.rs +description: "def a[T: U, V: W, *X](): pass" +input_file: parser/test_data/inputs/one_liners/function_def.py +--- +[ + Token { + kind: Def, + value: None, + start: 0, + end: 3, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 4, + end: 5, + }, + Token { + kind: LeftBrace, + value: None, + start: 5, + end: 6, + }, + Token { + kind: Identifier, + value: Str( + "T", + ), + start: 6, + end: 7, + }, + Token { + kind: Colon, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Identifier, + value: Str( + "U", + ), + start: 9, + end: 10, + }, + Token { + kind: Comma, + value: None, + start: 10, + end: 11, + }, + Token { + kind: Identifier, + value: Str( + "V", + ), + start: 12, + end: 13, + }, + Token { + kind: Colon, + value: None, + start: 13, + end: 14, + }, + Token { + kind: Identifier, + value: Str( + "W", + ), + start: 15, + end: 16, + }, + Token { + kind: Comma, + value: None, + start: 16, + end: 17, + }, + Token { + kind: Mul, + value: None, + start: 18, + end: 19, + }, + Token { + kind: Identifier, + value: Str( + "X", + ), + start: 19, + end: 20, + }, + Token { + kind: RightBrace, + value: None, + start: 20, + end: 21, + }, + Token { + kind: LeftParen, + value: None, + start: 21, + end: 22, + }, + Token { + kind: RightParen, + value: None, + start: 22, + end: 23, + }, + Token { + kind: Colon, + value: None, + start: 23, + end: 24, + }, + Token { + kind: Pass, + value: None, + start: 25, + end: 29, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-20.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-20.snap new file mode 100644 index 00000000..8ce66e23 --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-20.snap @@ -0,0 +1,71 @@ +--- +source: parser/src/lexer/lexer.rs +description: "def a[**T](): pass" +input_file: parser/test_data/inputs/one_liners/function_def.py +--- +[ + Token { + kind: Def, + value: None, + start: 0, + end: 3, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 4, + end: 5, + }, + Token { + kind: LeftBrace, + value: None, + start: 5, + end: 6, + }, + Token { + kind: Pow, + value: None, + start: 6, + end: 8, + }, + Token { + kind: Identifier, + value: Str( + "T", + ), + start: 8, + end: 9, + }, + Token { + kind: RightBrace, + value: None, + start: 9, + end: 10, + }, + Token { + kind: LeftParen, + value: None, + start: 10, + end: 11, + }, + Token { + kind: RightParen, + value: None, + start: 11, + end: 12, + }, + Token { + kind: Colon, + value: None, + start: 12, + end: 13, + }, + Token { + kind: Pass, + value: None, + start: 14, + end: 18, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-21.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-21.snap new file mode 100644 index 00000000..8f988f90 --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-21.snap @@ -0,0 +1,85 @@ +--- +source: parser/src/lexer/lexer.rs +description: "def a[T, **U](): pass" +input_file: parser/test_data/inputs/one_liners/function_def.py +--- +[ + Token { + kind: Def, + value: None, + start: 0, + end: 3, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 4, + end: 5, + }, + Token { + kind: LeftBrace, + value: None, + start: 5, + end: 6, + }, + Token { + kind: Identifier, + value: Str( + "T", + ), + start: 6, + end: 7, + }, + Token { + kind: Comma, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Pow, + value: None, + start: 9, + end: 11, + }, + Token { + kind: Identifier, + value: Str( + "U", + ), + start: 11, + end: 12, + }, + Token { + kind: RightBrace, + value: None, + start: 12, + end: 13, + }, + Token { + kind: LeftParen, + value: None, + start: 13, + end: 14, + }, + Token { + kind: RightParen, + value: None, + start: 14, + end: 15, + }, + Token { + kind: Colon, + value: None, + start: 15, + end: 16, + }, + Token { + kind: Pass, + value: None, + start: 17, + end: 21, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-22.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-22.snap new file mode 100644 index 00000000..ada39064 --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-22.snap @@ -0,0 +1,99 @@ +--- +source: parser/src/lexer/lexer.rs +description: "def a[T: U, **V](): pass" +input_file: parser/test_data/inputs/one_liners/function_def.py +--- +[ + Token { + kind: Def, + value: None, + start: 0, + end: 3, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 4, + end: 5, + }, + Token { + kind: LeftBrace, + value: None, + start: 5, + end: 6, + }, + Token { + kind: Identifier, + value: Str( + "T", + ), + start: 6, + end: 7, + }, + Token { + kind: Colon, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Identifier, + value: Str( + "U", + ), + start: 9, + end: 10, + }, + Token { + kind: Comma, + value: None, + start: 10, + end: 11, + }, + Token { + kind: Pow, + value: None, + start: 12, + end: 14, + }, + Token { + kind: Identifier, + value: Str( + "V", + ), + start: 14, + end: 15, + }, + Token { + kind: RightBrace, + value: None, + start: 15, + end: 16, + }, + Token { + kind: LeftParen, + value: None, + start: 16, + end: 17, + }, + Token { + kind: RightParen, + value: None, + start: 17, + end: 18, + }, + Token { + kind: Colon, + value: None, + start: 18, + end: 19, + }, + Token { + kind: Pass, + value: None, + start: 20, + end: 24, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-23.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-23.snap new file mode 100644 index 00000000..2a583ff2 --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-23.snap @@ -0,0 +1,127 @@ +--- +source: parser/src/lexer/lexer.rs +description: "def a[T: U, V: W, **X](): pass" +input_file: parser/test_data/inputs/one_liners/function_def.py +--- +[ + Token { + kind: Def, + value: None, + start: 0, + end: 3, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 4, + end: 5, + }, + Token { + kind: LeftBrace, + value: None, + start: 5, + end: 6, + }, + Token { + kind: Identifier, + value: Str( + "T", + ), + start: 6, + end: 7, + }, + Token { + kind: Colon, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Identifier, + value: Str( + "U", + ), + start: 9, + end: 10, + }, + Token { + kind: Comma, + value: None, + start: 10, + end: 11, + }, + Token { + kind: Identifier, + value: Str( + "V", + ), + start: 12, + end: 13, + }, + Token { + kind: Colon, + value: None, + start: 13, + end: 14, + }, + Token { + kind: Identifier, + value: Str( + "W", + ), + start: 15, + end: 16, + }, + Token { + kind: Comma, + value: None, + start: 16, + end: 17, + }, + Token { + kind: Pow, + value: None, + start: 18, + end: 20, + }, + Token { + kind: Identifier, + value: Str( + "X", + ), + start: 20, + end: 21, + }, + Token { + kind: RightBrace, + value: None, + start: 21, + end: 22, + }, + Token { + kind: LeftParen, + value: None, + start: 22, + end: 23, + }, + Token { + kind: RightParen, + value: None, + start: 23, + end: 24, + }, + Token { + kind: Colon, + value: None, + start: 24, + end: 25, + }, + Token { + kind: Pass, + value: None, + start: 26, + end: 30, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-24.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-24.snap new file mode 100644 index 00000000..90dd9125 --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-24.snap @@ -0,0 +1,105 @@ +--- +source: parser/src/lexer/lexer.rs +description: "def a[T, *U, **V](): pass" +input_file: parser/test_data/inputs/one_liners/function_def.py +--- +[ + Token { + kind: Def, + value: None, + start: 0, + end: 3, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 4, + end: 5, + }, + Token { + kind: LeftBrace, + value: None, + start: 5, + end: 6, + }, + Token { + kind: Identifier, + value: Str( + "T", + ), + start: 6, + end: 7, + }, + Token { + kind: Comma, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Mul, + value: None, + start: 9, + end: 10, + }, + Token { + kind: Identifier, + value: Str( + "U", + ), + start: 10, + end: 11, + }, + Token { + kind: Comma, + value: None, + start: 11, + end: 12, + }, + Token { + kind: Pow, + value: None, + start: 13, + end: 15, + }, + Token { + kind: Identifier, + value: Str( + "V", + ), + start: 15, + end: 16, + }, + Token { + kind: RightBrace, + value: None, + start: 16, + end: 17, + }, + Token { + kind: LeftParen, + value: None, + start: 17, + end: 18, + }, + Token { + kind: RightParen, + value: None, + start: 18, + end: 19, + }, + Token { + kind: Colon, + value: None, + start: 19, + end: 20, + }, + Token { + kind: Pass, + value: None, + start: 21, + end: 25, + }, +] diff --git a/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-25.snap b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-25.snap new file mode 100644 index 00000000..0c5712e7 --- /dev/null +++ b/parser/src/lexer/snapshots/enderpy_python_parser__lexer__lexer__tests__snapshot_test_lexer_and_errors@function_def.py-25.snap @@ -0,0 +1,125 @@ +--- +source: parser/src/lexer/lexer.rs +description: "def a[T: U, *V, **W](): pass\n" +input_file: parser/test_data/inputs/one_liners/function_def.py +--- +[ + Token { + kind: Def, + value: None, + start: 0, + end: 3, + }, + Token { + kind: Identifier, + value: Str( + "a", + ), + start: 4, + end: 5, + }, + Token { + kind: LeftBrace, + value: None, + start: 5, + end: 6, + }, + Token { + kind: Identifier, + value: Str( + "T", + ), + start: 6, + end: 7, + }, + Token { + kind: Colon, + value: None, + start: 7, + end: 8, + }, + Token { + kind: Identifier, + value: Str( + "U", + ), + start: 9, + end: 10, + }, + Token { + kind: Comma, + value: None, + start: 10, + end: 11, + }, + Token { + kind: Mul, + value: None, + start: 12, + end: 13, + }, + Token { + kind: Identifier, + value: Str( + "V", + ), + start: 13, + end: 14, + }, + Token { + kind: Comma, + value: None, + start: 14, + end: 15, + }, + Token { + kind: Pow, + value: None, + start: 16, + end: 18, + }, + Token { + kind: Identifier, + value: Str( + "W", + ), + start: 18, + end: 19, + }, + Token { + kind: RightBrace, + value: None, + start: 19, + end: 20, + }, + Token { + kind: LeftParen, + value: None, + start: 20, + end: 21, + }, + Token { + kind: RightParen, + value: None, + start: 21, + end: 22, + }, + Token { + kind: Colon, + value: None, + start: 22, + end: 23, + }, + Token { + kind: Pass, + value: None, + start: 24, + end: 28, + }, + Token { + kind: NewLine, + value: None, + start: 28, + end: 29, + }, +] diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-11.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-11.snap index d2a34685..27abc3a5 100644 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-11.snap +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-11.snap @@ -1,19 +1,19 @@ --- source: parser/src/parser/parser.rs -description: "async def a(a, b, c): pass\n" +description: "async def a(a, b, c): pass" input_file: parser/test_data/inputs/one_liners/function_def.py --- Module { node: Node { start: 0, - end: 27, + end: 26, }, body: [ AsyncFunctionDef( AsyncFunctionDef { node: Node { start: 0, - end: 27, + end: 26, }, name: "a", args: Arguments { diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-12.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-12.snap new file mode 100644 index 00000000..34a5444f --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-12.snap @@ -0,0 +1,60 @@ +--- +source: parser/src/parser/parser.rs +description: "def a[T](): pass" +input_file: parser/test_data/inputs/one_liners/function_def.py +--- +Module { + node: Node { + start: 0, + end: 16, + }, + body: [ + FunctionDef( + FunctionDef { + node: Node { + start: 0, + end: 16, + }, + name: "a", + args: Arguments { + node: Node { + start: 9, + end: 9, + }, + posonlyargs: [], + args: [], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + Pass( + Pass { + node: Node { + start: 12, + end: 16, + }, + }, + ), + ], + decorator_list: [], + returns: None, + type_comment: None, + type_params: [ + TypeVar( + TypeVar { + node: Node { + start: 6, + end: 7, + }, + name: "T", + bound: None, + }, + ), + ], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-13.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-13.snap new file mode 100644 index 00000000..0993c7ad --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-13.snap @@ -0,0 +1,70 @@ +--- +source: parser/src/parser/parser.rs +description: "def a[T, U](): pass" +input_file: parser/test_data/inputs/one_liners/function_def.py +--- +Module { + node: Node { + start: 0, + end: 19, + }, + body: [ + FunctionDef( + FunctionDef { + node: Node { + start: 0, + end: 19, + }, + name: "a", + args: Arguments { + node: Node { + start: 12, + end: 12, + }, + posonlyargs: [], + args: [], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + Pass( + Pass { + node: Node { + start: 15, + end: 19, + }, + }, + ), + ], + decorator_list: [], + returns: None, + type_comment: None, + type_params: [ + TypeVar( + TypeVar { + node: Node { + start: 6, + end: 7, + }, + name: "T", + bound: None, + }, + ), + TypeVar( + TypeVar { + node: Node { + start: 9, + end: 10, + }, + name: "U", + bound: None, + }, + ), + ], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-14.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-14.snap new file mode 100644 index 00000000..53b061d4 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-14.snap @@ -0,0 +1,70 @@ +--- +source: parser/src/parser/parser.rs +description: "def a[T: U](): pass" +input_file: parser/test_data/inputs/one_liners/function_def.py +--- +Module { + node: Node { + start: 0, + end: 19, + }, + body: [ + FunctionDef( + FunctionDef { + node: Node { + start: 0, + end: 19, + }, + name: "a", + args: Arguments { + node: Node { + start: 12, + end: 12, + }, + posonlyargs: [], + args: [], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + Pass( + Pass { + node: Node { + start: 15, + end: 19, + }, + }, + ), + ], + decorator_list: [], + returns: None, + type_comment: None, + type_params: [ + TypeVar( + TypeVar { + node: Node { + start: 6, + end: 10, + }, + name: "T", + bound: Some( + Name( + Name { + node: Node { + start: 9, + end: 10, + }, + id: "U", + }, + ), + ), + }, + ), + ], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-15.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-15.snap new file mode 100644 index 00000000..5d15c24e --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-15.snap @@ -0,0 +1,90 @@ +--- +source: parser/src/parser/parser.rs +description: "def a[T: U, V: W](): pass" +input_file: parser/test_data/inputs/one_liners/function_def.py +--- +Module { + node: Node { + start: 0, + end: 25, + }, + body: [ + FunctionDef( + FunctionDef { + node: Node { + start: 0, + end: 25, + }, + name: "a", + args: Arguments { + node: Node { + start: 18, + end: 18, + }, + posonlyargs: [], + args: [], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + Pass( + Pass { + node: Node { + start: 21, + end: 25, + }, + }, + ), + ], + decorator_list: [], + returns: None, + type_comment: None, + type_params: [ + TypeVar( + TypeVar { + node: Node { + start: 6, + end: 10, + }, + name: "T", + bound: Some( + Name( + Name { + node: Node { + start: 9, + end: 10, + }, + id: "U", + }, + ), + ), + }, + ), + TypeVar( + TypeVar { + node: Node { + start: 12, + end: 16, + }, + name: "V", + bound: Some( + Name( + Name { + node: Node { + start: 15, + end: 16, + }, + id: "W", + }, + ), + ), + }, + ), + ], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-16.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-16.snap new file mode 100644 index 00000000..1699c92c --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-16.snap @@ -0,0 +1,59 @@ +--- +source: parser/src/parser/parser.rs +description: "def a[*T](): pass" +input_file: parser/test_data/inputs/one_liners/function_def.py +--- +Module { + node: Node { + start: 0, + end: 17, + }, + body: [ + FunctionDef( + FunctionDef { + node: Node { + start: 0, + end: 17, + }, + name: "a", + args: Arguments { + node: Node { + start: 10, + end: 10, + }, + posonlyargs: [], + args: [], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + Pass( + Pass { + node: Node { + start: 13, + end: 17, + }, + }, + ), + ], + decorator_list: [], + returns: None, + type_comment: None, + type_params: [ + TypeVarTuple( + TypeVarTuple { + node: Node { + start: 6, + end: 8, + }, + name: "T", + }, + ), + ], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-17.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-17.snap new file mode 100644 index 00000000..ff99068e --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-17.snap @@ -0,0 +1,69 @@ +--- +source: parser/src/parser/parser.rs +description: "def a[T, *U](): pass" +input_file: parser/test_data/inputs/one_liners/function_def.py +--- +Module { + node: Node { + start: 0, + end: 20, + }, + body: [ + FunctionDef( + FunctionDef { + node: Node { + start: 0, + end: 20, + }, + name: "a", + args: Arguments { + node: Node { + start: 13, + end: 13, + }, + posonlyargs: [], + args: [], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + Pass( + Pass { + node: Node { + start: 16, + end: 20, + }, + }, + ), + ], + decorator_list: [], + returns: None, + type_comment: None, + type_params: [ + TypeVar( + TypeVar { + node: Node { + start: 6, + end: 7, + }, + name: "T", + bound: None, + }, + ), + TypeVarTuple( + TypeVarTuple { + node: Node { + start: 9, + end: 11, + }, + name: "U", + }, + ), + ], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-18.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-18.snap new file mode 100644 index 00000000..5392d7d2 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-18.snap @@ -0,0 +1,79 @@ +--- +source: parser/src/parser/parser.rs +description: "def a[T: U, *V](): pass" +input_file: parser/test_data/inputs/one_liners/function_def.py +--- +Module { + node: Node { + start: 0, + end: 23, + }, + body: [ + FunctionDef( + FunctionDef { + node: Node { + start: 0, + end: 23, + }, + name: "a", + args: Arguments { + node: Node { + start: 16, + end: 16, + }, + posonlyargs: [], + args: [], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + Pass( + Pass { + node: Node { + start: 19, + end: 23, + }, + }, + ), + ], + decorator_list: [], + returns: None, + type_comment: None, + type_params: [ + TypeVar( + TypeVar { + node: Node { + start: 6, + end: 10, + }, + name: "T", + bound: Some( + Name( + Name { + node: Node { + start: 9, + end: 10, + }, + id: "U", + }, + ), + ), + }, + ), + TypeVarTuple( + TypeVarTuple { + node: Node { + start: 12, + end: 14, + }, + name: "V", + }, + ), + ], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-19.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-19.snap new file mode 100644 index 00000000..23acb1d9 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-19.snap @@ -0,0 +1,99 @@ +--- +source: parser/src/parser/parser.rs +description: "def a[T: U, V: W, *X](): pass" +input_file: parser/test_data/inputs/one_liners/function_def.py +--- +Module { + node: Node { + start: 0, + end: 29, + }, + body: [ + FunctionDef( + FunctionDef { + node: Node { + start: 0, + end: 29, + }, + name: "a", + args: Arguments { + node: Node { + start: 22, + end: 22, + }, + posonlyargs: [], + args: [], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + Pass( + Pass { + node: Node { + start: 25, + end: 29, + }, + }, + ), + ], + decorator_list: [], + returns: None, + type_comment: None, + type_params: [ + TypeVar( + TypeVar { + node: Node { + start: 6, + end: 10, + }, + name: "T", + bound: Some( + Name( + Name { + node: Node { + start: 9, + end: 10, + }, + id: "U", + }, + ), + ), + }, + ), + TypeVar( + TypeVar { + node: Node { + start: 12, + end: 16, + }, + name: "V", + bound: Some( + Name( + Name { + node: Node { + start: 15, + end: 16, + }, + id: "W", + }, + ), + ), + }, + ), + TypeVarTuple( + TypeVarTuple { + node: Node { + start: 18, + end: 20, + }, + name: "X", + }, + ), + ], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-20.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-20.snap new file mode 100644 index 00000000..8c698d31 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-20.snap @@ -0,0 +1,59 @@ +--- +source: parser/src/parser/parser.rs +description: "def a[**T](): pass" +input_file: parser/test_data/inputs/one_liners/function_def.py +--- +Module { + node: Node { + start: 0, + end: 18, + }, + body: [ + FunctionDef( + FunctionDef { + node: Node { + start: 0, + end: 18, + }, + name: "a", + args: Arguments { + node: Node { + start: 11, + end: 11, + }, + posonlyargs: [], + args: [], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + Pass( + Pass { + node: Node { + start: 14, + end: 18, + }, + }, + ), + ], + decorator_list: [], + returns: None, + type_comment: None, + type_params: [ + ParamSpec( + ParamSpec { + node: Node { + start: 6, + end: 9, + }, + name: "T", + }, + ), + ], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-21.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-21.snap new file mode 100644 index 00000000..948c3af2 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-21.snap @@ -0,0 +1,69 @@ +--- +source: parser/src/parser/parser.rs +description: "def a[T, **U](): pass" +input_file: parser/test_data/inputs/one_liners/function_def.py +--- +Module { + node: Node { + start: 0, + end: 21, + }, + body: [ + FunctionDef( + FunctionDef { + node: Node { + start: 0, + end: 21, + }, + name: "a", + args: Arguments { + node: Node { + start: 14, + end: 14, + }, + posonlyargs: [], + args: [], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + Pass( + Pass { + node: Node { + start: 17, + end: 21, + }, + }, + ), + ], + decorator_list: [], + returns: None, + type_comment: None, + type_params: [ + TypeVar( + TypeVar { + node: Node { + start: 6, + end: 7, + }, + name: "T", + bound: None, + }, + ), + ParamSpec( + ParamSpec { + node: Node { + start: 9, + end: 12, + }, + name: "U", + }, + ), + ], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-22.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-22.snap new file mode 100644 index 00000000..22a08162 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-22.snap @@ -0,0 +1,79 @@ +--- +source: parser/src/parser/parser.rs +description: "def a[T: U, **V](): pass" +input_file: parser/test_data/inputs/one_liners/function_def.py +--- +Module { + node: Node { + start: 0, + end: 24, + }, + body: [ + FunctionDef( + FunctionDef { + node: Node { + start: 0, + end: 24, + }, + name: "a", + args: Arguments { + node: Node { + start: 17, + end: 17, + }, + posonlyargs: [], + args: [], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + Pass( + Pass { + node: Node { + start: 20, + end: 24, + }, + }, + ), + ], + decorator_list: [], + returns: None, + type_comment: None, + type_params: [ + TypeVar( + TypeVar { + node: Node { + start: 6, + end: 10, + }, + name: "T", + bound: Some( + Name( + Name { + node: Node { + start: 9, + end: 10, + }, + id: "U", + }, + ), + ), + }, + ), + ParamSpec( + ParamSpec { + node: Node { + start: 12, + end: 15, + }, + name: "V", + }, + ), + ], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-23.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-23.snap new file mode 100644 index 00000000..84ff88bc --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-23.snap @@ -0,0 +1,99 @@ +--- +source: parser/src/parser/parser.rs +description: "def a[T: U, V: W, **X](): pass" +input_file: parser/test_data/inputs/one_liners/function_def.py +--- +Module { + node: Node { + start: 0, + end: 30, + }, + body: [ + FunctionDef( + FunctionDef { + node: Node { + start: 0, + end: 30, + }, + name: "a", + args: Arguments { + node: Node { + start: 23, + end: 23, + }, + posonlyargs: [], + args: [], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + Pass( + Pass { + node: Node { + start: 26, + end: 30, + }, + }, + ), + ], + decorator_list: [], + returns: None, + type_comment: None, + type_params: [ + TypeVar( + TypeVar { + node: Node { + start: 6, + end: 10, + }, + name: "T", + bound: Some( + Name( + Name { + node: Node { + start: 9, + end: 10, + }, + id: "U", + }, + ), + ), + }, + ), + TypeVar( + TypeVar { + node: Node { + start: 12, + end: 16, + }, + name: "V", + bound: Some( + Name( + Name { + node: Node { + start: 15, + end: 16, + }, + id: "W", + }, + ), + ), + }, + ), + ParamSpec( + ParamSpec { + node: Node { + start: 18, + end: 21, + }, + name: "X", + }, + ), + ], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-24.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-24.snap new file mode 100644 index 00000000..ff4d4dc3 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-24.snap @@ -0,0 +1,78 @@ +--- +source: parser/src/parser/parser.rs +description: "def a[T, *U, **V](): pass" +input_file: parser/test_data/inputs/one_liners/function_def.py +--- +Module { + node: Node { + start: 0, + end: 25, + }, + body: [ + FunctionDef( + FunctionDef { + node: Node { + start: 0, + end: 25, + }, + name: "a", + args: Arguments { + node: Node { + start: 18, + end: 18, + }, + posonlyargs: [], + args: [], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + Pass( + Pass { + node: Node { + start: 21, + end: 25, + }, + }, + ), + ], + decorator_list: [], + returns: None, + type_comment: None, + type_params: [ + TypeVar( + TypeVar { + node: Node { + start: 6, + end: 7, + }, + name: "T", + bound: None, + }, + ), + TypeVarTuple( + TypeVarTuple { + node: Node { + start: 9, + end: 11, + }, + name: "U", + }, + ), + ParamSpec( + ParamSpec { + node: Node { + start: 13, + end: 16, + }, + name: "V", + }, + ), + ], + }, + ), + ], +} diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-25.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-25.snap new file mode 100644 index 00000000..298c64d5 --- /dev/null +++ b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__one_liners@function_def.py-25.snap @@ -0,0 +1,88 @@ +--- +source: parser/src/parser/parser.rs +description: "def a[T: U, *V, **W](): pass\n" +input_file: parser/test_data/inputs/one_liners/function_def.py +--- +Module { + node: Node { + start: 0, + end: 29, + }, + body: [ + FunctionDef( + FunctionDef { + node: Node { + start: 0, + end: 29, + }, + name: "a", + args: Arguments { + node: Node { + start: 21, + end: 21, + }, + posonlyargs: [], + args: [], + vararg: None, + kwonlyargs: [], + kw_defaults: [], + kwarg: None, + defaults: [], + }, + body: [ + Pass( + Pass { + node: Node { + start: 24, + end: 28, + }, + }, + ), + ], + decorator_list: [], + returns: None, + type_comment: None, + type_params: [ + TypeVar( + TypeVar { + node: Node { + start: 6, + end: 10, + }, + name: "T", + bound: Some( + Name( + Name { + node: Node { + start: 9, + end: 10, + }, + id: "U", + }, + ), + ), + }, + ), + TypeVarTuple( + TypeVarTuple { + node: Node { + start: 12, + end: 14, + }, + name: "V", + }, + ), + ParamSpec( + ParamSpec { + node: Node { + start: 16, + end: 19, + }, + name: "W", + }, + ), + ], + }, + ), + ], +} diff --git a/parser/test_data/inputs/one_liners/function_def.py b/parser/test_data/inputs/one_liners/function_def.py index 03fc019f..f97e0909 100644 --- a/parser/test_data/inputs/one_liners/function_def.py +++ b/parser/test_data/inputs/one_liners/function_def.py @@ -25,3 +25,31 @@ async def a(): pass async def a(a, b, c): pass + +def a[T](): pass + +def a[T, U](): pass + +def a[T: U](): pass + +def a[T: U, V: W](): pass + +def a[*T](): pass + +def a[T, *U](): pass + +def a[T: U, *V](): pass + +def a[T: U, V: W, *X](): pass + +def a[**T](): pass + +def a[T, **U](): pass + +def a[T: U, **V](): pass + +def a[T: U, V: W, **X](): pass + +def a[T, *U, **V](): pass + +def a[T: U, *V, **W](): pass From 3f7949690b0c69730f8bb1a12d19bae0a4f90f25 Mon Sep 17 00:00:00 2001 From: Glyphack Date: Sun, 29 Oct 2023 19:49:22 +0100 Subject: [PATCH 3/6] Check for type alias in ast visitors --- typechecker/src/ast_visitor.rs | 5 + typechecker/src/ast_visitor_generic.rs | 5 + typechecker/src/ast_visitor_immut.rs | 325 ------------------ typechecker/src/lib.rs | 1 - typechecker/src/nodes.rs | 1 + typechecker/src/semantic_analyzer.rs | 1 + typechecker/src/type_check/checker.rs | 1 + typechecker/src/type_check/type_evaluator.rs | 1 + ...sts__symbol_table@class_definition.py.snap | 4 + ...__symbol_table@function_definition.py.snap | 4 + 10 files changed, 22 insertions(+), 326 deletions(-) delete mode 100644 typechecker/src/ast_visitor_immut.rs diff --git a/typechecker/src/ast_visitor.rs b/typechecker/src/ast_visitor.rs index 0398376c..3e0083ee 100644 --- a/typechecker/src/ast_visitor.rs +++ b/typechecker/src/ast_visitor.rs @@ -36,6 +36,7 @@ pub trait TraversalVisitor { Statement::AsyncForStatement(f) => self.visit_async_for(f), Statement::AsyncWithStatement(w) => self.visit_async_with(w), Statement::AsyncFunctionDef(f) => self.visit_async_function_def(f), + Statement::TypeAlias(t) => self.visit_type_alias(t), } } fn visit_expr(&mut self, e: &Expression) { @@ -361,4 +362,8 @@ pub trait TraversalVisitor { fn visit_nonlocal(&mut self, _n: &Nonlocal) { todo!() } + + fn visit_type_alias(&mut self, _t: &TypeAlias) { + todo!() + } } diff --git a/typechecker/src/ast_visitor_generic.rs b/typechecker/src/ast_visitor_generic.rs index 0a1ed9e4..3ebbef60 100644 --- a/typechecker/src/ast_visitor_generic.rs +++ b/typechecker/src/ast_visitor_generic.rs @@ -37,6 +37,7 @@ pub trait TraversalVisitorImmutGeneric { Statement::AsyncForStatement(f) => self.visit_async_for(f), Statement::AsyncWithStatement(w) => self.visit_async_with(w), Statement::AsyncFunctionDef(f) => self.visit_async_function_def(f), + Statement::TypeAlias(a) => self.visit_type_alias(a), } } fn visit_expr(&self, e: &Expression) -> T { @@ -259,4 +260,8 @@ pub trait TraversalVisitorImmutGeneric { fn visit_nonlocal(&self, _n: &Nonlocal) -> T { todo!() } + + fn visit_type_alias(&self, _a: &TypeAlias) -> T { + todo!() + } } diff --git a/typechecker/src/ast_visitor_immut.rs b/typechecker/src/ast_visitor_immut.rs deleted file mode 100644 index b4186f50..00000000 --- a/typechecker/src/ast_visitor_immut.rs +++ /dev/null @@ -1,325 +0,0 @@ -use ast::{Expression, Statement}; - -use enderpy_python_parser::ast::{self, *}; - -use enderpy_python_parser as parser; - -pub trait TraversalVisitorImmut { - fn visit_stmt(&self, s: &Statement) { - // map all statements and call visit - match s { - Statement::ExpressionStatement(e) => self.visit_expr(e), - Statement::Import(i) => self.visit_import(i), - Statement::ImportFrom(i) => self.visit_import_from(i), - Statement::AssignStatement(a) => self.visit_assign(a), - Statement::AnnAssignStatement(a) => self.visit_ann_assign(a), - Statement::AugAssignStatement(a) => self.visit_aug_assign(a), - Statement::Assert(a) => self.visit_assert(a), - Statement::Pass(p) => self.visit_pass(p), - Statement::Delete(d) => self.visit_delete(d), - Statement::Return(r) => self.visit_return(r), - Statement::Raise(r) => self.visit_raise(r), - Statement::Break(b) => self.visit_break(b), - Statement::Continue(c) => self.visit_continue(c), - Statement::Global(g) => self.visit_global(g), - Statement::Nonlocal(n) => self.visit_nonlocal(n), - Statement::IfStatement(i) => self.visit_if(i), - Statement::WhileStatement(w) => self.visit_while(w), - Statement::ForStatement(f) => self.visit_for(f), - Statement::WithStatement(w) => self.visit_with(w), - Statement::TryStatement(t) => self.visit_try(t), - Statement::TryStarStatement(t) => self.visit_try_star(t), - Statement::FunctionDef(f) => self.visit_function_def(f), - Statement::ClassDef(c) => self.visit_class_def(c), - Statement::Match(m) => self.visit_match(m), - Statement::AsyncForStatement(f) => self.visit_async_for(f), - Statement::AsyncWithStatement(w) => self.visit_async_with(w), - Statement::AsyncFunctionDef(f) => self.visit_async_function_def(f), - } - } - fn visit_expr(&self, e: &Expression) { - match e { - Expression::Constant(c) => self.visit_constant(c), - Expression::List(l) => self.visit_list(l), - Expression::Tuple(t) => self.visit_tuple(t), - Expression::Dict(d) => self.visit_dict(d), - Expression::Set(s) => self.visit_set(s), - Expression::Name(n) => self.visit_name(n), - Expression::BoolOp(b) => self.visit_bool_op(b), - Expression::UnaryOp(u) => self.visit_unary_op(u), - Expression::BinOp(b) => self.visit_bin_op(b), - Expression::NamedExpr(n) => self.visit_named_expr(n), - Expression::Yield(y) => self.visit_yield(y), - Expression::YieldFrom(y) => self.visit_yield_from(y), - Expression::Starred(s) => self.visit_starred(s), - Expression::Generator(g) => self.visit_generator(g), - Expression::ListComp(l) => self.visit_list_comp(l), - Expression::SetComp(s) => self.visit_set_comp(s), - Expression::DictComp(d) => self.visit_dict_comp(d), - Expression::Attribute(a) => self.visit_attribute(a), - Expression::Subscript(s) => self.visit_subscript(s), - Expression::Slice(s) => self.visit_slice(s), - Expression::Call(c) => self.visit_call(c), - Expression::Await(a) => self.visit_await(a), - Expression::Compare(c) => self.visit_compare(c), - Expression::Lambda(l) => self.visit_lambda(l), - Expression::IfExp(i) => self.visit_if_exp(i), - Expression::JoinedStr(j) => self.visit_joined_str(j), - Expression::FormattedValue(f) => self.visit_formatted_value(f), - } - } - fn visit_import(&self, _i: &Import) { - todo!(); - } - - fn visit_import_from(&self, _i: &ImportFrom) { - todo!(); - } - - fn visit_if(&self, i: &parser::ast::If) { - for stmt in &i.body { - self.visit_stmt(stmt); - } - for stmt in &i.orelse { - self.visit_stmt(stmt); - } - } - - fn visit_while(&self, w: &parser::ast::While) { - for stmt in &w.body { - self.visit_stmt(stmt) - } - } - - fn visit_for(&self, f: &parser::ast::For) { - for stmt in &f.body { - self.visit_stmt(stmt); - } - } - - fn visit_async_for(&self, f: &parser::ast::AsyncFor) { - for stmt in &f.body { - self.visit_stmt(stmt); - } - } - - fn visit_with(&self, w: &parser::ast::With) { - for stmt in &w.body { - self.visit_stmt(stmt); - } - for with_items in &w.items { - self.visit_expr(&with_items.context_expr); - match &with_items.optional_vars { - Some(items) => self.visit_expr(items), - None => (), - } - } - } - - fn visit_async_with(&self, w: &parser::ast::AsyncWith) { - for stmt in &w.body { - self.visit_stmt(stmt); - } - for with_items in &w.items { - self.visit_expr(&with_items.context_expr); - match &with_items.optional_vars { - Some(items) => self.visit_expr(items), - None => (), - } - } - } - - fn visit_try(&self, t: &parser::ast::Try) { - for stmt in &t.body { - self.visit_stmt(stmt); - } - for stmt in &t.orelse { - self.visit_stmt(stmt); - } - for stmt in &t.finalbody { - self.visit_stmt(stmt); - } - // TODO: need to visit exception handler name and type but let's keep it simple for now - for handler in &t.handlers { - for stmt in &handler.body { - self.visit_stmt(stmt); - } - } - } - - fn visit_try_star(&self, t: &parser::ast::TryStar) { - for stmt in &t.body { - self.visit_stmt(stmt); - } - for stmt in &t.orelse { - self.visit_stmt(stmt); - } - for stmt in &t.finalbody { - self.visit_stmt(stmt); - } - // TODO: need to visit exception handler name and type but let's keep it simple for now - for handler in &t.handlers { - for stmt in &handler.body { - self.visit_stmt(stmt); - } - } - } - - fn visit_function_def(&self, f: &parser::ast::FunctionDef) { - for stmt in &f.body { - self.visit_stmt(stmt); - } - } - - fn visit_async_function_def(&self, f: &parser::ast::AsyncFunctionDef) { - for stmt in &f.body { - self.visit_stmt(stmt); - } - } - - fn visit_class_def(&self, c: &parser::ast::ClassDef) { - for stmt in &c.body { - self.visit_stmt(stmt); - } - } - - fn visit_match(&self, m: &parser::ast::Match) { - for case in &m.cases { - for stmt in &case.body { - self.visit_stmt(stmt); - } - } - } - - fn visit_constant(&self, _c: &Constant) { - todo!() - } - fn visit_list(&self, _l: &List) { - todo!() - } - fn visit_tuple(&self, _t: &Tuple) { - todo!() - } - fn visit_dict(&self, _d: &Dict) { - todo!() - } - fn visit_set(&self, _s: &Set) { - todo!() - } - fn visit_name(&self, _n: &Name) {} - fn visit_bool_op(&self, _b: &BoolOperation) { - todo!() - } - fn visit_unary_op(&self, _u: &UnaryOperation) { - todo!() - } - fn visit_bin_op(&self, _b: &BinOp) { - todo!() - } - fn visit_named_expr(&self, _n: &NamedExpression) { - todo!() - } - fn visit_yield(&self, _y: &Yield) { - todo!() - } - fn visit_yield_from(&self, _y: &YieldFrom) { - todo!() - } - fn visit_starred(&self, _s: &Starred) { - todo!() - } - fn visit_generator(&self, _g: &Generator) { - todo!() - } - fn visit_list_comp(&self, _l: &ListComp) { - todo!() - } - fn visit_set_comp(&self, _s: &SetComp) { - todo!() - } - fn visit_dict_comp(&self, _d: &DictComp) { - todo!() - } - fn visit_attribute(&self, _a: &Attribute) { - todo!() - } - fn visit_subscript(&self, _s: &Subscript) { - todo!() - } - fn visit_slice(&self, _s: &Slice) { - todo!() - } - fn visit_call(&self, _c: &Call) { - todo!() - } - fn visit_await(&self, _a: &Await) { - todo!() - } - fn visit_compare(&self, _c: &Compare) { - todo!() - } - fn visit_lambda(&self, _l: &Lambda) { - todo!() - } - fn visit_if_exp(&self, _i: &IfExp) { - todo!() - } - fn visit_joined_str(&self, _j: &JoinedStr) { - todo!() - } - fn visit_formatted_value(&self, _f: &FormattedValue) { - todo!() - } - - fn visit_alias(&self, _a: &Alias) { - todo!() - } - - fn visit_assign(&self, _a: &Assign) { - todo!() - } - - fn visit_ann_assign(&self, _a: &AnnAssign) { - todo!() - } - - fn visit_aug_assign(&self, _a: &AugAssign) { - todo!() - } - - fn visit_assert(&self, _a: &Assert) { - todo!() - } - - fn visit_pass(&self, _p: &Pass) { - todo!() - } - - fn visit_delete(&self, _d: &Delete) { - todo!() - } - - fn visit_return(&self, _r: &Return) { - todo!() - } - - fn visit_raise(&self, _r: &Raise) { - todo!() - } - - fn visit_break(&self, _b: &Break) { - todo!() - } - - fn visit_continue(&self, _c: &Continue) { - todo!() - } - - fn visit_global(&self, _g: &Global) { - todo!() - } - - fn visit_nonlocal(&self, _n: &Nonlocal) { - todo!() - } -} diff --git a/typechecker/src/lib.rs b/typechecker/src/lib.rs index 26a4e399..135b9d34 100644 --- a/typechecker/src/lib.rs +++ b/typechecker/src/lib.rs @@ -1,6 +1,5 @@ mod ast_visitor; mod ast_visitor_generic; -mod ast_visitor_immut; mod nodes; mod ruff_python_import_resolver; mod semanal_utils; diff --git a/typechecker/src/nodes.rs b/typechecker/src/nodes.rs index 26f20bfd..99a6fc6e 100755 --- a/typechecker/src/nodes.rs +++ b/typechecker/src/nodes.rs @@ -118,6 +118,7 @@ impl<'a> TraversalVisitor for EnderpyFile { Statement::AsyncForStatement(f) => self.visit_async_for(f), Statement::AsyncWithStatement(w) => self.visit_async_with(w), Statement::AsyncFunctionDef(f) => self.visit_async_function_def(f), + Statement::TypeAlias(a) => self.visit_type_alias(a), } } diff --git a/typechecker/src/semantic_analyzer.rs b/typechecker/src/semantic_analyzer.rs index f07827b8..9c92ef53 100644 --- a/typechecker/src/semantic_analyzer.rs +++ b/typechecker/src/semantic_analyzer.rs @@ -234,6 +234,7 @@ impl TraversalVisitor for SemanticAnalyzer { Statement::AsyncForStatement(f) => self.visit_async_for(f), Statement::AsyncWithStatement(w) => self.visit_async_with(w), Statement::AsyncFunctionDef(f) => self.visit_async_function_def(f), + Statement::TypeAlias(a) => self.visit_type_alias(a), } } diff --git a/typechecker/src/type_check/checker.rs b/typechecker/src/type_check/checker.rs index 2f6e4f75..bc21ef42 100644 --- a/typechecker/src/type_check/checker.rs +++ b/typechecker/src/type_check/checker.rs @@ -101,6 +101,7 @@ impl<'a> TraversalVisitor for TypeChecker<'a> { Statement::AsyncForStatement(f) => self.visit_async_for(f), Statement::AsyncWithStatement(w) => self.visit_async_with(w), Statement::AsyncFunctionDef(f) => self.visit_async_function_def(f), + Statement::TypeAlias(a) => self.visit_type_alias(a), } } diff --git a/typechecker/src/type_check/type_evaluator.rs b/typechecker/src/type_check/type_evaluator.rs index 8398f1ff..a8adeb0e 100755 --- a/typechecker/src/type_check/type_evaluator.rs +++ b/typechecker/src/type_check/type_evaluator.rs @@ -281,6 +281,7 @@ impl TraversalVisitorImmutGeneric for TypeEvaluator { Statement::AsyncForStatement(f) => self.visit_async_for(f), Statement::AsyncWithStatement(w) => self.visit_async_with(w), Statement::AsyncFunctionDef(f) => self.visit_async_function_def(f), + Statement::TypeAlias(a) => self.visit_type_alias(a), } } diff --git a/typechecker/testdata/output/enderpy_python_type_checker__build__tests__symbol_table@class_definition.py.snap b/typechecker/testdata/output/enderpy_python_type_checker__build__tests__symbol_table@class_definition.py.snap index 3414ae3b..f7fa44f7 100644 --- a/typechecker/testdata/output/enderpy_python_type_checker__build__tests__symbol_table@class_definition.py.snap +++ b/typechecker/testdata/output/enderpy_python_type_checker__build__tests__symbol_table@class_definition.py.snap @@ -74,6 +74,7 @@ self Symbols: __init__ - Declarations: +<<<<<<< HEAD --: Function { declaration_path: DeclarationPath { module_name: [REDACTED]", @@ -150,6 +151,9 @@ __init__ yeild_statements: [], raise_statements: [], } +======= +--: Function { declaration_path: DeclarationPath { module_name: ".Users.glyphack.Programming.enderpy.typechecker.test_data.inputs.symbol_table.class_definition.py", node: Node { start: 13, end: 47 } }, function_node: FunctionDef { node: Node { start: 13, end: 47 }, name: "__init__", args: Arguments { node: Node { start: 26, end: 30 }, posonlyargs: [], args: [Arg { node: Node { start: 26, end: 30 }, arg: "self", annotation: None }], vararg: None, kwonlyargs: [], kw_defaults: [], kwarg: None, defaults: [] }, body: [AssignStatement(Assign { node: Node { start: 41, end: 46 }, targets: [Name(Name { node: Node { start: 41, end: 42 }, id: "a" })], value: Constant(Constant { node: Node { start: 45, end: 46 }, value: 1 }) })], decorator_list: [], returns: None, type_comment: None, type_params: [] }, is_method: true, is_generator: false, return_statements: [], yeild_statements: [], raise_statements: [] } +>>>>>>> d6d917b (Check for type alias in ast visitors) ------------------- diff --git a/typechecker/testdata/output/enderpy_python_type_checker__build__tests__symbol_table@function_definition.py.snap b/typechecker/testdata/output/enderpy_python_type_checker__build__tests__symbol_table@function_definition.py.snap index 7d633cdb..9ef53fb1 100644 --- a/typechecker/testdata/output/enderpy_python_type_checker__build__tests__symbol_table@function_definition.py.snap +++ b/typechecker/testdata/output/enderpy_python_type_checker__build__tests__symbol_table@function_definition.py.snap @@ -9,6 +9,7 @@ global scope: Symbols: func - Declarations: +<<<<<<< HEAD --: Function { declaration_path: DeclarationPath { module_name: [REDACTED]", @@ -101,6 +102,9 @@ func yeild_statements: [], raise_statements: [], } +======= +--: Function { declaration_path: DeclarationPath { module_name: ".Users.glyphack.Programming.enderpy.typechecker.test_data.inputs.symbol_table.function_definition.py", node: Node { start: 0, end: 37 } }, function_node: FunctionDef { node: Node { start: 0, end: 37 }, name: "func", args: Arguments { node: Node { start: 9, end: 29 }, posonlyargs: [Arg { node: Node { start: 9, end: 10 }, arg: "a", annotation: None }, Arg { node: Node { start: 12, end: 13 }, arg: "b", annotation: None }], args: [Arg { node: Node { start: 19, end: 24 }, arg: "c", annotation: None }], vararg: None, kwonlyargs: [], kw_defaults: [], kwarg: Some(Arg { node: Node { start: 28, end: 29 }, arg: "e", annotation: None }), defaults: [Constant(Constant { node: Node { start: 23, end: 24 }, value: 2 })] }, body: [Pass(Pass { node: Node { start: 32, end: 36 } })], decorator_list: [], returns: None, type_comment: None, type_params: [] }, is_method: false, is_generator: false, return_statements: [], yeild_statements: [], raise_statements: [] } +>>>>>>> d6d917b (Check for type alias in ast visitors) all scopes: Symbols: From 1ef5c788b8e1d4e3c8d0feefae660d62ec727345 Mon Sep 17 00:00:00 2001 From: Glyphack Date: Wed, 25 Oct 2023 21:21:57 +0200 Subject: [PATCH 4/6] Remove noisy test case --- ...ser__tests__complete@input_program.py.snap | 14329 ---------------- parser/test_data/inputs/input_program.py | 467 - 2 files changed, 14796 deletions(-) delete mode 100644 parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@input_program.py.snap delete mode 100644 parser/test_data/inputs/input_program.py diff --git a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@input_program.py.snap b/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@input_program.py.snap deleted file mode 100644 index 28cb79b3..00000000 --- a/parser/src/parser/snapshots/enderpy_python_parser__parser__parser__tests__complete@input_program.py.snap +++ /dev/null @@ -1,14329 +0,0 @@ ---- -source: parser/src/parser/parser.rs -description: "def _handle_ticker_index(symbol):\n ticker_index = symbols_data.get_ticker_index(symbol)\n\n if ticker_index is None:\n market_symbol = get_symbol_info(symbol)\n if market_symbol is not None:\n symbols_data.append_symbol_to_file(market_symbol)\n ticker_index = market_symbol.index\n return ticker_index\n\n\ndef _extract_ticker_client_types_data(ticker_index: str) -> List:\n url = TSE_CLIENT_TYPE_DATA_URL.format(ticker_index)\n with requests_retry_session() as session:\n response = session.get(url, timeout=5)\n data = response.text.split(\";\")\n data = [row.split(\",\") for row in data]\n return data\n\n\ndef _create_financial_index_from_text_response(data):\n data = pd.DataFrame(re.split(r\"\\;\", data))\n columns = [\"date\", \"high\", \"low\", \"open\", \"close\", \"volume\", \"__\"]\n data[columns] = data[0].str.split(\",\", expand=True)\n return data.drop(columns=[\"__\", 0])\n\n\ndef _adjust_data_frame(df, include_jdate):\n df.date = pd.to_datetime(df.date, format=\"%Y%m%d\")\n if include_jdate:\n df[\"jdate\"] = \"\"\n df.jdate = df.date.apply(\n lambda gregorian: jdatetime.date.fromgregorian(date=gregorian)\n )\n\n\ndef _adjust_data_frame_for_fIndex(df, include_jdate):\n df[\"date\"] = pd.to_datetime(df[\"date\"], format=\"%Y%m%d\")\n if include_jdate:\n df[\"jdate\"] = df.date.apply(\n lambda gregorian: jdatetime.date.fromgregorian(date=gregorian)\n )\n\n\ndef download(\n symbols: Union[List, str],\n write_to_csv: bool = False,\n include_jdate: bool = False,\n base_path: str = config.DATA_BASE_PATH,\n adjust: bool = False,\n) -> Dict[str, pd.DataFrame]:\n if symbols == \"all\":\n symbols = symbols_data.all_symbols()\n elif isinstance(symbols, str):\n symbols = [symbols]\n\n df_list = {}\n future_to_symbol = {}\n with futures.ThreadPoolExecutor(max_workers=10) as executor:\n session = requests_retry_session()\n for symbol in symbols:\n if (\n symbol.isnumeric()\n and symbols_data.get_ticker_index(symbol) is None\n ):\n ticker_indexes = [symbol]\n else:\n ticker_index = _handle_ticker_index(symbol)\n if ticker_index is None:\n raise Exception(f\"Cannot find symbol: {symbol}\")\n ticker_indexes = symbols_data.get_ticker_old_index(symbol)\n ticker_indexes.insert(0, ticker_index)\n\n for index in ticker_indexes:\n future = executor.submit(\n download_ticker_daily_record, index, session\n )\n\n future_to_symbol[future] = symbol\n\n for future in futures.as_completed(future_to_symbol):\n symbol = future_to_symbol[future]\n try:\n df: pd.DataFrame = future.result()\n except pd.errors.EmptyDataError as ex:\n logger.error(\n f\"Cannot read daily trade records for symbol: {symbol}\",\n extra={\"Error\": ex},\n )\n continue\n df = df.iloc[::-1].reset_index(drop=True)\n df = df.rename(columns=translations.HISTORY_FIELD_MAPPINGS)\n df = df.drop(columns=[\"\", \"\"])\n _adjust_data_frame(df, include_jdate)\n\n if symbol in df_list:\n df_list[symbol] = (\n pd.concat(\n [df_list[symbol], df], ignore_index=True, sort=False\n )\n .sort_values(\"date\")\n .reset_index(drop=True)\n )\n else:\n df_list[symbol] = df\n\n if adjust:\n df_list[symbol] = adjust_price(df_list[symbol])\n\n if write_to_csv:\n Path(base_path).mkdir(parents=True, exist_ok=True)\n if adjust:\n df_list[symbol].to_csv(\n f\"{base_path}/{symbol}-ت.csv\", index=False\n )\n else:\n df_list[symbol].to_csv(\n f\"{base_path}/{symbol}.csv\", index=False\n )\n\n if len(df_list) != len(symbols):\n print(\"Warning, download did not complete, re-run the code\")\n session.close()\n return df_list\n\n\ndef adjust_price(df: pd.DataFrame) -> pd.DataFrame:\n \"\"\"\n Adjust historical records of stock\n\n There is a capital increase/profit sharing,\n if today \"Final Close Price\" is not equal to next day\n \"Yesterday Final Close Price\" by using this ratio,\n performance adjustment of stocks is achieved\n\n Parameters\n ----------\n df : pd.DataFrame\n DataFrame with historical records.\n\n Returns\n -------\n pd.DataFrame\n DataFrame with adjusted historical records.\n\n Notes\n -----\n DataFrame can not be empty or else it makes runtime error\n Type of DataFrame must be RangeIndex to make proper range of records\n that need to be modified\n\n diff: list\n list of indexs of the day after capital increase/profit sharing\n ratio_list: List\n List of ratios to adjust historical data of stock\n ratio: Float\n ratio = df.loc[i].adjClose / df.loc[i+1].yesterday\n\n Description\n -----------\n # Note: adjustment does not include Tenth and twentieth days\n df.index = range(0,101,1)\n # step is 1\n step = df.index.step\n diff = [10,20]\n ratio_list = [0.5, 0.8]\n df.loc[0:10-step, [open,...]] * ratio[0]\n df.loc[10:20-step, [open,...]] * ratio[1]\n \"\"\"\n if df.empty or not isinstance(df.index, pd.core.indexes.range.RangeIndex):\n return df\n\n new_df = df.copy()\n step = new_df.index.step\n diff = list(new_df.index[new_df.shift(1).adjClose != new_df.yesterday])\n if len(diff) > 0:\n diff.pop(0)\n ratio = 1\n ratio_list = []\n for i in diff[::-1]:\n ratio *= (\n new_df.loc[i, \"yesterday\"] / new_df.shift(1).loc[i, \"adjClose\"]\n )\n ratio_list.insert(0, ratio)\n for i, k in enumerate(diff):\n if i == 0:\n start = new_df.index.start\n else:\n start = diff[i - 1]\n end = diff[i] - step\n new_df.loc[\n start:end,\n [\n \"open\",\n \"high\",\n \"low\",\n \"close\",\n \"adjClose\",\n \"yesterday\",\n ],\n ] = round(\n new_df.loc[\n start:end,\n [\n \"open\",\n \"high\",\n \"low\",\n \"close\",\n \"adjClose\",\n \"yesterday\",\n ],\n ]\n * ratio_list[i]\n )\n\n return new_df\n\n\n@retry(\n retry=retry_if_exception_type(HTTPError),\n wait=wait_random(min=1, max=4),\n before_sleep=before_sleep_log(logger, logging.DEBUG),\n)\ndef download_ticker_daily_record(ticker_index: str, session: Session):\n url = tse_settings.TSE_TICKER_EXPORT_DATA_ADDRESS.format(ticker_index)\n response = session.get(url, timeout=10)\n if 400 <= response.status_code < 500:\n logger.error(\n f\"Cannot read daily trade records from the url: {url}\",\n extra={\"response\": response.text, \"code\": response.status_code},\n )\n\n response.raise_for_status()\n\n data = StringIO(response.text)\n return pd.read_csv(data)\n\n\n@retry(\n retry=retry_if_exception_type(HTTPError),\n wait=wait_random(min=1, max=4),\n before_sleep=before_sleep_log(logger, logging.DEBUG),\n)\ndef download_fIndex_record(fIndex: str, session: Session):\n url = tse_settings.TSE_FINANCIAL_INDEX_EXPORT_DATA_ADDRESS.format(fIndex)\n response = session.get(url, timeout=10)\n if 400 <= response.status_code < 500:\n logger.error(\n f\"Cannot read daily trade records from the url: {url}\",\n extra={\"response\": response.text, \"code\": response.status_code},\n )\n\n response.raise_for_status()\n data = response.text\n if not data or \";\" not in data or \",\" not in data:\n raise ValueError(\n f\"\"\"Invalid response from the url: {url}.\n \\nExpected valid financial index data.\"\"\"\n )\n df = _create_financial_index_from_text_response(data)\n return df\n\n\ndef download_financial_indexes(\n symbols: Union[List, str],\n write_to_csv: bool = False,\n include_jdate: bool = False,\n base_path: str = config.FINANCIAL_INDEX_BASE_PATH,\n) -> Dict[str, pd.DataFrame]:\n if symbols == \"all\":\n symbols = symbols_data.all_financial_index()\n elif isinstance(symbols, str):\n symbols = [symbols]\n\n df_list = {}\n future_to_symbol = {}\n with futures.ThreadPoolExecutor(max_workers=10) as executor:\n session = requests_retry_session()\n for symbol in symbols:\n symbol = persian.replace_persian(symbol)\n if (\n symbol.isnumeric()\n and symbols_data.get_financial_index(symbol) is None\n ):\n financial_index = symbol\n else:\n financial_index = symbols_data.get_financial_index(symbol)\n if financial_index is None:\n raise Exception(f\"Cannot find financial index: {symbol}\")\n\n future = executor.submit(\n download_fIndex_record, financial_index, session\n )\n\n future_to_symbol[future] = symbol\n\n for future in futures.as_completed(future_to_symbol):\n symbol = future_to_symbol[future]\n try:\n df: pd.DataFrame = future.result()\n except pd.errors.EmptyDataError as ex:\n logger.error(\n f\"Cannot read daily trade records for symbol: {symbol}\",\n extra={\"Error\": ex},\n )\n continue\n _adjust_data_frame_for_fIndex(df, include_jdate)\n df_list[symbol] = df\n\n if write_to_csv:\n Path(base_path).mkdir(parents=True, exist_ok=True)\n df_list[symbol].to_csv(\n f\"{base_path}/{symbol}.csv\", index=False\n )\n\n if len(df_list) != len(symbols):\n print(\"Warning, download did not complete, re-run the code\")\n session.close()\n return df_list\n\n\ndef download_client_types_records(\n symbols: Union[List, str],\n write_to_csv: bool = False,\n include_jdate: bool = False,\n base_path: str = config.CLIENT_TYPES_DATA_BASE_PATH,\n):\n if symbols == \"all\":\n symbols = symbols_data.all_symbols()\n elif isinstance(symbols, str):\n symbols = [symbols]\n\n df_list = {}\n future_to_symbol = {}\n with futures.ThreadPoolExecutor(max_workers=10) as executor:\n for symbol in symbols:\n ticker_index = _handle_ticker_index(symbol)\n if ticker_index is None:\n raise Exception(f\"Cannot find symbol: {symbol}\")\n future = executor.submit(\n download_ticker_client_types_record, ticker_index\n )\n future_to_symbol[future] = symbol\n for future in futures.as_completed(future_to_symbol):\n symbol = future_to_symbol[future]\n df: pd.DataFrame = future.result()\n # ignore failures\n if df is None:\n continue\n _adjust_data_frame(df, include_jdate)\n df_list[symbol] = df\n if write_to_csv:\n Path(base_path).mkdir(parents=True, exist_ok=True)\n df.to_csv(f\"{base_path}/{symbol}.csv\")\n\n if len(df_list) != len(symbols):\n print(\n \"\"\"could not download client types for all the symbols make\n sure you have what you need or re-run the function\"\"\"\n )\n return df_list\n\n\n@retry(\n retry=retry_if_exception_type(HTTPError),\n wait=wait_random(min=1, max=4),\n before_sleep=before_sleep_log(logger, logging.DEBUG),\n)\ndef download_ticker_client_types_record(ticker_index: Optional[str]):\n data = _extract_ticker_client_types_data(ticker_index)\n if len(data) == 1:\n logger.warning(\n f\"\"\"Cannot create client types data for ticker{ticker_index}\n from data: {data}\"\"\",\n extra={\"ticker_index\": ticker_index},\n )\n return None\n client_types_data_frame = pd.DataFrame(\n data,\n columns=[\n \"date\",\n \"individual_buy_count\",\n \"corporate_buy_count\",\n \"individual_sell_count\",\n \"corporate_sell_count\",\n \"individual_buy_vol\",\n \"corporate_buy_vol\",\n \"individual_sell_vol\",\n \"corporate_sell_vol\",\n \"individual_buy_value\",\n \"corporate_buy_value\",\n \"individual_sell_value\",\n \"corporate_sell_value\",\n ],\n )\n for i in [\n \"individual_buy_\",\n \"individual_sell_\",\n \"corporate_buy_\",\n \"corporate_sell_\",\n ]:\n client_types_data_frame[f\"{i}mean_price\"] = client_types_data_frame[\n f\"{i}value\"\n ].astype(float) / client_types_data_frame[f\"{i}vol\"].astype(float)\n client_types_data_frame[\n \"individual_ownership_change\"\n ] = client_types_data_frame[\"corporate_sell_vol\"].astype(\n float\n ) - client_types_data_frame[\n \"corporate_buy_vol\"\n ].astype(\n float\n )\n return client_types_data_frame\n\n\ndef get_symbol_id(symbol_name: str):\n url = tse_settings.TSE_SYMBOL_ID_URL.format(symbol_name.strip())\n response = requests_retry_session().get(url, timeout=10)\n try:\n response.raise_for_status()\n except HTTPError:\n raise Exception(\"Sorry, tse server did not respond\")\n\n symbol_full_info = response.text.split(\";\")[0].split(\",\")\n if persian.replace_arabic(symbol_name) == symbol_full_info[0].strip():\n return symbol_full_info[2] # symbol id\n return None\n\n\ndef get_symbol_info(symbol_name: str):\n url = tse_settings.TSE_SYMBOL_ID_URL.format(symbol_name.strip())\n response = requests_retry_session().get(url, timeout=10)\n try:\n response.raise_for_status()\n except HTTPError:\n raise Exception(f\"{symbol_name}: Sorry, tse server did not respond\")\n\n symbols = response.text.split(\";\")\n market_symbol = MarketSymbol(\n code=None,\n symbol=None,\n index=None,\n name=None,\n old=[],\n )\n for symbol_full_info in symbols:\n if symbol_full_info.strip() == \"\":\n continue\n symbol_full_info = symbol_full_info.split(\",\")\n if persian.replace_arabic(symbol_full_info[0]) == symbol_name:\n # if symbol id is active\n if symbol_full_info[7] == \"1\":\n market_symbol.symbol = persian.replace_arabic(\n symbol_full_info[0]\n )\n market_symbol.name = persian.replace_arabic(\n symbol_full_info[1]\n )\n market_symbol.index = symbol_full_info[2] # active symbol id\n else:\n market_symbol.old.append(symbol_full_info[2]) # old symbol id\n\n if market_symbol.index is None:\n return None\n return market_symbol\n\n" -input_file: parser/test_data/inputs/input_program.py ---- -Module { - node: Node { - start: 0, - end: 15273, - }, - body: [ - FunctionDef( - FunctionDef { - node: Node { - start: 0, - end: 342, - }, - name: "_handle_ticker_index", - args: Arguments { - node: Node { - start: 25, - end: 31, - }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 25, - end: 31, - }, - arg: "symbol", - annotation: None, - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: [ - AssignStatement( - Assign { - node: Node { - start: 38, - end: 90, - }, - targets: [ - Name( - Name { - node: Node { - start: 38, - end: 50, - }, - id: "ticker_index", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 82, - end: 90, - }, - func: Attribute( - Attribute { - node: Node { - start: 53, - end: 82, - }, - value: Name( - Name { - node: Node { - start: 53, - end: 65, - }, - id: "symbols_data", - }, - ), - attr: "get_ticker_index", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 83, - end: 89, - }, - id: "symbol", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - IfStatement( - If { - node: Node { - start: 96, - end: 320, - }, - test: Compare( - Compare { - node: Node { - start: 99, - end: 119, - }, - left: Name( - Name { - node: Node { - start: 99, - end: 111, - }, - id: "ticker_index", - }, - ), - ops: [ - Is, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 115, - end: 119, - }, - value: None, - }, - ), - ], - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 129, - end: 168, - }, - targets: [ - Name( - Name { - node: Node { - start: 129, - end: 142, - }, - id: "market_symbol", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 145, - end: 168, - }, - func: Name( - Name { - node: Node { - start: 145, - end: 160, - }, - id: "get_symbol_info", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 161, - end: 167, - }, - id: "symbol", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - IfStatement( - If { - node: Node { - start: 177, - end: 320, - }, - test: Compare( - Compare { - node: Node { - start: 180, - end: 205, - }, - left: Name( - Name { - node: Node { - start: 180, - end: 193, - }, - id: "market_symbol", - }, - ), - ops: [ - IsNot, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 201, - end: 205, - }, - value: None, - }, - ), - ], - }, - ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 253, - end: 268, - }, - func: Attribute( - Attribute { - node: Node { - start: 219, - end: 253, - }, - value: Name( - Name { - node: Node { - start: 219, - end: 231, - }, - id: "symbols_data", - }, - ), - attr: "append_symbol_to_file", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 254, - end: 267, - }, - id: "market_symbol", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - AssignStatement( - Assign { - node: Node { - start: 281, - end: 315, - }, - targets: [ - Name( - Name { - node: Node { - start: 281, - end: 293, - }, - id: "ticker_index", - }, - ), - ], - value: Attribute( - Attribute { - node: Node { - start: 296, - end: 315, - }, - value: Name( - Name { - node: Node { - start: 296, - end: 309, - }, - id: "market_symbol", - }, - ), - attr: "index", - }, - ), - }, - ), - ], - orelse: [], - }, - ), - ], - orelse: [], - }, - ), - Return( - Return { - node: Node { - start: 320, - end: 339, - }, - value: Some( - Name( - Name { - node: Node { - start: 327, - end: 339, - }, - id: "ticker_index", - }, - ), - ), - }, - ), - ], - decorator_list: [], - returns: None, - type_comment: None, - type_params: [], - }, - ), - FunctionDef( - FunctionDef { - node: Node { - start: 342, - end: 655, - }, - name: "_extract_ticker_client_types_data", - args: Arguments { - node: Node { - start: 380, - end: 397, - }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 380, - end: 397, - }, - arg: "ticker_index", - annotation: Some( - Name( - Name { - node: Node { - start: 394, - end: 397, - }, - id: "str", - }, - ), - ), - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: [ - AssignStatement( - Assign { - node: Node { - start: 412, - end: 463, - }, - targets: [ - Name( - Name { - node: Node { - start: 412, - end: 415, - }, - id: "url", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 449, - end: 463, - }, - func: Attribute( - Attribute { - node: Node { - start: 418, - end: 449, - }, - value: Name( - Name { - node: Node { - start: 418, - end: 442, - }, - id: "TSE_CLIENT_TYPE_DATA_URL", - }, - ), - attr: "format", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 450, - end: 462, - }, - id: "ticker_index", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - WithStatement( - With { - node: Node { - start: 468, - end: 561, - }, - items: [ - WithItem { - node: Node { - start: 473, - end: 508, - }, - context_expr: Call( - Call { - node: Node { - start: 473, - end: 497, - }, - func: Name( - Name { - node: Node { - start: 473, - end: 495, - }, - id: "requests_retry_session", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - optional_vars: Some( - Name( - Name { - node: Node { - start: 501, - end: 508, - }, - id: "session", - }, - ), - ), - }, - ], - body: [ - AssignStatement( - Assign { - node: Node { - start: 518, - end: 556, - }, - targets: [ - Name( - Name { - node: Node { - start: 518, - end: 526, - }, - id: "response", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 540, - end: 556, - }, - func: Attribute( - Attribute { - node: Node { - start: 529, - end: 540, - }, - value: Name( - Name { - node: Node { - start: 529, - end: 536, - }, - id: "session", - }, - ), - attr: "get", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 541, - end: 544, - }, - id: "url", - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 546, - end: 555, - }, - arg: Some( - "timeout", - ), - value: Constant( - Constant { - node: Node { - start: 554, - end: 555, - }, - value: 5, - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ], - }, - ), - AssignStatement( - Assign { - node: Node { - start: 561, - end: 592, - }, - targets: [ - Name( - Name { - node: Node { - start: 561, - end: 565, - }, - id: "data", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 587, - end: 592, - }, - func: Attribute( - Attribute { - node: Node { - start: 568, - end: 587, - }, - value: Attribute( - Attribute { - node: Node { - start: 568, - end: 581, - }, - value: Name( - Name { - node: Node { - start: 568, - end: 576, - }, - id: "response", - }, - ), - attr: "text", - }, - ), - attr: "split", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 588, - end: 591, - }, - value: ";", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 597, - end: 636, - }, - targets: [ - Name( - Name { - node: Node { - start: 597, - end: 601, - }, - id: "data", - }, - ), - ], - value: ListComp( - ListComp { - node: Node { - start: 604, - end: 636, - }, - element: Call( - Call { - node: Node { - start: 614, - end: 619, - }, - func: Attribute( - Attribute { - node: Node { - start: 605, - end: 614, - }, - value: Name( - Name { - node: Node { - start: 605, - end: 608, - }, - id: "row", - }, - ), - attr: "split", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 615, - end: 618, - }, - value: ",", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - generators: [ - Comprehension { - node: Node { - start: 620, - end: 635, - }, - target: Name( - Name { - node: Node { - start: 624, - end: 627, - }, - id: "row", - }, - ), - iter: Name( - Name { - node: Node { - start: 631, - end: 635, - }, - id: "data", - }, - ), - ifs: [], - is_async: false, - }, - ], - }, - ), - }, - ), - Return( - Return { - node: Node { - start: 641, - end: 652, - }, - value: Some( - Name( - Name { - node: Node { - start: 648, - end: 652, - }, - id: "data", - }, - ), - ), - }, - ), - ], - decorator_list: [], - returns: Some( - Name( - Name { - node: Node { - start: 402, - end: 406, - }, - id: "List", - }, - ), - ), - type_comment: None, - type_params: [], - }, - ), - FunctionDef( - FunctionDef { - node: Node { - start: 655, - end: 925, - }, - name: "_create_financial_index_from_text_response", - args: Arguments { - node: Node { - start: 702, - end: 706, - }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 702, - end: 706, - }, - arg: "data", - annotation: None, - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: [ - AssignStatement( - Assign { - node: Node { - start: 713, - end: 755, - }, - targets: [ - Name( - Name { - node: Node { - start: 713, - end: 717, - }, - id: "data", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 732, - end: 755, - }, - func: Attribute( - Attribute { - node: Node { - start: 720, - end: 732, - }, - value: Name( - Name { - node: Node { - start: 720, - end: 722, - }, - id: "pd", - }, - ), - attr: "DataFrame", - }, - ), - args: [ - Call( - Call { - node: Node { - start: 741, - end: 754, - }, - func: Attribute( - Attribute { - node: Node { - start: 733, - end: 741, - }, - value: Name( - Name { - node: Node { - start: 733, - end: 735, - }, - id: "re", - }, - ), - attr: "split", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 742, - end: 747, - }, - value: "\\;", - }, - ), - Name( - Name { - node: Node { - start: 749, - end: 753, - }, - id: "data", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 760, - end: 826, - }, - targets: [ - Name( - Name { - node: Node { - start: 760, - end: 767, - }, - id: "columns", - }, - ), - ], - value: List( - List { - node: Node { - start: 770, - end: 826, - }, - elements: [ - Constant( - Constant { - node: Node { - start: 771, - end: 777, - }, - value: "date", - }, - ), - Constant( - Constant { - node: Node { - start: 779, - end: 785, - }, - value: "high", - }, - ), - Constant( - Constant { - node: Node { - start: 787, - end: 792, - }, - value: "low", - }, - ), - Constant( - Constant { - node: Node { - start: 794, - end: 800, - }, - value: "open", - }, - ), - Constant( - Constant { - node: Node { - start: 802, - end: 809, - }, - value: "close", - }, - ), - Constant( - Constant { - node: Node { - start: 811, - end: 819, - }, - value: "volume", - }, - ), - Constant( - Constant { - node: Node { - start: 821, - end: 825, - }, - value: "__", - }, - ), - ], - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 831, - end: 882, - }, - targets: [ - Subscript( - Subscript { - node: Node { - start: 831, - end: 844, - }, - value: Name( - Name { - node: Node { - start: 831, - end: 835, - }, - id: "data", - }, - ), - slice: Name( - Name { - node: Node { - start: 836, - end: 843, - }, - id: "columns", - }, - ), - }, - ), - ], - value: Call( - Call { - node: Node { - start: 864, - end: 882, - }, - func: Attribute( - Attribute { - node: Node { - start: 854, - end: 864, - }, - value: Attribute( - Attribute { - node: Node { - start: 854, - end: 858, - }, - value: Subscript( - Subscript { - node: Node { - start: 847, - end: 854, - }, - value: Name( - Name { - node: Node { - start: 847, - end: 851, - }, - id: "data", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 852, - end: 853, - }, - value: 0, - }, - ), - }, - ), - attr: "str", - }, - ), - attr: "split", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 865, - end: 868, - }, - value: ",", - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 870, - end: 881, - }, - arg: Some( - "expand", - ), - value: Constant( - Constant { - node: Node { - start: 877, - end: 881, - }, - value: true, - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - ), - Return( - Return { - node: Node { - start: 887, - end: 922, - }, - value: Some( - Call( - Call { - node: Node { - start: 903, - end: 922, - }, - func: Attribute( - Attribute { - node: Node { - start: 894, - end: 903, - }, - value: Name( - Name { - node: Node { - start: 894, - end: 898, - }, - id: "data", - }, - ), - attr: "drop", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 904, - end: 921, - }, - arg: Some( - "columns", - ), - value: List( - List { - node: Node { - start: 912, - end: 921, - }, - elements: [ - Constant( - Constant { - node: Node { - start: 913, - end: 917, - }, - value: "__", - }, - ), - Constant( - Constant { - node: Node { - start: 919, - end: 920, - }, - value: 0, - }, - ), - ], - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ), - }, - ), - ], - decorator_list: [], - returns: None, - type_comment: None, - type_params: [], - }, - ), - FunctionDef( - FunctionDef { - node: Node { - start: 925, - end: 1191, - }, - name: "_adjust_data_frame", - args: Arguments { - node: Node { - start: 948, - end: 965, - }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 948, - end: 950, - }, - arg: "df", - annotation: None, - }, - Arg { - node: Node { - start: 952, - end: 965, - }, - arg: "include_jdate", - annotation: None, - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: [ - AssignStatement( - Assign { - node: Node { - start: 972, - end: 1022, - }, - targets: [ - Attribute( - Attribute { - node: Node { - start: 972, - end: 979, - }, - value: Name( - Name { - node: Node { - start: 972, - end: 974, - }, - id: "df", - }, - ), - attr: "date", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 996, - end: 1022, - }, - func: Attribute( - Attribute { - node: Node { - start: 982, - end: 996, - }, - value: Name( - Name { - node: Node { - start: 982, - end: 984, - }, - id: "pd", - }, - ), - attr: "to_datetime", - }, - ), - args: [ - Attribute( - Attribute { - node: Node { - start: 997, - end: 1004, - }, - value: Name( - Name { - node: Node { - start: 997, - end: 999, - }, - id: "df", - }, - ), - attr: "date", - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 1006, - end: 1021, - }, - arg: Some( - "format", - ), - value: Constant( - Constant { - node: Node { - start: 1013, - end: 1021, - }, - value: "%Y%m%d", - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - ), - IfStatement( - If { - node: Node { - start: 1027, - end: 1191, - }, - test: Name( - Name { - node: Node { - start: 1030, - end: 1043, - }, - id: "include_jdate", - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 1053, - end: 1069, - }, - targets: [ - Subscript( - Subscript { - node: Node { - start: 1053, - end: 1064, - }, - value: Name( - Name { - node: Node { - start: 1053, - end: 1055, - }, - id: "df", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 1056, - end: 1063, - }, - value: "jdate", - }, - ), - }, - ), - ], - value: Constant( - Constant { - node: Node { - start: 1067, - end: 1069, - }, - value: "", - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 1078, - end: 1188, - }, - targets: [ - Attribute( - Attribute { - node: Node { - start: 1078, - end: 1086, - }, - value: Name( - Name { - node: Node { - start: 1078, - end: 1080, - }, - id: "df", - }, - ), - attr: "jdate", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 1102, - end: 1188, - }, - func: Attribute( - Attribute { - node: Node { - start: 1089, - end: 1102, - }, - value: Attribute( - Attribute { - node: Node { - start: 1089, - end: 1096, - }, - value: Name( - Name { - node: Node { - start: 1089, - end: 1091, - }, - id: "df", - }, - ), - attr: "date", - }, - ), - attr: "apply", - }, - ), - args: [ - Lambda( - Lambda { - node: Node { - start: 1116, - end: 1178, - }, - args: Arguments { - node: Node { - start: 1123, - end: 1132, - }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 1123, - end: 1132, - }, - arg: "gregorian", - annotation: None, - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: Call( - Call { - node: Node { - start: 1162, - end: 1178, - }, - func: Attribute( - Attribute { - node: Node { - start: 1134, - end: 1162, - }, - value: Attribute( - Attribute { - node: Node { - start: 1134, - end: 1148, - }, - value: Name( - Name { - node: Node { - start: 1134, - end: 1143, - }, - id: "jdatetime", - }, - ), - attr: "date", - }, - ), - attr: "fromgregorian", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 1163, - end: 1177, - }, - arg: Some( - "date", - ), - value: Name( - Name { - node: Node { - start: 1168, - end: 1177, - }, - id: "gregorian", - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ], - orelse: [], - }, - ), - ], - decorator_list: [], - returns: None, - type_comment: None, - type_params: [], - }, - ), - FunctionDef( - FunctionDef { - node: Node { - start: 1191, - end: 1452, - }, - name: "_adjust_data_frame_for_fIndex", - args: Arguments { - node: Node { - start: 1225, - end: 1242, - }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 1225, - end: 1227, - }, - arg: "df", - annotation: None, - }, - Arg { - node: Node { - start: 1229, - end: 1242, - }, - arg: "include_jdate", - annotation: None, - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: [ - AssignStatement( - Assign { - node: Node { - start: 1249, - end: 1305, - }, - targets: [ - Subscript( - Subscript { - node: Node { - start: 1249, - end: 1259, - }, - value: Name( - Name { - node: Node { - start: 1249, - end: 1251, - }, - id: "df", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 1252, - end: 1258, - }, - value: "date", - }, - ), - }, - ), - ], - value: Call( - Call { - node: Node { - start: 1276, - end: 1305, - }, - func: Attribute( - Attribute { - node: Node { - start: 1262, - end: 1276, - }, - value: Name( - Name { - node: Node { - start: 1262, - end: 1264, - }, - id: "pd", - }, - ), - attr: "to_datetime", - }, - ), - args: [ - Subscript( - Subscript { - node: Node { - start: 1277, - end: 1287, - }, - value: Name( - Name { - node: Node { - start: 1277, - end: 1279, - }, - id: "df", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 1280, - end: 1286, - }, - value: "date", - }, - ), - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 1289, - end: 1304, - }, - arg: Some( - "format", - ), - value: Constant( - Constant { - node: Node { - start: 1296, - end: 1304, - }, - value: "%Y%m%d", - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - ), - IfStatement( - If { - node: Node { - start: 1310, - end: 1452, - }, - test: Name( - Name { - node: Node { - start: 1313, - end: 1326, - }, - id: "include_jdate", - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 1336, - end: 1449, - }, - targets: [ - Subscript( - Subscript { - node: Node { - start: 1336, - end: 1347, - }, - value: Name( - Name { - node: Node { - start: 1336, - end: 1338, - }, - id: "df", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 1339, - end: 1346, - }, - value: "jdate", - }, - ), - }, - ), - ], - value: Call( - Call { - node: Node { - start: 1363, - end: 1449, - }, - func: Attribute( - Attribute { - node: Node { - start: 1350, - end: 1363, - }, - value: Attribute( - Attribute { - node: Node { - start: 1350, - end: 1357, - }, - value: Name( - Name { - node: Node { - start: 1350, - end: 1352, - }, - id: "df", - }, - ), - attr: "date", - }, - ), - attr: "apply", - }, - ), - args: [ - Lambda( - Lambda { - node: Node { - start: 1377, - end: 1439, - }, - args: Arguments { - node: Node { - start: 1384, - end: 1393, - }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 1384, - end: 1393, - }, - arg: "gregorian", - annotation: None, - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: Call( - Call { - node: Node { - start: 1423, - end: 1439, - }, - func: Attribute( - Attribute { - node: Node { - start: 1395, - end: 1423, - }, - value: Attribute( - Attribute { - node: Node { - start: 1395, - end: 1409, - }, - value: Name( - Name { - node: Node { - start: 1395, - end: 1404, - }, - id: "jdatetime", - }, - ), - attr: "date", - }, - ), - attr: "fromgregorian", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 1424, - end: 1438, - }, - arg: Some( - "date", - ), - value: Name( - Name { - node: Node { - start: 1429, - end: 1438, - }, - id: "gregorian", - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ], - orelse: [], - }, - ), - ], - decorator_list: [], - returns: None, - type_comment: None, - type_params: [], - }, - ), - FunctionDef( - FunctionDef { - node: Node { - start: 1452, - end: 4346, - }, - name: "download", - args: Arguments { - node: Node { - start: 1470, - end: 1631, - }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 1470, - end: 1495, - }, - arg: "symbols", - annotation: Some( - Subscript( - Subscript { - node: Node { - start: 1479, - end: 1495, - }, - value: Name( - Name { - node: Node { - start: 1479, - end: 1484, - }, - id: "Union", - }, - ), - slice: Tuple( - Tuple { - node: Node { - start: 1485, - end: 1495, - }, - elements: [ - Name( - Name { - node: Node { - start: 1485, - end: 1489, - }, - id: "List", - }, - ), - Name( - Name { - node: Node { - start: 1491, - end: 1494, - }, - id: "str", - }, - ), - ], - }, - ), - }, - ), - ), - }, - Arg { - node: Node { - start: 1501, - end: 1527, - }, - arg: "write_to_csv", - annotation: Some( - Name( - Name { - node: Node { - start: 1515, - end: 1519, - }, - id: "bool", - }, - ), - ), - }, - Arg { - node: Node { - start: 1533, - end: 1560, - }, - arg: "include_jdate", - annotation: Some( - Name( - Name { - node: Node { - start: 1548, - end: 1552, - }, - id: "bool", - }, - ), - ), - }, - Arg { - node: Node { - start: 1566, - end: 1604, - }, - arg: "base_path", - annotation: Some( - Name( - Name { - node: Node { - start: 1577, - end: 1580, - }, - id: "str", - }, - ), - ), - }, - Arg { - node: Node { - start: 1610, - end: 1630, - }, - arg: "adjust", - annotation: Some( - Name( - Name { - node: Node { - start: 1618, - end: 1622, - }, - id: "bool", - }, - ), - ), - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [ - Constant( - Constant { - node: Node { - start: 1522, - end: 1527, - }, - value: false, - }, - ), - Constant( - Constant { - node: Node { - start: 1555, - end: 1560, - }, - value: false, - }, - ), - Attribute( - Attribute { - node: Node { - start: 1583, - end: 1604, - }, - value: Name( - Name { - node: Node { - start: 1583, - end: 1589, - }, - id: "config", - }, - ), - attr: "DATA_BASE_PATH", - }, - ), - Constant( - Constant { - node: Node { - start: 1625, - end: 1630, - }, - value: false, - }, - ), - ], - }, - body: [ - IfStatement( - If { - node: Node { - start: 1666, - end: 1800, - }, - test: Compare( - Compare { - node: Node { - start: 1669, - end: 1685, - }, - left: Name( - Name { - node: Node { - start: 1669, - end: 1676, - }, - id: "symbols", - }, - ), - ops: [ - Eq, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 1680, - end: 1685, - }, - value: "all", - }, - ), - ], - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 1695, - end: 1731, - }, - targets: [ - Name( - Name { - node: Node { - start: 1695, - end: 1702, - }, - id: "symbols", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 1729, - end: 1731, - }, - func: Attribute( - Attribute { - node: Node { - start: 1705, - end: 1729, - }, - value: Name( - Name { - node: Node { - start: 1705, - end: 1717, - }, - id: "symbols_data", - }, - ), - attr: "all_symbols", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ], - orelse: [ - IfStatement( - If { - node: Node { - start: 1736, - end: 1800, - }, - test: Call( - Call { - node: Node { - start: 1741, - end: 1765, - }, - func: Name( - Name { - node: Node { - start: 1741, - end: 1751, - }, - id: "isinstance", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 1752, - end: 1759, - }, - id: "symbols", - }, - ), - Name( - Name { - node: Node { - start: 1761, - end: 1764, - }, - id: "str", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 1775, - end: 1794, - }, - targets: [ - Name( - Name { - node: Node { - start: 1775, - end: 1782, - }, - id: "symbols", - }, - ), - ], - value: List( - List { - node: Node { - start: 1785, - end: 1794, - }, - elements: [ - Name( - Name { - node: Node { - start: 1786, - end: 1793, - }, - id: "symbols", - }, - ), - ], - }, - ), - }, - ), - ], - orelse: [], - }, - ), - ], - }, - ), - AssignStatement( - Assign { - node: Node { - start: 1800, - end: 1812, - }, - targets: [ - Name( - Name { - node: Node { - start: 1800, - end: 1807, - }, - id: "df_list", - }, - ), - ], - value: Dict( - Dict { - node: Node { - start: 1810, - end: 1812, - }, - keys: [], - values: [], - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 1817, - end: 1838, - }, - targets: [ - Name( - Name { - node: Node { - start: 1817, - end: 1833, - }, - id: "future_to_symbol", - }, - ), - ], - value: Dict( - Dict { - node: Node { - start: 1836, - end: 1838, - }, - keys: [], - values: [], - }, - ), - }, - ), - WithStatement( - With { - node: Node { - start: 1843, - end: 4203, - }, - items: [ - WithItem { - node: Node { - start: 1848, - end: 1902, - }, - context_expr: Call( - Call { - node: Node { - start: 1874, - end: 1890, - }, - func: Attribute( - Attribute { - node: Node { - start: 1848, - end: 1874, - }, - value: Name( - Name { - node: Node { - start: 1848, - end: 1855, - }, - id: "futures", - }, - ), - attr: "ThreadPoolExecutor", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 1875, - end: 1889, - }, - arg: Some( - "max_workers", - ), - value: Constant( - Constant { - node: Node { - start: 1887, - end: 1889, - }, - value: 10, - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - optional_vars: Some( - Name( - Name { - node: Node { - start: 1894, - end: 1902, - }, - id: "executor", - }, - ), - ), - }, - ], - body: [ - AssignStatement( - Assign { - node: Node { - start: 1912, - end: 1946, - }, - targets: [ - Name( - Name { - node: Node { - start: 1912, - end: 1919, - }, - id: "session", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 1922, - end: 1946, - }, - func: Name( - Name { - node: Node { - start: 1922, - end: 1944, - }, - id: "requests_retry_session", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ForStatement( - For { - node: Node { - start: 1955, - end: 2698, - }, - target: Name( - Name { - node: Node { - start: 1959, - end: 1965, - }, - id: "symbol", - }, - ), - iter: Name( - Name { - node: Node { - start: 1969, - end: 1976, - }, - id: "symbols", - }, - ), - body: [ - IfStatement( - If { - node: Node { - start: 1990, - end: 2484, - }, - test: BoolOp( - BoolOperation { - node: Node { - start: 2011, - end: 2095, - }, - op: And, - values: [ - Call( - Call { - node: Node { - start: 2027, - end: 2029, - }, - func: Attribute( - Attribute { - node: Node { - start: 2011, - end: 2027, - }, - value: Name( - Name { - node: Node { - start: 2011, - end: 2017, - }, - id: "symbol", - }, - ), - attr: "isnumeric", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - Compare( - Compare { - node: Node { - start: 2050, - end: 2095, - }, - left: Call( - Call { - node: Node { - start: 2079, - end: 2087, - }, - func: Attribute( - Attribute { - node: Node { - start: 2050, - end: 2079, - }, - value: Name( - Name { - node: Node { - start: 2050, - end: 2062, - }, - id: "symbols_data", - }, - ), - attr: "get_ticker_index", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 2080, - end: 2086, - }, - id: "symbol", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ops: [ - Is, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 2091, - end: 2095, - }, - value: None, - }, - ), - ], - }, - ), - ], - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 2127, - end: 2152, - }, - targets: [ - Name( - Name { - node: Node { - start: 2127, - end: 2141, - }, - id: "ticker_indexes", - }, - ), - ], - value: List( - List { - node: Node { - start: 2144, - end: 2152, - }, - elements: [ - Name( - Name { - node: Node { - start: 2145, - end: 2151, - }, - id: "symbol", - }, - ), - ], - }, - ), - }, - ), - ], - orelse: [ - AssignStatement( - Assign { - node: Node { - start: 2187, - end: 2230, - }, - targets: [ - Name( - Name { - node: Node { - start: 2187, - end: 2199, - }, - id: "ticker_index", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 2202, - end: 2230, - }, - func: Name( - Name { - node: Node { - start: 2202, - end: 2222, - }, - id: "_handle_ticker_index", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 2223, - end: 2229, - }, - id: "symbol", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - IfStatement( - If { - node: Node { - start: 2247, - end: 2357, - }, - test: Compare( - Compare { - node: Node { - start: 2250, - end: 2270, - }, - left: Name( - Name { - node: Node { - start: 2250, - end: 2262, - }, - id: "ticker_index", - }, - ), - ops: [ - Is, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 2266, - end: 2270, - }, - value: None, - }, - ), - ], - }, - ), - body: [ - Raise( - Raise { - node: Node { - start: 2292, - end: 2340, - }, - exc: Some( - Call( - Call { - node: Node { - start: 2298, - end: 2340, - }, - func: Name( - Name { - node: Node { - start: 2298, - end: 2307, - }, - id: "Exception", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 2308, - end: 2339, - }, - values: [ - Constant( - Constant { - node: Node { - start: 2330, - end: 0, - }, - value: "Cannot find symbol: ", - }, - ), - Name( - Name { - node: Node { - start: 2331, - end: 2337, - }, - id: "symbol", - }, - ), - ], - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - cause: None, - }, - ), - ], - orelse: [], - }, - ), - AssignStatement( - Assign { - node: Node { - start: 2357, - end: 2415, - }, - targets: [ - Name( - Name { - node: Node { - start: 2357, - end: 2371, - }, - id: "ticker_indexes", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 2407, - end: 2415, - }, - func: Attribute( - Attribute { - node: Node { - start: 2374, - end: 2407, - }, - value: Name( - Name { - node: Node { - start: 2374, - end: 2386, - }, - id: "symbols_data", - }, - ), - attr: "get_ticker_old_index", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 2408, - end: 2414, - }, - id: "symbol", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ExpressionStatement( - Call( - Call { - node: Node { - start: 2453, - end: 2470, - }, - func: Attribute( - Attribute { - node: Node { - start: 2432, - end: 2453, - }, - value: Name( - Name { - node: Node { - start: 2432, - end: 2446, - }, - id: "ticker_indexes", - }, - ), - attr: "insert", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 2454, - end: 2455, - }, - value: 0, - }, - ), - Name( - Name { - node: Node { - start: 2457, - end: 2469, - }, - id: "ticker_index", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - ], - }, - ), - ForStatement( - For { - node: Node { - start: 2484, - end: 2698, - }, - target: Name( - Name { - node: Node { - start: 2488, - end: 2493, - }, - id: "index", - }, - ), - iter: Name( - Name { - node: Node { - start: 2497, - end: 2511, - }, - id: "ticker_indexes", - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 2529, - end: 2637, - }, - targets: [ - Name( - Name { - node: Node { - start: 2529, - end: 2535, - }, - id: "future", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 2553, - end: 2637, - }, - func: Attribute( - Attribute { - node: Node { - start: 2538, - end: 2553, - }, - value: Name( - Name { - node: Node { - start: 2538, - end: 2546, - }, - id: "executor", - }, - ), - attr: "submit", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 2575, - end: 2603, - }, - id: "download_ticker_daily_record", - }, - ), - Name( - Name { - node: Node { - start: 2605, - end: 2610, - }, - id: "index", - }, - ), - Name( - Name { - node: Node { - start: 2612, - end: 2619, - }, - id: "session", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 2655, - end: 2688, - }, - targets: [ - Subscript( - Subscript { - node: Node { - start: 2655, - end: 2679, - }, - value: Name( - Name { - node: Node { - start: 2655, - end: 2671, - }, - id: "future_to_symbol", - }, - ), - slice: Name( - Name { - node: Node { - start: 2672, - end: 2678, - }, - id: "future", - }, - ), - }, - ), - ], - value: Name( - Name { - node: Node { - start: 2682, - end: 2688, - }, - id: "symbol", - }, - ), - }, - ), - ], - orelse: [], - }, - ), - ], - orelse: [], - }, - ), - ForStatement( - For { - node: Node { - start: 2698, - end: 4203, - }, - target: Name( - Name { - node: Node { - start: 2702, - end: 2708, - }, - id: "future", - }, - ), - iter: Call( - Call { - node: Node { - start: 2732, - end: 2750, - }, - func: Attribute( - Attribute { - node: Node { - start: 2712, - end: 2732, - }, - value: Name( - Name { - node: Node { - start: 2712, - end: 2719, - }, - id: "futures", - }, - ), - attr: "as_completed", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 2733, - end: 2749, - }, - id: "future_to_symbol", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 2764, - end: 2797, - }, - targets: [ - Name( - Name { - node: Node { - start: 2764, - end: 2770, - }, - id: "symbol", - }, - ), - ], - value: Subscript( - Subscript { - node: Node { - start: 2773, - end: 2797, - }, - value: Name( - Name { - node: Node { - start: 2773, - end: 2789, - }, - id: "future_to_symbol", - }, - ), - slice: Name( - Name { - node: Node { - start: 2790, - end: 2796, - }, - id: "future", - }, - ), - }, - ), - }, - ), - TryStatement( - Try { - node: Node { - start: 2810, - end: 3120, - }, - body: [ - AnnAssignStatement( - AnnAssign { - node: Node { - start: 2831, - end: 2865, - }, - target: Name( - Name { - node: Node { - start: 2831, - end: 2833, - }, - id: "df", - }, - ), - annotation: Attribute( - Attribute { - node: Node { - start: 2835, - end: 2847, - }, - value: Name( - Name { - node: Node { - start: 2835, - end: 2837, - }, - id: "pd", - }, - ), - attr: "DataFrame", - }, - ), - value: Some( - Call( - Call { - node: Node { - start: 2863, - end: 2865, - }, - func: Attribute( - Attribute { - node: Node { - start: 2850, - end: 2863, - }, - value: Name( - Name { - node: Node { - start: 2850, - end: 2856, - }, - id: "future", - }, - ), - attr: "result", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - simple: true, - }, - ), - ], - handlers: [ - ExceptHandler { - node: Node { - start: 2878, - end: 3120, - }, - typ: Some( - Attribute( - Attribute { - node: Node { - start: 2885, - end: 2909, - }, - value: Attribute( - Attribute { - node: Node { - start: 2885, - end: 2894, - }, - value: Name( - Name { - node: Node { - start: 2885, - end: 2887, - }, - id: "pd", - }, - ), - attr: "errors", - }, - ), - attr: "EmptyDataError", - }, - ), - ), - name: Some( - "ex", - ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 2945, - end: 3082, - }, - func: Attribute( - Attribute { - node: Node { - start: 2933, - end: 2945, - }, - value: Name( - Name { - node: Node { - start: 2933, - end: 2939, - }, - id: "logger", - }, - ), - attr: "error", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 2967, - end: 3022, - }, - values: [ - Constant( - Constant { - node: Node { - start: 3013, - end: 0, - }, - value: "Cannot read daily trade records for symbol: ", - }, - ), - Name( - Name { - node: Node { - start: 3014, - end: 3020, - }, - id: "symbol", - }, - ), - ], - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 3044, - end: 3063, - }, - arg: Some( - "extra", - ), - value: Dict( - Dict { - node: Node { - start: 3050, - end: 3063, - }, - keys: [ - Constant( - Constant { - node: Node { - start: 3051, - end: 3058, - }, - value: "Error", - }, - ), - ], - values: [ - Name( - Name { - node: Node { - start: 3060, - end: 3062, - }, - id: "ex", - }, - ), - ], - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ), - Continue( - Continue { - node: Node { - start: 3099, - end: 3107, - }, - }, - ), - ], - }, - ], - orelse: [], - finalbody: [], - }, - ), - AssignStatement( - Assign { - node: Node { - start: 3120, - end: 3161, - }, - targets: [ - Name( - Name { - node: Node { - start: 3120, - end: 3122, - }, - id: "df", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 3150, - end: 3161, - }, - func: Attribute( - Attribute { - node: Node { - start: 3138, - end: 3150, - }, - value: Subscript( - Subscript { - node: Node { - start: 3132, - end: 3138, - }, - value: Attribute( - Attribute { - node: Node { - start: 3125, - end: 3132, - }, - value: Name( - Name { - node: Node { - start: 3125, - end: 3127, - }, - id: "df", - }, - ), - attr: "iloc", - }, - ), - slice: Slice( - Slice { - node: Node { - start: 3133, - end: 3137, - }, - lower: None, - upper: Some( - UnaryOp( - UnaryOperation { - node: Node { - start: 3135, - end: 3137, - }, - op: USub, - operand: Constant( - Constant { - node: Node { - start: 3136, - end: 3137, - }, - value: 1, - }, - ), - }, - ), - ), - step: None, - }, - ), - }, - ), - attr: "reset_index", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 3151, - end: 3160, - }, - arg: Some( - "drop", - ), - value: Constant( - Constant { - node: Node { - start: 3156, - end: 3160, - }, - value: true, - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 3174, - end: 3233, - }, - targets: [ - Name( - Name { - node: Node { - start: 3174, - end: 3176, - }, - id: "df", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 3188, - end: 3233, - }, - func: Attribute( - Attribute { - node: Node { - start: 3179, - end: 3188, - }, - value: Name( - Name { - node: Node { - start: 3179, - end: 3181, - }, - id: "df", - }, - ), - attr: "rename", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 3189, - end: 3232, - }, - arg: Some( - "columns", - ), - value: Attribute( - Attribute { - node: Node { - start: 3197, - end: 3232, - }, - value: Name( - Name { - node: Node { - start: 3197, - end: 3209, - }, - id: "translations", - }, - ), - attr: "HISTORY_FIELD_MAPPINGS", - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 3246, - end: 3289, - }, - targets: [ - Name( - Name { - node: Node { - start: 3246, - end: 3248, - }, - id: "df", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 3258, - end: 3289, - }, - func: Attribute( - Attribute { - node: Node { - start: 3251, - end: 3258, - }, - value: Name( - Name { - node: Node { - start: 3251, - end: 3253, - }, - id: "df", - }, - ), - attr: "drop", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 3259, - end: 3288, - }, - arg: Some( - "columns", - ), - value: List( - List { - node: Node { - start: 3267, - end: 3288, - }, - elements: [ - Constant( - Constant { - node: Node { - start: 3268, - end: 3275, - }, - value: "", - }, - ), - Constant( - Constant { - node: Node { - start: 3277, - end: 3287, - }, - value: "", - }, - ), - ], - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ExpressionStatement( - Call( - Call { - node: Node { - start: 3302, - end: 3339, - }, - func: Name( - Name { - node: Node { - start: 3302, - end: 3320, - }, - id: "_adjust_data_frame", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 3321, - end: 3323, - }, - id: "df", - }, - ), - Name( - Name { - node: Node { - start: 3325, - end: 3338, - }, - id: "include_jdate", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - IfStatement( - If { - node: Node { - start: 3353, - end: 3712, - }, - test: Compare( - Compare { - node: Node { - start: 3356, - end: 3373, - }, - left: Name( - Name { - node: Node { - start: 3356, - end: 3362, - }, - id: "symbol", - }, - ), - ops: [ - In, - ], - comparators: [ - Name( - Name { - node: Node { - start: 3366, - end: 3373, - }, - id: "df_list", - }, - ), - ], - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 3391, - end: 3643, - }, - targets: [ - Subscript( - Subscript { - node: Node { - start: 3391, - end: 3406, - }, - value: Name( - Name { - node: Node { - start: 3391, - end: 3398, - }, - id: "df_list", - }, - ), - slice: Name( - Name { - node: Node { - start: 3399, - end: 3405, - }, - id: "symbol", - }, - ), - }, - ), - ], - value: Call( - Call { - node: Node { - start: 3614, - end: 3625, - }, - func: Attribute( - Attribute { - node: Node { - start: 3602, - end: 3614, - }, - value: Call( - Call { - node: Node { - start: 3573, - end: 3581, - }, - func: Attribute( - Attribute { - node: Node { - start: 3561, - end: 3573, - }, - value: Call( - Call { - node: Node { - start: 3440, - end: 3540, - }, - func: Attribute( - Attribute { - node: Node { - start: 3431, - end: 3440, - }, - value: Name( - Name { - node: Node { - start: 3431, - end: 3433, - }, - id: "pd", - }, - ), - attr: "concat", - }, - ), - args: [ - List( - List { - node: Node { - start: 3466, - end: 3487, - }, - elements: [ - Subscript( - Subscript { - node: Node { - start: 3467, - end: 3482, - }, - value: Name( - Name { - node: Node { - start: 3467, - end: 3474, - }, - id: "df_list", - }, - ), - slice: Name( - Name { - node: Node { - start: 3475, - end: 3481, - }, - id: "symbol", - }, - ), - }, - ), - Name( - Name { - node: Node { - start: 3484, - end: 3486, - }, - id: "df", - }, - ), - ], - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 3489, - end: 3506, - }, - arg: Some( - "ignore_index", - ), - value: Constant( - Constant { - node: Node { - start: 3502, - end: 3506, - }, - value: true, - }, - ), - }, - Keyword { - node: Node { - start: 3508, - end: 3518, - }, - arg: Some( - "sort", - ), - value: Constant( - Constant { - node: Node { - start: 3513, - end: 3518, - }, - value: false, - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - attr: "sort_values", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 3574, - end: 3580, - }, - value: "date", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - attr: "reset_index", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 3615, - end: 3624, - }, - arg: Some( - "drop", - ), - value: Constant( - Constant { - node: Node { - start: 3620, - end: 3624, - }, - value: true, - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ], - orelse: [ - AssignStatement( - Assign { - node: Node { - start: 3678, - end: 3698, - }, - targets: [ - Subscript( - Subscript { - node: Node { - start: 3678, - end: 3693, - }, - value: Name( - Name { - node: Node { - start: 3678, - end: 3685, - }, - id: "df_list", - }, - ), - slice: Name( - Name { - node: Node { - start: 3686, - end: 3692, - }, - id: "symbol", - }, - ), - }, - ), - ], - value: Name( - Name { - node: Node { - start: 3696, - end: 3698, - }, - id: "df", - }, - ), - }, - ), - ], - }, - ), - IfStatement( - If { - node: Node { - start: 3712, - end: 3800, - }, - test: Name( - Name { - node: Node { - start: 3715, - end: 3721, - }, - id: "adjust", - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 3739, - end: 3786, - }, - targets: [ - Subscript( - Subscript { - node: Node { - start: 3739, - end: 3754, - }, - value: Name( - Name { - node: Node { - start: 3739, - end: 3746, - }, - id: "df_list", - }, - ), - slice: Name( - Name { - node: Node { - start: 3747, - end: 3753, - }, - id: "symbol", - }, - ), - }, - ), - ], - value: Call( - Call { - node: Node { - start: 3757, - end: 3786, - }, - func: Name( - Name { - node: Node { - start: 3757, - end: 3769, - }, - id: "adjust_price", - }, - ), - args: [ - Subscript( - Subscript { - node: Node { - start: 3770, - end: 3785, - }, - value: Name( - Name { - node: Node { - start: 3770, - end: 3777, - }, - id: "df_list", - }, - ), - slice: Name( - Name { - node: Node { - start: 3778, - end: 3784, - }, - id: "symbol", - }, - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ], - orelse: [], - }, - ), - IfStatement( - If { - node: Node { - start: 3800, - end: 4203, - }, - test: Name( - Name { - node: Node { - start: 3803, - end: 3815, - }, - id: "write_to_csv", - }, - ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 3854, - end: 3883, - }, - func: Attribute( - Attribute { - node: Node { - start: 3848, - end: 3854, - }, - value: Call( - Call { - node: Node { - start: 3833, - end: 3848, - }, - func: Name( - Name { - node: Node { - start: 3833, - end: 3837, - }, - id: "Path", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 3838, - end: 3847, - }, - id: "base_path", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - attr: "mkdir", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 3855, - end: 3867, - }, - arg: Some( - "parents", - ), - value: Constant( - Constant { - node: Node { - start: 3863, - end: 3867, - }, - value: true, - }, - ), - }, - Keyword { - node: Node { - start: 3869, - end: 3882, - }, - arg: Some( - "exist_ok", - ), - value: Constant( - Constant { - node: Node { - start: 3878, - end: 3882, - }, - value: true, - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ), - IfStatement( - If { - node: Node { - start: 3900, - end: 4203, - }, - test: Name( - Name { - node: Node { - start: 3903, - end: 3909, - }, - id: "adjust", - }, - ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 3953, - end: 4044, - }, - func: Attribute( - Attribute { - node: Node { - start: 3946, - end: 3953, - }, - value: Subscript( - Subscript { - node: Node { - start: 3931, - end: 3946, - }, - value: Name( - Name { - node: Node { - start: 3931, - end: 3938, - }, - id: "df_list", - }, - ), - slice: Name( - Name { - node: Node { - start: 3939, - end: 3945, - }, - id: "symbol", - }, - ), - }, - ), - attr: "to_csv", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 3979, - end: 4009, - }, - values: [ - Name( - Name { - node: Node { - start: 3982, - end: 3991, - }, - id: "base_path", - }, - ), - Constant( - Constant { - node: Node { - start: 3993, - end: 0, - }, - value: "/", - }, - ), - Name( - Name { - node: Node { - start: 3994, - end: 4000, - }, - id: "symbol", - }, - ), - Constant( - Constant { - node: Node { - start: 4008, - end: 0, - }, - value: "-ت.csv", - }, - ), - ], - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 4011, - end: 4022, - }, - arg: Some( - "index", - ), - value: Constant( - Constant { - node: Node { - start: 4017, - end: 4022, - }, - value: false, - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ), - ], - orelse: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 4109, - end: 4197, - }, - func: Attribute( - Attribute { - node: Node { - start: 4102, - end: 4109, - }, - value: Subscript( - Subscript { - node: Node { - start: 4087, - end: 4102, - }, - value: Name( - Name { - node: Node { - start: 4087, - end: 4094, - }, - id: "df_list", - }, - ), - slice: Name( - Name { - node: Node { - start: 4095, - end: 4101, - }, - id: "symbol", - }, - ), - }, - ), - attr: "to_csv", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 4135, - end: 4162, - }, - values: [ - Name( - Name { - node: Node { - start: 4138, - end: 4147, - }, - id: "base_path", - }, - ), - Constant( - Constant { - node: Node { - start: 4149, - end: 0, - }, - value: "/", - }, - ), - Name( - Name { - node: Node { - start: 4150, - end: 4156, - }, - id: "symbol", - }, - ), - Constant( - Constant { - node: Node { - start: 4161, - end: 0, - }, - value: ".csv", - }, - ), - ], - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 4164, - end: 4175, - }, - arg: Some( - "index", - ), - value: Constant( - Constant { - node: Node { - start: 4170, - end: 4175, - }, - value: false, - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ), - ], - }, - ), - ], - orelse: [], - }, - ), - ], - orelse: [], - }, - ), - ], - }, - ), - IfStatement( - If { - node: Node { - start: 4203, - end: 4309, - }, - test: Compare( - Compare { - node: Node { - start: 4206, - end: 4234, - }, - left: Call( - Call { - node: Node { - start: 4206, - end: 4218, - }, - func: Name( - Name { - node: Node { - start: 4206, - end: 4209, - }, - id: "len", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 4210, - end: 4217, - }, - id: "df_list", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ops: [ - NotEq, - ], - comparators: [ - Call( - Call { - node: Node { - start: 4222, - end: 4234, - }, - func: Name( - Name { - node: Node { - start: 4222, - end: 4225, - }, - id: "len", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 4226, - end: 4233, - }, - id: "symbols", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ], - }, - ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 4244, - end: 4304, - }, - func: Name( - Name { - node: Node { - start: 4244, - end: 4249, - }, - id: "print", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 4250, - end: 4303, - }, - value: "Warning, download did not complete, re-run the code", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - ], - orelse: [], - }, - ), - ExpressionStatement( - Call( - Call { - node: Node { - start: 4322, - end: 4324, - }, - func: Attribute( - Attribute { - node: Node { - start: 4309, - end: 4322, - }, - value: Name( - Name { - node: Node { - start: 4309, - end: 4316, - }, - id: "session", - }, - ), - attr: "close", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - Return( - Return { - node: Node { - start: 4329, - end: 4343, - }, - value: Some( - Name( - Name { - node: Node { - start: 4336, - end: 4343, - }, - id: "df_list", - }, - ), - ), - }, - ), - ], - decorator_list: [], - returns: Some( - Subscript( - Subscript { - node: Node { - start: 1637, - end: 1660, - }, - value: Name( - Name { - node: Node { - start: 1637, - end: 1641, - }, - id: "Dict", - }, - ), - slice: Tuple( - Tuple { - node: Node { - start: 1642, - end: 1660, - }, - elements: [ - Name( - Name { - node: Node { - start: 1642, - end: 1645, - }, - id: "str", - }, - ), - Attribute( - Attribute { - node: Node { - start: 1647, - end: 1659, - }, - value: Name( - Name { - node: Node { - start: 1647, - end: 1649, - }, - id: "pd", - }, - ), - attr: "DataFrame", - }, - ), - ], - }, - ), - }, - ), - ), - type_comment: None, - type_params: [], - }, - ), - FunctionDef( - FunctionDef { - node: Node { - start: 4346, - end: 6805, - }, - name: "adjust_price", - args: Arguments { - node: Node { - start: 4363, - end: 4379, - }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 4363, - end: 4379, - }, - arg: "df", - annotation: Some( - Attribute( - Attribute { - node: Node { - start: 4367, - end: 4379, - }, - value: Name( - Name { - node: Node { - start: 4367, - end: 4369, - }, - id: "pd", - }, - ), - attr: "DataFrame", - }, - ), - ), - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: [ - ExpressionStatement( - Constant( - Constant { - node: Node { - start: 4402, - end: 5588, - }, - value: " - Adjust historical records of stock - - There is a capital increase/profit sharing, - if today "Final Close Price" is not equal to next day - "Yesterday Final Close Price" by using this ratio, - performance adjustment of stocks is achieved - - Parameters - ---------- - df : pd.DataFrame - DataFrame with historical records. - - Returns - ------- - pd.DataFrame - DataFrame with adjusted historical records. - - Notes - ----- - DataFrame can not be empty or else it makes runtime error - Type of DataFrame must be RangeIndex to make proper range of records - that need to be modified - - diff: list - list of indexs of the day after capital increase/profit sharing - ratio_list: List - List of ratios to adjust historical data of stock - ratio: Float - ratio = df.loc[i].adjClose / df.loc[i+1].yesterday - - Description - ----------- - # Note: adjustment does not include Tenth and twentieth days - df.index = range(0,101,1) - # step is 1 - step = df.index.step - diff = [10,20] - ratio_list = [0.5, 0.8] - df.loc[0:10-step, [open,...]] * ratio[0] - df.loc[10:20-step, [open,...]] * ratio[1] - ", - }, - ), - ), - IfStatement( - If { - node: Node { - start: 5593, - end: 5691, - }, - test: BoolOp( - BoolOperation { - node: Node { - start: 5596, - end: 5666, - }, - op: Or, - values: [ - Attribute( - Attribute { - node: Node { - start: 5596, - end: 5604, - }, - value: Name( - Name { - node: Node { - start: 5596, - end: 5598, - }, - id: "df", - }, - ), - attr: "empty", - }, - ), - UnaryOp( - UnaryOperation { - node: Node { - start: 5608, - end: 5666, - }, - op: Not, - operand: Call( - Call { - node: Node { - start: 5612, - end: 5666, - }, - func: Name( - Name { - node: Node { - start: 5612, - end: 5622, - }, - id: "isinstance", - }, - ), - args: [ - Attribute( - Attribute { - node: Node { - start: 5623, - end: 5631, - }, - value: Name( - Name { - node: Node { - start: 5623, - end: 5625, - }, - id: "df", - }, - ), - attr: "index", - }, - ), - Attribute( - Attribute { - node: Node { - start: 5633, - end: 5665, - }, - value: Attribute( - Attribute { - node: Node { - start: 5633, - end: 5654, - }, - value: Attribute( - Attribute { - node: Node { - start: 5633, - end: 5648, - }, - value: Attribute( - Attribute { - node: Node { - start: 5633, - end: 5640, - }, - value: Name( - Name { - node: Node { - start: 5633, - end: 5635, - }, - id: "pd", - }, - ), - attr: "core", - }, - ), - attr: "indexes", - }, - ), - attr: "range", - }, - ), - attr: "RangeIndex", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ], - }, - ), - body: [ - Return( - Return { - node: Node { - start: 5676, - end: 5685, - }, - value: Some( - Name( - Name { - node: Node { - start: 5683, - end: 5685, - }, - id: "df", - }, - ), - ), - }, - ), - ], - orelse: [], - }, - ), - AssignStatement( - Assign { - node: Node { - start: 5691, - end: 5709, - }, - targets: [ - Name( - Name { - node: Node { - start: 5691, - end: 5697, - }, - id: "new_df", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 5707, - end: 5709, - }, - func: Attribute( - Attribute { - node: Node { - start: 5700, - end: 5707, - }, - value: Name( - Name { - node: Node { - start: 5700, - end: 5702, - }, - id: "df", - }, - ), - attr: "copy", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 5714, - end: 5738, - }, - targets: [ - Name( - Name { - node: Node { - start: 5714, - end: 5718, - }, - id: "step", - }, - ), - ], - value: Attribute( - Attribute { - node: Node { - start: 5721, - end: 5738, - }, - value: Attribute( - Attribute { - node: Node { - start: 5721, - end: 5733, - }, - value: Name( - Name { - node: Node { - start: 5721, - end: 5727, - }, - id: "new_df", - }, - ), - attr: "index", - }, - ), - attr: "step", - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 5743, - end: 5814, - }, - targets: [ - Name( - Name { - node: Node { - start: 5743, - end: 5747, - }, - id: "diff", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 5750, - end: 5814, - }, - func: Name( - Name { - node: Node { - start: 5750, - end: 5754, - }, - id: "list", - }, - ), - args: [ - Subscript( - Subscript { - node: Node { - start: 5767, - end: 5813, - }, - value: Attribute( - Attribute { - node: Node { - start: 5755, - end: 5767, - }, - value: Name( - Name { - node: Node { - start: 5755, - end: 5761, - }, - id: "new_df", - }, - ), - attr: "index", - }, - ), - slice: Compare( - Compare { - node: Node { - start: 5768, - end: 5812, - }, - left: Attribute( - Attribute { - node: Node { - start: 5783, - end: 5792, - }, - value: Call( - Call { - node: Node { - start: 5780, - end: 5783, - }, - func: Attribute( - Attribute { - node: Node { - start: 5768, - end: 5780, - }, - value: Name( - Name { - node: Node { - start: 5768, - end: 5774, - }, - id: "new_df", - }, - ), - attr: "shift", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 5781, - end: 5782, - }, - value: 1, - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - attr: "adjClose", - }, - ), - ops: [ - NotEq, - ], - comparators: [ - Attribute( - Attribute { - node: Node { - start: 5796, - end: 5812, - }, - value: Name( - Name { - node: Node { - start: 5796, - end: 5802, - }, - id: "new_df", - }, - ), - attr: "yesterday", - }, - ), - ], - }, - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - IfStatement( - If { - node: Node { - start: 5819, - end: 5861, - }, - test: Compare( - Compare { - node: Node { - start: 5822, - end: 5835, - }, - left: Call( - Call { - node: Node { - start: 5822, - end: 5831, - }, - func: Name( - Name { - node: Node { - start: 5822, - end: 5825, - }, - id: "len", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 5826, - end: 5830, - }, - id: "diff", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ops: [ - Gt, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 5834, - end: 5835, - }, - value: 0, - }, - ), - ], - }, - ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 5853, - end: 5856, - }, - func: Attribute( - Attribute { - node: Node { - start: 5845, - end: 5853, - }, - value: Name( - Name { - node: Node { - start: 5845, - end: 5849, - }, - id: "diff", - }, - ), - attr: "pop", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 5854, - end: 5855, - }, - value: 0, - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - ], - orelse: [], - }, - ), - AssignStatement( - Assign { - node: Node { - start: 5861, - end: 5870, - }, - targets: [ - Name( - Name { - node: Node { - start: 5861, - end: 5866, - }, - id: "ratio", - }, - ), - ], - value: Constant( - Constant { - node: Node { - start: 5869, - end: 5870, - }, - value: 1, - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 5875, - end: 5890, - }, - targets: [ - Name( - Name { - node: Node { - start: 5875, - end: 5885, - }, - id: "ratio_list", - }, - ), - ], - value: List( - List { - node: Node { - start: 5888, - end: 5890, - }, - elements: [], - }, - ), - }, - ), - ForStatement( - For { - node: Node { - start: 5895, - end: 6061, - }, - target: Name( - Name { - node: Node { - start: 5899, - end: 5900, - }, - id: "i", - }, - ), - iter: Subscript( - Subscript { - node: Node { - start: 5904, - end: 5914, - }, - value: Name( - Name { - node: Node { - start: 5904, - end: 5908, - }, - id: "diff", - }, - ), - slice: Slice( - Slice { - node: Node { - start: 5909, - end: 5913, - }, - lower: None, - upper: Some( - UnaryOp( - UnaryOperation { - node: Node { - start: 5911, - end: 5913, - }, - op: USub, - operand: Constant( - Constant { - node: Node { - start: 5912, - end: 5913, - }, - value: 1, - }, - ), - }, - ), - ), - step: None, - }, - ), - }, - ), - body: [ - AugAssignStatement( - AugAssign { - node: Node { - start: 5924, - end: 6020, - }, - target: Name( - Name { - node: Node { - start: 5924, - end: 5929, - }, - id: "ratio", - }, - ), - op: Mult, - value: BinOp( - BinOp { - node: Node { - start: 5947, - end: 6010, - }, - op: Div, - left: Subscript( - Subscript { - node: Node { - start: 5957, - end: 5973, - }, - value: Attribute( - Attribute { - node: Node { - start: 5947, - end: 5957, - }, - value: Name( - Name { - node: Node { - start: 5947, - end: 5953, - }, - id: "new_df", - }, - ), - attr: "loc", - }, - ), - slice: Tuple( - Tuple { - node: Node { - start: 5958, - end: 5973, - }, - elements: [ - Name( - Name { - node: Node { - start: 5958, - end: 5959, - }, - id: "i", - }, - ), - Constant( - Constant { - node: Node { - start: 5961, - end: 5972, - }, - value: "yesterday", - }, - ), - ], - }, - ), - }, - ), - right: Subscript( - Subscript { - node: Node { - start: 5995, - end: 6010, - }, - value: Attribute( - Attribute { - node: Node { - start: 5991, - end: 5995, - }, - value: Call( - Call { - node: Node { - start: 5988, - end: 5991, - }, - func: Attribute( - Attribute { - node: Node { - start: 5976, - end: 5988, - }, - value: Name( - Name { - node: Node { - start: 5976, - end: 5982, - }, - id: "new_df", - }, - ), - attr: "shift", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 5989, - end: 5990, - }, - value: 1, - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - attr: "loc", - }, - ), - slice: Tuple( - Tuple { - node: Node { - start: 5996, - end: 6010, - }, - elements: [ - Name( - Name { - node: Node { - start: 5996, - end: 5997, - }, - id: "i", - }, - ), - Constant( - Constant { - node: Node { - start: 5999, - end: 6009, - }, - value: "adjClose", - }, - ), - ], - }, - ), - }, - ), - }, - ), - }, - ), - ExpressionStatement( - Call( - Call { - node: Node { - start: 6046, - end: 6056, - }, - func: Attribute( - Attribute { - node: Node { - start: 6029, - end: 6046, - }, - value: Name( - Name { - node: Node { - start: 6029, - end: 6039, - }, - id: "ratio_list", - }, - ), - attr: "insert", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 6047, - end: 6048, - }, - value: 0, - }, - ), - Name( - Name { - node: Node { - start: 6050, - end: 6055, - }, - id: "ratio", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - ], - orelse: [], - }, - ), - ForStatement( - For { - node: Node { - start: 6061, - end: 6789, - }, - target: Tuple( - Tuple { - node: Node { - start: 6065, - end: 6069, - }, - elements: [ - Name( - Name { - node: Node { - start: 6065, - end: 6066, - }, - id: "i", - }, - ), - Name( - Name { - node: Node { - start: 6068, - end: 6069, - }, - id: "k", - }, - ), - ], - }, - ), - iter: Call( - Call { - node: Node { - start: 6073, - end: 6088, - }, - func: Name( - Name { - node: Node { - start: 6073, - end: 6082, - }, - id: "enumerate", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 6083, - end: 6087, - }, - id: "diff", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - body: [ - IfStatement( - If { - node: Node { - start: 6098, - end: 6202, - }, - test: Compare( - Compare { - node: Node { - start: 6101, - end: 6107, - }, - left: Name( - Name { - node: Node { - start: 6101, - end: 6102, - }, - id: "i", - }, - ), - ops: [ - Eq, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 6106, - end: 6107, - }, - value: 0, - }, - ), - ], - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 6121, - end: 6147, - }, - targets: [ - Name( - Name { - node: Node { - start: 6121, - end: 6126, - }, - id: "start", - }, - ), - ], - value: Attribute( - Attribute { - node: Node { - start: 6129, - end: 6147, - }, - value: Attribute( - Attribute { - node: Node { - start: 6129, - end: 6141, - }, - value: Name( - Name { - node: Node { - start: 6129, - end: 6135, - }, - id: "new_df", - }, - ), - attr: "index", - }, - ), - attr: "start", - }, - ), - }, - ), - ], - orelse: [ - AssignStatement( - Assign { - node: Node { - start: 6174, - end: 6193, - }, - targets: [ - Name( - Name { - node: Node { - start: 6174, - end: 6179, - }, - id: "start", - }, - ), - ], - value: Subscript( - Subscript { - node: Node { - start: 6182, - end: 6193, - }, - value: Name( - Name { - node: Node { - start: 6182, - end: 6186, - }, - id: "diff", - }, - ), - slice: BinOp( - BinOp { - node: Node { - start: 6187, - end: 6192, - }, - op: Sub, - left: Name( - Name { - node: Node { - start: 6187, - end: 6188, - }, - id: "i", - }, - ), - right: Constant( - Constant { - node: Node { - start: 6191, - end: 6192, - }, - value: 1, - }, - ), - }, - ), - }, - ), - }, - ), - ], - }, - ), - AssignStatement( - Assign { - node: Node { - start: 6202, - end: 6222, - }, - targets: [ - Name( - Name { - node: Node { - start: 6202, - end: 6205, - }, - id: "end", - }, - ), - ], - value: BinOp( - BinOp { - node: Node { - start: 6208, - end: 6222, - }, - op: Sub, - left: Subscript( - Subscript { - node: Node { - start: 6208, - end: 6215, - }, - value: Name( - Name { - node: Node { - start: 6208, - end: 6212, - }, - id: "diff", - }, - ), - slice: Name( - Name { - node: Node { - start: 6213, - end: 6214, - }, - id: "i", - }, - ), - }, - ), - right: Name( - Name { - node: Node { - start: 6218, - end: 6222, - }, - id: "step", - }, - ), - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 6231, - end: 6783, - }, - targets: [ - Subscript( - Subscript { - node: Node { - start: 6241, - end: 6457, - }, - value: Attribute( - Attribute { - node: Node { - start: 6231, - end: 6241, - }, - value: Name( - Name { - node: Node { - start: 6231, - end: 6237, - }, - id: "new_df", - }, - ), - attr: "loc", - }, - ), - slice: Tuple( - Tuple { - node: Node { - start: 6255, - end: 6457, - }, - elements: [ - Slice( - Slice { - node: Node { - start: 6260, - end: 6264, - }, - lower: Some( - Name( - Name { - node: Node { - start: 6255, - end: 6260, - }, - id: "start", - }, - ), - ), - upper: Some( - Name( - Name { - node: Node { - start: 6261, - end: 6264, - }, - id: "end", - }, - ), - ), - step: None, - }, - ), - List( - List { - node: Node { - start: 6278, - end: 6446, - }, - elements: [ - Constant( - Constant { - node: Node { - start: 6296, - end: 6302, - }, - value: "open", - }, - ), - Constant( - Constant { - node: Node { - start: 6320, - end: 6326, - }, - value: "high", - }, - ), - Constant( - Constant { - node: Node { - start: 6344, - end: 6349, - }, - value: "low", - }, - ), - Constant( - Constant { - node: Node { - start: 6367, - end: 6374, - }, - value: "close", - }, - ), - Constant( - Constant { - node: Node { - start: 6392, - end: 6402, - }, - value: "adjClose", - }, - ), - Constant( - Constant { - node: Node { - start: 6420, - end: 6431, - }, - value: "yesterday", - }, - ), - ], - }, - ), - ], - }, - ), - }, - ), - ], - value: Call( - Call { - node: Node { - start: 6460, - end: 6783, - }, - func: Name( - Name { - node: Node { - start: 6460, - end: 6465, - }, - id: "round", - }, - ), - args: [ - BinOp( - BinOp { - node: Node { - start: 6479, - end: 6773, - }, - op: Mult, - left: Subscript( - Subscript { - node: Node { - start: 6489, - end: 6745, - }, - value: Attribute( - Attribute { - node: Node { - start: 6479, - end: 6489, - }, - value: Name( - Name { - node: Node { - start: 6479, - end: 6485, - }, - id: "new_df", - }, - ), - attr: "loc", - }, - ), - slice: Tuple( - Tuple { - node: Node { - start: 6507, - end: 6745, - }, - elements: [ - Slice( - Slice { - node: Node { - start: 6512, - end: 6516, - }, - lower: Some( - Name( - Name { - node: Node { - start: 6507, - end: 6512, - }, - id: "start", - }, - ), - ), - upper: Some( - Name( - Name { - node: Node { - start: 6513, - end: 6516, - }, - id: "end", - }, - ), - ), - step: None, - }, - ), - List( - List { - node: Node { - start: 6534, - end: 6730, - }, - elements: [ - Constant( - Constant { - node: Node { - start: 6556, - end: 6562, - }, - value: "open", - }, - ), - Constant( - Constant { - node: Node { - start: 6584, - end: 6590, - }, - value: "high", - }, - ), - Constant( - Constant { - node: Node { - start: 6612, - end: 6617, - }, - value: "low", - }, - ), - Constant( - Constant { - node: Node { - start: 6639, - end: 6646, - }, - value: "close", - }, - ), - Constant( - Constant { - node: Node { - start: 6668, - end: 6678, - }, - value: "adjClose", - }, - ), - Constant( - Constant { - node: Node { - start: 6700, - end: 6711, - }, - value: "yesterday", - }, - ), - ], - }, - ), - ], - }, - ), - }, - ), - right: Subscript( - Subscript { - node: Node { - start: 6760, - end: 6773, - }, - value: Name( - Name { - node: Node { - start: 6760, - end: 6770, - }, - id: "ratio_list", - }, - ), - slice: Name( - Name { - node: Node { - start: 6771, - end: 6772, - }, - id: "i", - }, - ), - }, - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ], - orelse: [], - }, - ), - Return( - Return { - node: Node { - start: 6789, - end: 6802, - }, - value: Some( - Name( - Name { - node: Node { - start: 6796, - end: 6802, - }, - id: "new_df", - }, - ), - ), - }, - ), - ], - decorator_list: [], - returns: Some( - Attribute( - Attribute { - node: Node { - start: 4384, - end: 4396, - }, - value: Name( - Name { - node: Node { - start: 4384, - end: 4386, - }, - id: "pd", - }, - ), - attr: "DataFrame", - }, - ), - ), - type_comment: None, - type_params: [], - }, - ), - FunctionDef( - FunctionDef { - node: Node { - start: 6955, - end: 7464, - }, - name: "download_ticker_daily_record", - args: Arguments { - node: Node { - start: 6988, - end: 7023, - }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 6988, - end: 7005, - }, - arg: "ticker_index", - annotation: Some( - Name( - Name { - node: Node { - start: 7002, - end: 7005, - }, - id: "str", - }, - ), - ), - }, - Arg { - node: Node { - start: 7007, - end: 7023, - }, - arg: "session", - annotation: Some( - Name( - Name { - node: Node { - start: 7016, - end: 7023, - }, - id: "Session", - }, - ), - ), - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: [ - AssignStatement( - Assign { - node: Node { - start: 7030, - end: 7100, - }, - targets: [ - Name( - Name { - node: Node { - start: 7030, - end: 7033, - }, - id: "url", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 7086, - end: 7100, - }, - func: Attribute( - Attribute { - node: Node { - start: 7036, - end: 7086, - }, - value: Attribute( - Attribute { - node: Node { - start: 7036, - end: 7079, - }, - value: Name( - Name { - node: Node { - start: 7036, - end: 7048, - }, - id: "tse_settings", - }, - ), - attr: "TSE_TICKER_EXPORT_DATA_ADDRESS", - }, - ), - attr: "format", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 7087, - end: 7099, - }, - id: "ticker_index", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 7105, - end: 7144, - }, - targets: [ - Name( - Name { - node: Node { - start: 7105, - end: 7113, - }, - id: "response", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 7127, - end: 7144, - }, - func: Attribute( - Attribute { - node: Node { - start: 7116, - end: 7127, - }, - value: Name( - Name { - node: Node { - start: 7116, - end: 7123, - }, - id: "session", - }, - ), - attr: "get", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 7128, - end: 7131, - }, - id: "url", - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 7133, - end: 7143, - }, - arg: Some( - "timeout", - ), - value: Constant( - Constant { - node: Node { - start: 7141, - end: 7143, - }, - value: 10, - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - ), - IfStatement( - If { - node: Node { - start: 7149, - end: 7369, - }, - test: Compare( - Compare { - node: Node { - start: 7152, - end: 7185, - }, - left: Constant( - Constant { - node: Node { - start: 7152, - end: 7155, - }, - value: 400, - }, - ), - ops: [ - LtE, - Lt, - ], - comparators: [ - Attribute( - Attribute { - node: Node { - start: 7159, - end: 7179, - }, - value: Name( - Name { - node: Node { - start: 7159, - end: 7167, - }, - id: "response", - }, - ), - attr: "status_code", - }, - ), - Constant( - Constant { - node: Node { - start: 7182, - end: 7185, - }, - value: 500, - }, - ), - ], - }, - ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 7207, - end: 7363, - }, - func: Attribute( - Attribute { - node: Node { - start: 7195, - end: 7207, - }, - value: Name( - Name { - node: Node { - start: 7195, - end: 7201, - }, - id: "logger", - }, - ), - attr: "error", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 7221, - end: 7275, - }, - values: [ - Constant( - Constant { - node: Node { - start: 7269, - end: 0, - }, - value: "Cannot read daily trade records from the url: ", - }, - ), - Name( - Name { - node: Node { - start: 7270, - end: 7273, - }, - id: "url", - }, - ), - ], - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 7289, - end: 7352, - }, - arg: Some( - "extra", - ), - value: Dict( - Dict { - node: Node { - start: 7295, - end: 7352, - }, - keys: [ - Constant( - Constant { - node: Node { - start: 7296, - end: 7306, - }, - value: "response", - }, - ), - Constant( - Constant { - node: Node { - start: 7323, - end: 7329, - }, - value: "code", - }, - ), - ], - values: [ - Attribute( - Attribute { - node: Node { - start: 7308, - end: 7321, - }, - value: Name( - Name { - node: Node { - start: 7308, - end: 7316, - }, - id: "response", - }, - ), - attr: "text", - }, - ), - Attribute( - Attribute { - node: Node { - start: 7331, - end: 7351, - }, - value: Name( - Name { - node: Node { - start: 7331, - end: 7339, - }, - id: "response", - }, - ), - attr: "status_code", - }, - ), - ], - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ), - ], - orelse: [], - }, - ), - ExpressionStatement( - Call( - Call { - node: Node { - start: 7394, - end: 7396, - }, - func: Attribute( - Attribute { - node: Node { - start: 7369, - end: 7394, - }, - value: Name( - Name { - node: Node { - start: 7369, - end: 7377, - }, - id: "response", - }, - ), - attr: "raise_for_status", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - AssignStatement( - Assign { - node: Node { - start: 7402, - end: 7432, - }, - targets: [ - Name( - Name { - node: Node { - start: 7402, - end: 7406, - }, - id: "data", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 7409, - end: 7432, - }, - func: Name( - Name { - node: Node { - start: 7409, - end: 7417, - }, - id: "StringIO", - }, - ), - args: [ - Attribute( - Attribute { - node: Node { - start: 7418, - end: 7431, - }, - value: Name( - Name { - node: Node { - start: 7418, - end: 7426, - }, - id: "response", - }, - ), - attr: "text", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - Return( - Return { - node: Node { - start: 7437, - end: 7461, - }, - value: Some( - Call( - Call { - node: Node { - start: 7455, - end: 7461, - }, - func: Attribute( - Attribute { - node: Node { - start: 7444, - end: 7455, - }, - value: Name( - Name { - node: Node { - start: 7444, - end: 7446, - }, - id: "pd", - }, - ), - attr: "read_csv", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 7456, - end: 7460, - }, - id: "data", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - }, - ), - ], - decorator_list: [ - Call( - Call { - node: Node { - start: 6806, - end: 6954, - }, - func: Name( - Name { - node: Node { - start: 6806, - end: 6811, - }, - id: "retry", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 6817, - end: 6857, - }, - arg: Some( - "retry", - ), - value: Call( - Call { - node: Node { - start: 6823, - end: 6857, - }, - func: Name( - Name { - node: Node { - start: 6823, - end: 6846, - }, - id: "retry_if_exception_type", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 6847, - end: 6856, - }, - id: "HTTPError", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - Keyword { - node: Node { - start: 6863, - end: 6893, - }, - arg: Some( - "wait", - ), - value: Call( - Call { - node: Node { - start: 6868, - end: 6893, - }, - func: Name( - Name { - node: Node { - start: 6868, - end: 6879, - }, - id: "wait_random", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 6880, - end: 6885, - }, - arg: Some( - "min", - ), - value: Constant( - Constant { - node: Node { - start: 6884, - end: 6885, - }, - value: 1, - }, - ), - }, - Keyword { - node: Node { - start: 6887, - end: 6892, - }, - arg: Some( - "max", - ), - value: Constant( - Constant { - node: Node { - start: 6891, - end: 6892, - }, - value: 4, - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - Keyword { - node: Node { - start: 6899, - end: 6951, - }, - arg: Some( - "before_sleep", - ), - value: Call( - Call { - node: Node { - start: 6912, - end: 6951, - }, - func: Name( - Name { - node: Node { - start: 6912, - end: 6928, - }, - id: "before_sleep_log", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 6929, - end: 6935, - }, - id: "logger", - }, - ), - Attribute( - Attribute { - node: Node { - start: 6937, - end: 6950, - }, - value: Name( - Name { - node: Node { - start: 6937, - end: 6944, - }, - id: "logging", - }, - ), - attr: "DEBUG", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ], - returns: None, - type_comment: None, - type_params: [], - }, - ), - FunctionDef( - FunctionDef { - node: Node { - start: 7614, - end: 8358, - }, - name: "download_fIndex_record", - args: Arguments { - node: Node { - start: 7641, - end: 7670, - }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 7641, - end: 7652, - }, - arg: "fIndex", - annotation: Some( - Name( - Name { - node: Node { - start: 7649, - end: 7652, - }, - id: "str", - }, - ), - ), - }, - Arg { - node: Node { - start: 7654, - end: 7670, - }, - arg: "session", - annotation: Some( - Name( - Name { - node: Node { - start: 7663, - end: 7670, - }, - id: "Session", - }, - ), - ), - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: [ - AssignStatement( - Assign { - node: Node { - start: 7677, - end: 7750, - }, - targets: [ - Name( - Name { - node: Node { - start: 7677, - end: 7680, - }, - id: "url", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 7742, - end: 7750, - }, - func: Attribute( - Attribute { - node: Node { - start: 7683, - end: 7742, - }, - value: Attribute( - Attribute { - node: Node { - start: 7683, - end: 7735, - }, - value: Name( - Name { - node: Node { - start: 7683, - end: 7695, - }, - id: "tse_settings", - }, - ), - attr: "TSE_FINANCIAL_INDEX_EXPORT_DATA_ADDRESS", - }, - ), - attr: "format", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 7743, - end: 7749, - }, - id: "fIndex", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 7755, - end: 7794, - }, - targets: [ - Name( - Name { - node: Node { - start: 7755, - end: 7763, - }, - id: "response", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 7777, - end: 7794, - }, - func: Attribute( - Attribute { - node: Node { - start: 7766, - end: 7777, - }, - value: Name( - Name { - node: Node { - start: 7766, - end: 7773, - }, - id: "session", - }, - ), - attr: "get", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 7778, - end: 7781, - }, - id: "url", - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 7783, - end: 7793, - }, - arg: Some( - "timeout", - ), - value: Constant( - Constant { - node: Node { - start: 7791, - end: 7793, - }, - value: 10, - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - ), - IfStatement( - If { - node: Node { - start: 7799, - end: 8019, - }, - test: Compare( - Compare { - node: Node { - start: 7802, - end: 7835, - }, - left: Constant( - Constant { - node: Node { - start: 7802, - end: 7805, - }, - value: 400, - }, - ), - ops: [ - LtE, - Lt, - ], - comparators: [ - Attribute( - Attribute { - node: Node { - start: 7809, - end: 7829, - }, - value: Name( - Name { - node: Node { - start: 7809, - end: 7817, - }, - id: "response", - }, - ), - attr: "status_code", - }, - ), - Constant( - Constant { - node: Node { - start: 7832, - end: 7835, - }, - value: 500, - }, - ), - ], - }, - ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 7857, - end: 8013, - }, - func: Attribute( - Attribute { - node: Node { - start: 7845, - end: 7857, - }, - value: Name( - Name { - node: Node { - start: 7845, - end: 7851, - }, - id: "logger", - }, - ), - attr: "error", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 7871, - end: 7925, - }, - values: [ - Constant( - Constant { - node: Node { - start: 7919, - end: 0, - }, - value: "Cannot read daily trade records from the url: ", - }, - ), - Name( - Name { - node: Node { - start: 7920, - end: 7923, - }, - id: "url", - }, - ), - ], - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 7939, - end: 8002, - }, - arg: Some( - "extra", - ), - value: Dict( - Dict { - node: Node { - start: 7945, - end: 8002, - }, - keys: [ - Constant( - Constant { - node: Node { - start: 7946, - end: 7956, - }, - value: "response", - }, - ), - Constant( - Constant { - node: Node { - start: 7973, - end: 7979, - }, - value: "code", - }, - ), - ], - values: [ - Attribute( - Attribute { - node: Node { - start: 7958, - end: 7971, - }, - value: Name( - Name { - node: Node { - start: 7958, - end: 7966, - }, - id: "response", - }, - ), - attr: "text", - }, - ), - Attribute( - Attribute { - node: Node { - start: 7981, - end: 8001, - }, - value: Name( - Name { - node: Node { - start: 7981, - end: 7989, - }, - id: "response", - }, - ), - attr: "status_code", - }, - ), - ], - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ), - ], - orelse: [], - }, - ), - ExpressionStatement( - Call( - Call { - node: Node { - start: 8044, - end: 8046, - }, - func: Attribute( - Attribute { - node: Node { - start: 8019, - end: 8044, - }, - value: Name( - Name { - node: Node { - start: 8019, - end: 8027, - }, - id: "response", - }, - ), - attr: "raise_for_status", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - AssignStatement( - Assign { - node: Node { - start: 8051, - end: 8071, - }, - targets: [ - Name( - Name { - node: Node { - start: 8051, - end: 8055, - }, - id: "data", - }, - ), - ], - value: Attribute( - Attribute { - node: Node { - start: 8058, - end: 8071, - }, - value: Name( - Name { - node: Node { - start: 8058, - end: 8066, - }, - id: "response", - }, - ), - attr: "text", - }, - ), - }, - ), - IfStatement( - If { - node: Node { - start: 8076, - end: 8288, - }, - test: BoolOp( - BoolOperation { - node: Node { - start: 8079, - end: 8125, - }, - op: Or, - values: [ - UnaryOp( - UnaryOperation { - node: Node { - start: 8079, - end: 8087, - }, - op: Not, - operand: Name( - Name { - node: Node { - start: 8083, - end: 8087, - }, - id: "data", - }, - ), - }, - ), - BoolOp( - BoolOperation { - node: Node { - start: 8091, - end: 8125, - }, - op: Or, - values: [ - Compare( - Compare { - node: Node { - start: 8091, - end: 8106, - }, - left: Constant( - Constant { - node: Node { - start: 8091, - end: 8094, - }, - value: ";", - }, - ), - ops: [ - NotIn, - ], - comparators: [ - Name( - Name { - node: Node { - start: 8102, - end: 8106, - }, - id: "data", - }, - ), - ], - }, - ), - Compare( - Compare { - node: Node { - start: 8110, - end: 8125, - }, - left: Constant( - Constant { - node: Node { - start: 8110, - end: 8113, - }, - value: ",", - }, - ), - ops: [ - NotIn, - ], - comparators: [ - Name( - Name { - node: Node { - start: 8121, - end: 8125, - }, - id: "data", - }, - ), - ], - }, - ), - ], - }, - ), - ], - }, - ), - body: [ - Raise( - Raise { - node: Node { - start: 8135, - end: 8283, - }, - exc: Some( - Call( - Call { - node: Node { - start: 8141, - end: 8283, - }, - func: Name( - Name { - node: Node { - start: 8141, - end: 8151, - }, - id: "ValueError", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 8165, - end: 8273, - }, - values: [ - Constant( - Constant { - node: Node { - start: 8200, - end: 0, - }, - value: "Invalid response from the url: ", - }, - ), - Name( - Name { - node: Node { - start: 8201, - end: 8204, - }, - id: "url", - }, - ), - Constant( - Constant { - node: Node { - start: 8270, - end: 0, - }, - value: ". - \nExpected valid financial index data.", - }, - ), - ], - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - cause: None, - }, - ), - ], - orelse: [], - }, - ), - AssignStatement( - Assign { - node: Node { - start: 8288, - end: 8341, - }, - targets: [ - Name( - Name { - node: Node { - start: 8288, - end: 8290, - }, - id: "df", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 8293, - end: 8341, - }, - func: Name( - Name { - node: Node { - start: 8293, - end: 8335, - }, - id: "_create_financial_index_from_text_response", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 8336, - end: 8340, - }, - id: "data", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - Return( - Return { - node: Node { - start: 8346, - end: 8355, - }, - value: Some( - Name( - Name { - node: Node { - start: 8353, - end: 8355, - }, - id: "df", - }, - ), - ), - }, - ), - ], - decorator_list: [ - Call( - Call { - node: Node { - start: 7465, - end: 7613, - }, - func: Name( - Name { - node: Node { - start: 7465, - end: 7470, - }, - id: "retry", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 7476, - end: 7516, - }, - arg: Some( - "retry", - ), - value: Call( - Call { - node: Node { - start: 7482, - end: 7516, - }, - func: Name( - Name { - node: Node { - start: 7482, - end: 7505, - }, - id: "retry_if_exception_type", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 7506, - end: 7515, - }, - id: "HTTPError", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - Keyword { - node: Node { - start: 7522, - end: 7552, - }, - arg: Some( - "wait", - ), - value: Call( - Call { - node: Node { - start: 7527, - end: 7552, - }, - func: Name( - Name { - node: Node { - start: 7527, - end: 7538, - }, - id: "wait_random", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 7539, - end: 7544, - }, - arg: Some( - "min", - ), - value: Constant( - Constant { - node: Node { - start: 7543, - end: 7544, - }, - value: 1, - }, - ), - }, - Keyword { - node: Node { - start: 7546, - end: 7551, - }, - arg: Some( - "max", - ), - value: Constant( - Constant { - node: Node { - start: 7550, - end: 7551, - }, - value: 4, - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - Keyword { - node: Node { - start: 7558, - end: 7610, - }, - arg: Some( - "before_sleep", - ), - value: Call( - Call { - node: Node { - start: 7571, - end: 7610, - }, - func: Name( - Name { - node: Node { - start: 7571, - end: 7587, - }, - id: "before_sleep_log", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 7588, - end: 7594, - }, - id: "logger", - }, - ), - Attribute( - Attribute { - node: Node { - start: 7596, - end: 7609, - }, - value: Name( - Name { - node: Node { - start: 7596, - end: 7603, - }, - id: "logging", - }, - ), - attr: "DEBUG", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ], - returns: None, - type_comment: None, - type_params: [], - }, - ), - FunctionDef( - FunctionDef { - node: Node { - start: 8358, - end: 10374, - }, - name: "download_financial_indexes", - args: Arguments { - node: Node { - start: 8394, - end: 8540, - }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 8394, - end: 8419, - }, - arg: "symbols", - annotation: Some( - Subscript( - Subscript { - node: Node { - start: 8403, - end: 8419, - }, - value: Name( - Name { - node: Node { - start: 8403, - end: 8408, - }, - id: "Union", - }, - ), - slice: Tuple( - Tuple { - node: Node { - start: 8409, - end: 8419, - }, - elements: [ - Name( - Name { - node: Node { - start: 8409, - end: 8413, - }, - id: "List", - }, - ), - Name( - Name { - node: Node { - start: 8415, - end: 8418, - }, - id: "str", - }, - ), - ], - }, - ), - }, - ), - ), - }, - Arg { - node: Node { - start: 8425, - end: 8451, - }, - arg: "write_to_csv", - annotation: Some( - Name( - Name { - node: Node { - start: 8439, - end: 8443, - }, - id: "bool", - }, - ), - ), - }, - Arg { - node: Node { - start: 8457, - end: 8484, - }, - arg: "include_jdate", - annotation: Some( - Name( - Name { - node: Node { - start: 8472, - end: 8476, - }, - id: "bool", - }, - ), - ), - }, - Arg { - node: Node { - start: 8490, - end: 8539, - }, - arg: "base_path", - annotation: Some( - Name( - Name { - node: Node { - start: 8501, - end: 8504, - }, - id: "str", - }, - ), - ), - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [ - Constant( - Constant { - node: Node { - start: 8446, - end: 8451, - }, - value: false, - }, - ), - Constant( - Constant { - node: Node { - start: 8479, - end: 8484, - }, - value: false, - }, - ), - Attribute( - Attribute { - node: Node { - start: 8507, - end: 8539, - }, - value: Name( - Name { - node: Node { - start: 8507, - end: 8513, - }, - id: "config", - }, - ), - attr: "FINANCIAL_INDEX_BASE_PATH", - }, - ), - ], - }, - body: [ - IfStatement( - If { - node: Node { - start: 8575, - end: 8717, - }, - test: Compare( - Compare { - node: Node { - start: 8578, - end: 8594, - }, - left: Name( - Name { - node: Node { - start: 8578, - end: 8585, - }, - id: "symbols", - }, - ), - ops: [ - Eq, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 8589, - end: 8594, - }, - value: "all", - }, - ), - ], - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 8604, - end: 8648, - }, - targets: [ - Name( - Name { - node: Node { - start: 8604, - end: 8611, - }, - id: "symbols", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 8646, - end: 8648, - }, - func: Attribute( - Attribute { - node: Node { - start: 8614, - end: 8646, - }, - value: Name( - Name { - node: Node { - start: 8614, - end: 8626, - }, - id: "symbols_data", - }, - ), - attr: "all_financial_index", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ], - orelse: [ - IfStatement( - If { - node: Node { - start: 8653, - end: 8717, - }, - test: Call( - Call { - node: Node { - start: 8658, - end: 8682, - }, - func: Name( - Name { - node: Node { - start: 8658, - end: 8668, - }, - id: "isinstance", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 8669, - end: 8676, - }, - id: "symbols", - }, - ), - Name( - Name { - node: Node { - start: 8678, - end: 8681, - }, - id: "str", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 8692, - end: 8711, - }, - targets: [ - Name( - Name { - node: Node { - start: 8692, - end: 8699, - }, - id: "symbols", - }, - ), - ], - value: List( - List { - node: Node { - start: 8702, - end: 8711, - }, - elements: [ - Name( - Name { - node: Node { - start: 8703, - end: 8710, - }, - id: "symbols", - }, - ), - ], - }, - ), - }, - ), - ], - orelse: [], - }, - ), - ], - }, - ), - AssignStatement( - Assign { - node: Node { - start: 8717, - end: 8729, - }, - targets: [ - Name( - Name { - node: Node { - start: 8717, - end: 8724, - }, - id: "df_list", - }, - ), - ], - value: Dict( - Dict { - node: Node { - start: 8727, - end: 8729, - }, - keys: [], - values: [], - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 8734, - end: 8755, - }, - targets: [ - Name( - Name { - node: Node { - start: 8734, - end: 8750, - }, - id: "future_to_symbol", - }, - ), - ], - value: Dict( - Dict { - node: Node { - start: 8753, - end: 8755, - }, - keys: [], - values: [], - }, - ), - }, - ), - WithStatement( - With { - node: Node { - start: 8760, - end: 10231, - }, - items: [ - WithItem { - node: Node { - start: 8765, - end: 8819, - }, - context_expr: Call( - Call { - node: Node { - start: 8791, - end: 8807, - }, - func: Attribute( - Attribute { - node: Node { - start: 8765, - end: 8791, - }, - value: Name( - Name { - node: Node { - start: 8765, - end: 8772, - }, - id: "futures", - }, - ), - attr: "ThreadPoolExecutor", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 8792, - end: 8806, - }, - arg: Some( - "max_workers", - ), - value: Constant( - Constant { - node: Node { - start: 8804, - end: 8806, - }, - value: 10, - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - optional_vars: Some( - Name( - Name { - node: Node { - start: 8811, - end: 8819, - }, - id: "executor", - }, - ), - ), - }, - ], - body: [ - AssignStatement( - Assign { - node: Node { - start: 8829, - end: 8863, - }, - targets: [ - Name( - Name { - node: Node { - start: 8829, - end: 8836, - }, - id: "session", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 8839, - end: 8863, - }, - func: Name( - Name { - node: Node { - start: 8839, - end: 8861, - }, - id: "requests_retry_session", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ForStatement( - For { - node: Node { - start: 8872, - end: 9506, - }, - target: Name( - Name { - node: Node { - start: 8876, - end: 8882, - }, - id: "symbol", - }, - ), - iter: Name( - Name { - node: Node { - start: 8886, - end: 8893, - }, - id: "symbols", - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 8907, - end: 8947, - }, - targets: [ - Name( - Name { - node: Node { - start: 8907, - end: 8913, - }, - id: "symbol", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 8939, - end: 8947, - }, - func: Attribute( - Attribute { - node: Node { - start: 8916, - end: 8939, - }, - value: Name( - Name { - node: Node { - start: 8916, - end: 8923, - }, - id: "persian", - }, - ), - attr: "replace_persian", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 8940, - end: 8946, - }, - id: "symbol", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - IfStatement( - If { - node: Node { - start: 8960, - end: 9230, - }, - test: BoolOp( - BoolOperation { - node: Node { - start: 8981, - end: 9068, - }, - op: And, - values: [ - Call( - Call { - node: Node { - start: 8997, - end: 8999, - }, - func: Attribute( - Attribute { - node: Node { - start: 8981, - end: 8997, - }, - value: Name( - Name { - node: Node { - start: 8981, - end: 8987, - }, - id: "symbol", - }, - ), - attr: "isnumeric", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - Compare( - Compare { - node: Node { - start: 9020, - end: 9068, - }, - left: Call( - Call { - node: Node { - start: 9052, - end: 9060, - }, - func: Attribute( - Attribute { - node: Node { - start: 9020, - end: 9052, - }, - value: Name( - Name { - node: Node { - start: 9020, - end: 9032, - }, - id: "symbols_data", - }, - ), - attr: "get_financial_index", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 9053, - end: 9059, - }, - id: "symbol", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ops: [ - Is, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 9064, - end: 9068, - }, - value: None, - }, - ), - ], - }, - ), - ], - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 9100, - end: 9124, - }, - targets: [ - Name( - Name { - node: Node { - start: 9100, - end: 9115, - }, - id: "financial_index", - }, - ), - ], - value: Name( - Name { - node: Node { - start: 9118, - end: 9124, - }, - id: "symbol", - }, - ), - }, - ), - ], - orelse: [ - AssignStatement( - Assign { - node: Node { - start: 9159, - end: 9217, - }, - targets: [ - Name( - Name { - node: Node { - start: 9159, - end: 9174, - }, - id: "financial_index", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 9209, - end: 9217, - }, - func: Attribute( - Attribute { - node: Node { - start: 9177, - end: 9209, - }, - value: Name( - Name { - node: Node { - start: 9177, - end: 9189, - }, - id: "symbols_data", - }, - ), - attr: "get_financial_index", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 9210, - end: 9216, - }, - id: "symbol", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ], - }, - ), - IfStatement( - If { - node: Node { - start: 9230, - end: 9345, - }, - test: Compare( - Compare { - node: Node { - start: 9233, - end: 9256, - }, - left: Name( - Name { - node: Node { - start: 9233, - end: 9248, - }, - id: "financial_index", - }, - ), - ops: [ - Is, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 9252, - end: 9256, - }, - value: None, - }, - ), - ], - }, - ), - body: [ - Raise( - Raise { - node: Node { - start: 9274, - end: 9331, - }, - exc: Some( - Call( - Call { - node: Node { - start: 9280, - end: 9331, - }, - func: Name( - Name { - node: Node { - start: 9280, - end: 9289, - }, - id: "Exception", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 9290, - end: 9330, - }, - values: [ - Constant( - Constant { - node: Node { - start: 9321, - end: 0, - }, - value: "Cannot find financial index: ", - }, - ), - Name( - Name { - node: Node { - start: 9322, - end: 9328, - }, - id: "symbol", - }, - ), - ], - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - cause: None, - }, - ), - ], - orelse: [], - }, - ), - AssignStatement( - Assign { - node: Node { - start: 9345, - end: 9449, - }, - targets: [ - Name( - Name { - node: Node { - start: 9345, - end: 9351, - }, - id: "future", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 9369, - end: 9449, - }, - func: Attribute( - Attribute { - node: Node { - start: 9354, - end: 9369, - }, - value: Name( - Name { - node: Node { - start: 9354, - end: 9362, - }, - id: "executor", - }, - ), - attr: "submit", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 9387, - end: 9409, - }, - id: "download_fIndex_record", - }, - ), - Name( - Name { - node: Node { - start: 9411, - end: 9426, - }, - id: "financial_index", - }, - ), - Name( - Name { - node: Node { - start: 9428, - end: 9435, - }, - id: "session", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 9463, - end: 9496, - }, - targets: [ - Subscript( - Subscript { - node: Node { - start: 9463, - end: 9487, - }, - value: Name( - Name { - node: Node { - start: 9463, - end: 9479, - }, - id: "future_to_symbol", - }, - ), - slice: Name( - Name { - node: Node { - start: 9480, - end: 9486, - }, - id: "future", - }, - ), - }, - ), - ], - value: Name( - Name { - node: Node { - start: 9490, - end: 9496, - }, - id: "symbol", - }, - ), - }, - ), - ], - orelse: [], - }, - ), - ForStatement( - For { - node: Node { - start: 9506, - end: 10231, - }, - target: Name( - Name { - node: Node { - start: 9510, - end: 9516, - }, - id: "future", - }, - ), - iter: Call( - Call { - node: Node { - start: 9540, - end: 9558, - }, - func: Attribute( - Attribute { - node: Node { - start: 9520, - end: 9540, - }, - value: Name( - Name { - node: Node { - start: 9520, - end: 9527, - }, - id: "futures", - }, - ), - attr: "as_completed", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 9541, - end: 9557, - }, - id: "future_to_symbol", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 9572, - end: 9605, - }, - targets: [ - Name( - Name { - node: Node { - start: 9572, - end: 9578, - }, - id: "symbol", - }, - ), - ], - value: Subscript( - Subscript { - node: Node { - start: 9581, - end: 9605, - }, - value: Name( - Name { - node: Node { - start: 9581, - end: 9597, - }, - id: "future_to_symbol", - }, - ), - slice: Name( - Name { - node: Node { - start: 9598, - end: 9604, - }, - id: "future", - }, - ), - }, - ), - }, - ), - TryStatement( - Try { - node: Node { - start: 9618, - end: 9928, - }, - body: [ - AnnAssignStatement( - AnnAssign { - node: Node { - start: 9639, - end: 9673, - }, - target: Name( - Name { - node: Node { - start: 9639, - end: 9641, - }, - id: "df", - }, - ), - annotation: Attribute( - Attribute { - node: Node { - start: 9643, - end: 9655, - }, - value: Name( - Name { - node: Node { - start: 9643, - end: 9645, - }, - id: "pd", - }, - ), - attr: "DataFrame", - }, - ), - value: Some( - Call( - Call { - node: Node { - start: 9671, - end: 9673, - }, - func: Attribute( - Attribute { - node: Node { - start: 9658, - end: 9671, - }, - value: Name( - Name { - node: Node { - start: 9658, - end: 9664, - }, - id: "future", - }, - ), - attr: "result", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - simple: true, - }, - ), - ], - handlers: [ - ExceptHandler { - node: Node { - start: 9686, - end: 9928, - }, - typ: Some( - Attribute( - Attribute { - node: Node { - start: 9693, - end: 9717, - }, - value: Attribute( - Attribute { - node: Node { - start: 9693, - end: 9702, - }, - value: Name( - Name { - node: Node { - start: 9693, - end: 9695, - }, - id: "pd", - }, - ), - attr: "errors", - }, - ), - attr: "EmptyDataError", - }, - ), - ), - name: Some( - "ex", - ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 9753, - end: 9890, - }, - func: Attribute( - Attribute { - node: Node { - start: 9741, - end: 9753, - }, - value: Name( - Name { - node: Node { - start: 9741, - end: 9747, - }, - id: "logger", - }, - ), - attr: "error", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 9775, - end: 9830, - }, - values: [ - Constant( - Constant { - node: Node { - start: 9821, - end: 0, - }, - value: "Cannot read daily trade records for symbol: ", - }, - ), - Name( - Name { - node: Node { - start: 9822, - end: 9828, - }, - id: "symbol", - }, - ), - ], - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 9852, - end: 9871, - }, - arg: Some( - "extra", - ), - value: Dict( - Dict { - node: Node { - start: 9858, - end: 9871, - }, - keys: [ - Constant( - Constant { - node: Node { - start: 9859, - end: 9866, - }, - value: "Error", - }, - ), - ], - values: [ - Name( - Name { - node: Node { - start: 9868, - end: 9870, - }, - id: "ex", - }, - ), - ], - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ), - Continue( - Continue { - node: Node { - start: 9907, - end: 9915, - }, - }, - ), - ], - }, - ], - orelse: [], - finalbody: [], - }, - ), - ExpressionStatement( - Call( - Call { - node: Node { - start: 9928, - end: 9976, - }, - func: Name( - Name { - node: Node { - start: 9928, - end: 9957, - }, - id: "_adjust_data_frame_for_fIndex", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 9958, - end: 9960, - }, - id: "df", - }, - ), - Name( - Name { - node: Node { - start: 9962, - end: 9975, - }, - id: "include_jdate", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - AssignStatement( - Assign { - node: Node { - start: 9989, - end: 10009, - }, - targets: [ - Subscript( - Subscript { - node: Node { - start: 9989, - end: 10004, - }, - value: Name( - Name { - node: Node { - start: 9989, - end: 9996, - }, - id: "df_list", - }, - ), - slice: Name( - Name { - node: Node { - start: 9997, - end: 10003, - }, - id: "symbol", - }, - ), - }, - ), - ], - value: Name( - Name { - node: Node { - start: 10007, - end: 10009, - }, - id: "df", - }, - ), - }, - ), - IfStatement( - If { - node: Node { - start: 10023, - end: 10231, - }, - test: Name( - Name { - node: Node { - start: 10026, - end: 10038, - }, - id: "write_to_csv", - }, - ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 10077, - end: 10106, - }, - func: Attribute( - Attribute { - node: Node { - start: 10071, - end: 10077, - }, - value: Call( - Call { - node: Node { - start: 10056, - end: 10071, - }, - func: Name( - Name { - node: Node { - start: 10056, - end: 10060, - }, - id: "Path", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 10061, - end: 10070, - }, - id: "base_path", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - attr: "mkdir", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 10078, - end: 10090, - }, - arg: Some( - "parents", - ), - value: Constant( - Constant { - node: Node { - start: 10086, - end: 10090, - }, - value: true, - }, - ), - }, - Keyword { - node: Node { - start: 10092, - end: 10105, - }, - arg: Some( - "exist_ok", - ), - value: Constant( - Constant { - node: Node { - start: 10101, - end: 10105, - }, - value: true, - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ), - ExpressionStatement( - Call( - Call { - node: Node { - start: 10145, - end: 10225, - }, - func: Attribute( - Attribute { - node: Node { - start: 10138, - end: 10145, - }, - value: Subscript( - Subscript { - node: Node { - start: 10123, - end: 10138, - }, - value: Name( - Name { - node: Node { - start: 10123, - end: 10130, - }, - id: "df_list", - }, - ), - slice: Name( - Name { - node: Node { - start: 10131, - end: 10137, - }, - id: "symbol", - }, - ), - }, - ), - attr: "to_csv", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 10167, - end: 10194, - }, - values: [ - Name( - Name { - node: Node { - start: 10170, - end: 10179, - }, - id: "base_path", - }, - ), - Constant( - Constant { - node: Node { - start: 10181, - end: 0, - }, - value: "/", - }, - ), - Name( - Name { - node: Node { - start: 10182, - end: 10188, - }, - id: "symbol", - }, - ), - Constant( - Constant { - node: Node { - start: 10193, - end: 0, - }, - value: ".csv", - }, - ), - ], - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 10196, - end: 10207, - }, - arg: Some( - "index", - ), - value: Constant( - Constant { - node: Node { - start: 10202, - end: 10207, - }, - value: false, - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ), - ], - orelse: [], - }, - ), - ], - orelse: [], - }, - ), - ], - }, - ), - IfStatement( - If { - node: Node { - start: 10231, - end: 10337, - }, - test: Compare( - Compare { - node: Node { - start: 10234, - end: 10262, - }, - left: Call( - Call { - node: Node { - start: 10234, - end: 10246, - }, - func: Name( - Name { - node: Node { - start: 10234, - end: 10237, - }, - id: "len", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 10238, - end: 10245, - }, - id: "df_list", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ops: [ - NotEq, - ], - comparators: [ - Call( - Call { - node: Node { - start: 10250, - end: 10262, - }, - func: Name( - Name { - node: Node { - start: 10250, - end: 10253, - }, - id: "len", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 10254, - end: 10261, - }, - id: "symbols", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ], - }, - ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 10272, - end: 10332, - }, - func: Name( - Name { - node: Node { - start: 10272, - end: 10277, - }, - id: "print", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 10278, - end: 10331, - }, - value: "Warning, download did not complete, re-run the code", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - ], - orelse: [], - }, - ), - ExpressionStatement( - Call( - Call { - node: Node { - start: 10350, - end: 10352, - }, - func: Attribute( - Attribute { - node: Node { - start: 10337, - end: 10350, - }, - value: Name( - Name { - node: Node { - start: 10337, - end: 10344, - }, - id: "session", - }, - ), - attr: "close", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - Return( - Return { - node: Node { - start: 10357, - end: 10371, - }, - value: Some( - Name( - Name { - node: Node { - start: 10364, - end: 10371, - }, - id: "df_list", - }, - ), - ), - }, - ), - ], - decorator_list: [], - returns: Some( - Subscript( - Subscript { - node: Node { - start: 8546, - end: 8569, - }, - value: Name( - Name { - node: Node { - start: 8546, - end: 8550, - }, - id: "Dict", - }, - ), - slice: Tuple( - Tuple { - node: Node { - start: 8551, - end: 8569, - }, - elements: [ - Name( - Name { - node: Node { - start: 8551, - end: 8554, - }, - id: "str", - }, - ), - Attribute( - Attribute { - node: Node { - start: 8556, - end: 8568, - }, - value: Name( - Name { - node: Node { - start: 8556, - end: 8558, - }, - id: "pd", - }, - ), - attr: "DataFrame", - }, - ), - ], - }, - ), - }, - ), - ), - type_comment: None, - type_params: [], - }, - ), - FunctionDef( - FunctionDef { - node: Node { - start: 10374, - end: 11849, - }, - name: "download_client_types_records", - args: Arguments { - node: Node { - start: 10413, - end: 10561, - }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 10413, - end: 10438, - }, - arg: "symbols", - annotation: Some( - Subscript( - Subscript { - node: Node { - start: 10422, - end: 10438, - }, - value: Name( - Name { - node: Node { - start: 10422, - end: 10427, - }, - id: "Union", - }, - ), - slice: Tuple( - Tuple { - node: Node { - start: 10428, - end: 10438, - }, - elements: [ - Name( - Name { - node: Node { - start: 10428, - end: 10432, - }, - id: "List", - }, - ), - Name( - Name { - node: Node { - start: 10434, - end: 10437, - }, - id: "str", - }, - ), - ], - }, - ), - }, - ), - ), - }, - Arg { - node: Node { - start: 10444, - end: 10470, - }, - arg: "write_to_csv", - annotation: Some( - Name( - Name { - node: Node { - start: 10458, - end: 10462, - }, - id: "bool", - }, - ), - ), - }, - Arg { - node: Node { - start: 10476, - end: 10503, - }, - arg: "include_jdate", - annotation: Some( - Name( - Name { - node: Node { - start: 10491, - end: 10495, - }, - id: "bool", - }, - ), - ), - }, - Arg { - node: Node { - start: 10509, - end: 10560, - }, - arg: "base_path", - annotation: Some( - Name( - Name { - node: Node { - start: 10520, - end: 10523, - }, - id: "str", - }, - ), - ), - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [ - Constant( - Constant { - node: Node { - start: 10465, - end: 10470, - }, - value: false, - }, - ), - Constant( - Constant { - node: Node { - start: 10498, - end: 10503, - }, - value: false, - }, - ), - Attribute( - Attribute { - node: Node { - start: 10526, - end: 10560, - }, - value: Name( - Name { - node: Node { - start: 10526, - end: 10532, - }, - id: "config", - }, - ), - attr: "CLIENT_TYPES_DATA_BASE_PATH", - }, - ), - ], - }, - body: [ - IfStatement( - If { - node: Node { - start: 10569, - end: 10703, - }, - test: Compare( - Compare { - node: Node { - start: 10572, - end: 10588, - }, - left: Name( - Name { - node: Node { - start: 10572, - end: 10579, - }, - id: "symbols", - }, - ), - ops: [ - Eq, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 10583, - end: 10588, - }, - value: "all", - }, - ), - ], - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 10598, - end: 10634, - }, - targets: [ - Name( - Name { - node: Node { - start: 10598, - end: 10605, - }, - id: "symbols", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 10632, - end: 10634, - }, - func: Attribute( - Attribute { - node: Node { - start: 10608, - end: 10632, - }, - value: Name( - Name { - node: Node { - start: 10608, - end: 10620, - }, - id: "symbols_data", - }, - ), - attr: "all_symbols", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ], - orelse: [ - IfStatement( - If { - node: Node { - start: 10639, - end: 10703, - }, - test: Call( - Call { - node: Node { - start: 10644, - end: 10668, - }, - func: Name( - Name { - node: Node { - start: 10644, - end: 10654, - }, - id: "isinstance", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 10655, - end: 10662, - }, - id: "symbols", - }, - ), - Name( - Name { - node: Node { - start: 10664, - end: 10667, - }, - id: "str", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 10678, - end: 10697, - }, - targets: [ - Name( - Name { - node: Node { - start: 10678, - end: 10685, - }, - id: "symbols", - }, - ), - ], - value: List( - List { - node: Node { - start: 10688, - end: 10697, - }, - elements: [ - Name( - Name { - node: Node { - start: 10689, - end: 10696, - }, - id: "symbols", - }, - ), - ], - }, - ), - }, - ), - ], - orelse: [], - }, - ), - ], - }, - ), - AssignStatement( - Assign { - node: Node { - start: 10703, - end: 10715, - }, - targets: [ - Name( - Name { - node: Node { - start: 10703, - end: 10710, - }, - id: "df_list", - }, - ), - ], - value: Dict( - Dict { - node: Node { - start: 10713, - end: 10715, - }, - keys: [], - values: [], - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 10720, - end: 10741, - }, - targets: [ - Name( - Name { - node: Node { - start: 10720, - end: 10736, - }, - id: "future_to_symbol", - }, - ), - ], - value: Dict( - Dict { - node: Node { - start: 10739, - end: 10741, - }, - keys: [], - values: [], - }, - ), - }, - ), - WithStatement( - With { - node: Node { - start: 10746, - end: 11636, - }, - items: [ - WithItem { - node: Node { - start: 10751, - end: 10805, - }, - context_expr: Call( - Call { - node: Node { - start: 10777, - end: 10793, - }, - func: Attribute( - Attribute { - node: Node { - start: 10751, - end: 10777, - }, - value: Name( - Name { - node: Node { - start: 10751, - end: 10758, - }, - id: "futures", - }, - ), - attr: "ThreadPoolExecutor", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 10778, - end: 10792, - }, - arg: Some( - "max_workers", - ), - value: Constant( - Constant { - node: Node { - start: 10790, - end: 10792, - }, - value: 10, - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - optional_vars: Some( - Name( - Name { - node: Node { - start: 10797, - end: 10805, - }, - id: "executor", - }, - ), - ), - }, - ], - body: [ - ForStatement( - For { - node: Node { - start: 10815, - end: 11168, - }, - target: Name( - Name { - node: Node { - start: 10819, - end: 10825, - }, - id: "symbol", - }, - ), - iter: Name( - Name { - node: Node { - start: 10829, - end: 10836, - }, - id: "symbols", - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 10850, - end: 10893, - }, - targets: [ - Name( - Name { - node: Node { - start: 10850, - end: 10862, - }, - id: "ticker_index", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 10865, - end: 10893, - }, - func: Name( - Name { - node: Node { - start: 10865, - end: 10885, - }, - id: "_handle_ticker_index", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 10886, - end: 10892, - }, - id: "symbol", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - IfStatement( - If { - node: Node { - start: 10906, - end: 11008, - }, - test: Compare( - Compare { - node: Node { - start: 10909, - end: 10929, - }, - left: Name( - Name { - node: Node { - start: 10909, - end: 10921, - }, - id: "ticker_index", - }, - ), - ops: [ - Is, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 10925, - end: 10929, - }, - value: None, - }, - ), - ], - }, - ), - body: [ - Raise( - Raise { - node: Node { - start: 10947, - end: 10995, - }, - exc: Some( - Call( - Call { - node: Node { - start: 10953, - end: 10995, - }, - func: Name( - Name { - node: Node { - start: 10953, - end: 10962, - }, - id: "Exception", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 10963, - end: 10994, - }, - values: [ - Constant( - Constant { - node: Node { - start: 10985, - end: 0, - }, - value: "Cannot find symbol: ", - }, - ), - Name( - Name { - node: Node { - start: 10986, - end: 10992, - }, - id: "symbol", - }, - ), - ], - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - cause: None, - }, - ), - ], - orelse: [], - }, - ), - AssignStatement( - Assign { - node: Node { - start: 11008, - end: 11113, - }, - targets: [ - Name( - Name { - node: Node { - start: 11008, - end: 11014, - }, - id: "future", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 11032, - end: 11113, - }, - func: Attribute( - Attribute { - node: Node { - start: 11017, - end: 11032, - }, - value: Name( - Name { - node: Node { - start: 11017, - end: 11025, - }, - id: "executor", - }, - ), - attr: "submit", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 11050, - end: 11085, - }, - id: "download_ticker_client_types_record", - }, - ), - Name( - Name { - node: Node { - start: 11087, - end: 11099, - }, - id: "ticker_index", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 11126, - end: 11159, - }, - targets: [ - Subscript( - Subscript { - node: Node { - start: 11126, - end: 11150, - }, - value: Name( - Name { - node: Node { - start: 11126, - end: 11142, - }, - id: "future_to_symbol", - }, - ), - slice: Name( - Name { - node: Node { - start: 11143, - end: 11149, - }, - id: "future", - }, - ), - }, - ), - ], - value: Name( - Name { - node: Node { - start: 11153, - end: 11159, - }, - id: "symbol", - }, - ), - }, - ), - ], - orelse: [], - }, - ), - ForStatement( - For { - node: Node { - start: 11168, - end: 11636, - }, - target: Name( - Name { - node: Node { - start: 11172, - end: 11178, - }, - id: "future", - }, - ), - iter: Call( - Call { - node: Node { - start: 11202, - end: 11220, - }, - func: Attribute( - Attribute { - node: Node { - start: 11182, - end: 11202, - }, - value: Name( - Name { - node: Node { - start: 11182, - end: 11189, - }, - id: "futures", - }, - ), - attr: "as_completed", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 11203, - end: 11219, - }, - id: "future_to_symbol", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 11234, - end: 11267, - }, - targets: [ - Name( - Name { - node: Node { - start: 11234, - end: 11240, - }, - id: "symbol", - }, - ), - ], - value: Subscript( - Subscript { - node: Node { - start: 11243, - end: 11267, - }, - value: Name( - Name { - node: Node { - start: 11243, - end: 11259, - }, - id: "future_to_symbol", - }, - ), - slice: Name( - Name { - node: Node { - start: 11260, - end: 11266, - }, - id: "future", - }, - ), - }, - ), - }, - ), - AnnAssignStatement( - AnnAssign { - node: Node { - start: 11280, - end: 11314, - }, - target: Name( - Name { - node: Node { - start: 11280, - end: 11282, - }, - id: "df", - }, - ), - annotation: Attribute( - Attribute { - node: Node { - start: 11284, - end: 11296, - }, - value: Name( - Name { - node: Node { - start: 11284, - end: 11286, - }, - id: "pd", - }, - ), - attr: "DataFrame", - }, - ), - value: Some( - Call( - Call { - node: Node { - start: 11312, - end: 11314, - }, - func: Attribute( - Attribute { - node: Node { - start: 11299, - end: 11312, - }, - value: Name( - Name { - node: Node { - start: 11299, - end: 11305, - }, - id: "future", - }, - ), - attr: "result", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - simple: true, - }, - ), - IfStatement( - If { - node: Node { - start: 11357, - end: 11409, - }, - test: Compare( - Compare { - node: Node { - start: 11360, - end: 11370, - }, - left: Name( - Name { - node: Node { - start: 11360, - end: 11362, - }, - id: "df", - }, - ), - ops: [ - Is, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 11366, - end: 11370, - }, - value: None, - }, - ), - ], - }, - ), - body: [ - Continue( - Continue { - node: Node { - start: 11388, - end: 11396, - }, - }, - ), - ], - orelse: [], - }, - ), - ExpressionStatement( - Call( - Call { - node: Node { - start: 11409, - end: 11446, - }, - func: Name( - Name { - node: Node { - start: 11409, - end: 11427, - }, - id: "_adjust_data_frame", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 11428, - end: 11430, - }, - id: "df", - }, - ), - Name( - Name { - node: Node { - start: 11432, - end: 11445, - }, - id: "include_jdate", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - AssignStatement( - Assign { - node: Node { - start: 11459, - end: 11479, - }, - targets: [ - Subscript( - Subscript { - node: Node { - start: 11459, - end: 11474, - }, - value: Name( - Name { - node: Node { - start: 11459, - end: 11466, - }, - id: "df_list", - }, - ), - slice: Name( - Name { - node: Node { - start: 11467, - end: 11473, - }, - id: "symbol", - }, - ), - }, - ), - ], - value: Name( - Name { - node: Node { - start: 11477, - end: 11479, - }, - id: "df", - }, - ), - }, - ), - IfStatement( - If { - node: Node { - start: 11492, - end: 11636, - }, - test: Name( - Name { - node: Node { - start: 11495, - end: 11507, - }, - id: "write_to_csv", - }, - ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 11546, - end: 11575, - }, - func: Attribute( - Attribute { - node: Node { - start: 11540, - end: 11546, - }, - value: Call( - Call { - node: Node { - start: 11525, - end: 11540, - }, - func: Name( - Name { - node: Node { - start: 11525, - end: 11529, - }, - id: "Path", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 11530, - end: 11539, - }, - id: "base_path", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - attr: "mkdir", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 11547, - end: 11559, - }, - arg: Some( - "parents", - ), - value: Constant( - Constant { - node: Node { - start: 11555, - end: 11559, - }, - value: true, - }, - ), - }, - Keyword { - node: Node { - start: 11561, - end: 11574, - }, - arg: Some( - "exist_ok", - ), - value: Constant( - Constant { - node: Node { - start: 11570, - end: 11574, - }, - value: true, - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ), - ExpressionStatement( - Call( - Call { - node: Node { - start: 11601, - end: 11630, - }, - func: Attribute( - Attribute { - node: Node { - start: 11592, - end: 11601, - }, - value: Name( - Name { - node: Node { - start: 11592, - end: 11594, - }, - id: "df", - }, - ), - attr: "to_csv", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 11602, - end: 11629, - }, - values: [ - Name( - Name { - node: Node { - start: 11605, - end: 11614, - }, - id: "base_path", - }, - ), - Constant( - Constant { - node: Node { - start: 11616, - end: 0, - }, - value: "/", - }, - ), - Name( - Name { - node: Node { - start: 11617, - end: 11623, - }, - id: "symbol", - }, - ), - Constant( - Constant { - node: Node { - start: 11628, - end: 0, - }, - value: ".csv", - }, - ), - ], - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - ], - orelse: [], - }, - ), - ], - orelse: [], - }, - ), - ], - }, - ), - IfStatement( - If { - node: Node { - start: 11636, - end: 11832, - }, - test: Compare( - Compare { - node: Node { - start: 11639, - end: 11667, - }, - left: Call( - Call { - node: Node { - start: 11639, - end: 11651, - }, - func: Name( - Name { - node: Node { - start: 11639, - end: 11642, - }, - id: "len", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 11643, - end: 11650, - }, - id: "df_list", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ops: [ - NotEq, - ], - comparators: [ - Call( - Call { - node: Node { - start: 11655, - end: 11667, - }, - func: Name( - Name { - node: Node { - start: 11655, - end: 11658, - }, - id: "len", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 11659, - end: 11666, - }, - id: "symbols", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ], - }, - ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 11677, - end: 11827, - }, - func: Name( - Name { - node: Node { - start: 11677, - end: 11682, - }, - id: "print", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 11696, - end: 11817, - }, - value: "could not download client types for all the symbols make - sure you have what you need or re-run the function", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - ], - orelse: [], - }, - ), - Return( - Return { - node: Node { - start: 11832, - end: 11846, - }, - value: Some( - Name( - Name { - node: Node { - start: 11839, - end: 11846, - }, - id: "df_list", - }, - ), - ), - }, - ), - ], - decorator_list: [], - returns: None, - type_comment: None, - type_params: [], - }, - ), - FunctionDef( - FunctionDef { - node: Node { - start: 11999, - end: 13481, - }, - name: "download_ticker_client_types_record", - args: Arguments { - node: Node { - start: 12039, - end: 12066, - }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 12039, - end: 12066, - }, - arg: "ticker_index", - annotation: Some( - Subscript( - Subscript { - node: Node { - start: 12053, - end: 12066, - }, - value: Name( - Name { - node: Node { - start: 12053, - end: 12061, - }, - id: "Optional", - }, - ), - slice: Name( - Name { - node: Node { - start: 12062, - end: 12065, - }, - id: "str", - }, - ), - }, - ), - ), - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: [ - AssignStatement( - Assign { - node: Node { - start: 12073, - end: 12127, - }, - targets: [ - Name( - Name { - node: Node { - start: 12073, - end: 12077, - }, - id: "data", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 12080, - end: 12127, - }, - func: Name( - Name { - node: Node { - start: 12080, - end: 12113, - }, - id: "_extract_ticker_client_types_data", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 12114, - end: 12126, - }, - id: "ticker_index", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - IfStatement( - If { - node: Node { - start: 12132, - end: 12367, - }, - test: Compare( - Compare { - node: Node { - start: 12135, - end: 12149, - }, - left: Call( - Call { - node: Node { - start: 12135, - end: 12144, - }, - func: Name( - Name { - node: Node { - start: 12135, - end: 12138, - }, - id: "len", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 12139, - end: 12143, - }, - id: "data", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ops: [ - Eq, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 12148, - end: 12149, - }, - value: 1, - }, - ), - ], - }, - ), - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 12173, - end: 12342, - }, - func: Attribute( - Attribute { - node: Node { - start: 12159, - end: 12173, - }, - value: Name( - Name { - node: Node { - start: 12159, - end: 12165, - }, - id: "logger", - }, - ), - attr: "warning", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 12187, - end: 12281, - }, - values: [ - Constant( - Constant { - node: Node { - start: 12233, - end: 0, - }, - value: "Cannot create client types data for ticker", - }, - ), - Name( - Name { - node: Node { - start: 12234, - end: 12246, - }, - id: "ticker_index", - }, - ), - Constant( - Constant { - node: Node { - start: 12272, - end: 0, - }, - value: " - from data: ", - }, - ), - Name( - Name { - node: Node { - start: 12273, - end: 12277, - }, - id: "data", - }, - ), - ], - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 12295, - end: 12331, - }, - arg: Some( - "extra", - ), - value: Dict( - Dict { - node: Node { - start: 12301, - end: 12331, - }, - keys: [ - Constant( - Constant { - node: Node { - start: 12302, - end: 12316, - }, - value: "ticker_index", - }, - ), - ], - values: [ - Name( - Name { - node: Node { - start: 12318, - end: 12330, - }, - id: "ticker_index", - }, - ), - ], - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ), - Return( - Return { - node: Node { - start: 12351, - end: 12362, - }, - value: Some( - Constant( - Constant { - node: Node { - start: 12358, - end: 12362, - }, - value: None, - }, - ), - ), - }, - ), - ], - orelse: [], - }, - ), - AssignStatement( - Assign { - node: Node { - start: 12367, - end: 12899, - }, - targets: [ - Name( - Name { - node: Node { - start: 12367, - end: 12390, - }, - id: "client_types_data_frame", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 12405, - end: 12899, - }, - func: Attribute( - Attribute { - node: Node { - start: 12393, - end: 12405, - }, - value: Name( - Name { - node: Node { - start: 12393, - end: 12395, - }, - id: "pd", - }, - ), - attr: "DataFrame", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 12415, - end: 12419, - }, - id: "data", - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 12429, - end: 12892, - }, - arg: Some( - "columns", - ), - value: List( - List { - node: Node { - start: 12437, - end: 12892, - }, - elements: [ - Constant( - Constant { - node: Node { - start: 12451, - end: 12457, - }, - value: "date", - }, - ), - Constant( - Constant { - node: Node { - start: 12471, - end: 12493, - }, - value: "individual_buy_count", - }, - ), - Constant( - Constant { - node: Node { - start: 12507, - end: 12528, - }, - value: "corporate_buy_count", - }, - ), - Constant( - Constant { - node: Node { - start: 12542, - end: 12565, - }, - value: "individual_sell_count", - }, - ), - Constant( - Constant { - node: Node { - start: 12579, - end: 12601, - }, - value: "corporate_sell_count", - }, - ), - Constant( - Constant { - node: Node { - start: 12615, - end: 12635, - }, - value: "individual_buy_vol", - }, - ), - Constant( - Constant { - node: Node { - start: 12649, - end: 12668, - }, - value: "corporate_buy_vol", - }, - ), - Constant( - Constant { - node: Node { - start: 12682, - end: 12703, - }, - value: "individual_sell_vol", - }, - ), - Constant( - Constant { - node: Node { - start: 12717, - end: 12737, - }, - value: "corporate_sell_vol", - }, - ), - Constant( - Constant { - node: Node { - start: 12751, - end: 12773, - }, - value: "individual_buy_value", - }, - ), - Constant( - Constant { - node: Node { - start: 12787, - end: 12808, - }, - value: "corporate_buy_value", - }, - ), - Constant( - Constant { - node: Node { - start: 12822, - end: 12845, - }, - value: "individual_sell_value", - }, - ), - Constant( - Constant { - node: Node { - start: 12859, - end: 12881, - }, - value: "corporate_sell_value", - }, - ), - ], - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ForStatement( - For { - node: Node { - start: 12904, - end: 13210, - }, - target: Name( - Name { - node: Node { - start: 12908, - end: 12909, - }, - id: "i", - }, - ), - iter: List( - List { - node: Node { - start: 12913, - end: 13028, - }, - elements: [ - Constant( - Constant { - node: Node { - start: 12923, - end: 12940, - }, - value: "individual_buy_", - }, - ), - Constant( - Constant { - node: Node { - start: 12950, - end: 12968, - }, - value: "individual_sell_", - }, - ), - Constant( - Constant { - node: Node { - start: 12978, - end: 12994, - }, - value: "corporate_buy_", - }, - ), - Constant( - Constant { - node: Node { - start: 13004, - end: 13021, - }, - value: "corporate_sell_", - }, - ), - ], - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 13038, - end: 13205, - }, - targets: [ - Subscript( - Subscript { - node: Node { - start: 13038, - end: 13079, - }, - value: Name( - Name { - node: Node { - start: 13038, - end: 13061, - }, - id: "client_types_data_frame", - }, - ), - slice: JoinedStr( - JoinedStr { - node: Node { - start: 13062, - end: 13078, - }, - values: [ - Name( - Name { - node: Node { - start: 13065, - end: 13066, - }, - id: "i", - }, - ), - Constant( - Constant { - node: Node { - start: 13077, - end: 0, - }, - value: "mean_price", - }, - ), - ], - }, - ), - }, - ), - ], - value: BinOp( - BinOp { - node: Node { - start: 13082, - end: 13205, - }, - op: Div, - left: Call( - Call { - node: Node { - start: 13147, - end: 13154, - }, - func: Attribute( - Attribute { - node: Node { - start: 13140, - end: 13147, - }, - value: Subscript( - Subscript { - node: Node { - start: 13082, - end: 13140, - }, - value: Name( - Name { - node: Node { - start: 13082, - end: 13105, - }, - id: "client_types_data_frame", - }, - ), - slice: JoinedStr( - JoinedStr { - node: Node { - start: 13119, - end: 13130, - }, - values: [ - Name( - Name { - node: Node { - start: 13122, - end: 13123, - }, - id: "i", - }, - ), - Constant( - Constant { - node: Node { - start: 13129, - end: 0, - }, - value: "value", - }, - ), - ], - }, - ), - }, - ), - attr: "astype", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 13148, - end: 13153, - }, - id: "float", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - right: Call( - Call { - node: Node { - start: 13198, - end: 13205, - }, - func: Attribute( - Attribute { - node: Node { - start: 13191, - end: 13198, - }, - value: Subscript( - Subscript { - node: Node { - start: 13157, - end: 13191, - }, - value: Name( - Name { - node: Node { - start: 13157, - end: 13180, - }, - id: "client_types_data_frame", - }, - ), - slice: JoinedStr( - JoinedStr { - node: Node { - start: 13181, - end: 13190, - }, - values: [ - Name( - Name { - node: Node { - start: 13184, - end: 13185, - }, - id: "i", - }, - ), - Constant( - Constant { - node: Node { - start: 13189, - end: 0, - }, - value: "vol", - }, - ), - ], - }, - ), - }, - ), - attr: "astype", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 13199, - end: 13204, - }, - id: "float", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - }, - ), - ], - orelse: [], - }, - ), - AssignStatement( - Assign { - node: Node { - start: 13210, - end: 13443, - }, - targets: [ - Subscript( - Subscript { - node: Node { - start: 13210, - end: 13278, - }, - value: Name( - Name { - node: Node { - start: 13210, - end: 13233, - }, - id: "client_types_data_frame", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 13243, - end: 13272, - }, - value: "individual_ownership_change", - }, - ), - }, - ), - ], - value: BinOp( - BinOp { - node: Node { - start: 13281, - end: 13443, - }, - op: Sub, - left: Call( - Call { - node: Node { - start: 13333, - end: 13354, - }, - func: Attribute( - Attribute { - node: Node { - start: 13326, - end: 13333, - }, - value: Subscript( - Subscript { - node: Node { - start: 13281, - end: 13326, - }, - value: Name( - Name { - node: Node { - start: 13281, - end: 13304, - }, - id: "client_types_data_frame", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 13305, - end: 13325, - }, - value: "corporate_sell_vol", - }, - ), - }, - ), - attr: "astype", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 13343, - end: 13348, - }, - id: "float", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - right: Call( - Call { - node: Node { - start: 13422, - end: 13443, - }, - func: Attribute( - Attribute { - node: Node { - start: 13415, - end: 13422, - }, - value: Subscript( - Subscript { - node: Node { - start: 13357, - end: 13415, - }, - value: Name( - Name { - node: Node { - start: 13357, - end: 13380, - }, - id: "client_types_data_frame", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 13390, - end: 13409, - }, - value: "corporate_buy_vol", - }, - ), - }, - ), - attr: "astype", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 13432, - end: 13437, - }, - id: "float", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - }, - ), - Return( - Return { - node: Node { - start: 13448, - end: 13478, - }, - value: Some( - Name( - Name { - node: Node { - start: 13455, - end: 13478, - }, - id: "client_types_data_frame", - }, - ), - ), - }, - ), - ], - decorator_list: [ - Call( - Call { - node: Node { - start: 11850, - end: 11998, - }, - func: Name( - Name { - node: Node { - start: 11850, - end: 11855, - }, - id: "retry", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 11861, - end: 11901, - }, - arg: Some( - "retry", - ), - value: Call( - Call { - node: Node { - start: 11867, - end: 11901, - }, - func: Name( - Name { - node: Node { - start: 11867, - end: 11890, - }, - id: "retry_if_exception_type", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 11891, - end: 11900, - }, - id: "HTTPError", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - Keyword { - node: Node { - start: 11907, - end: 11937, - }, - arg: Some( - "wait", - ), - value: Call( - Call { - node: Node { - start: 11912, - end: 11937, - }, - func: Name( - Name { - node: Node { - start: 11912, - end: 11923, - }, - id: "wait_random", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 11924, - end: 11929, - }, - arg: Some( - "min", - ), - value: Constant( - Constant { - node: Node { - start: 11928, - end: 11929, - }, - value: 1, - }, - ), - }, - Keyword { - node: Node { - start: 11931, - end: 11936, - }, - arg: Some( - "max", - ), - value: Constant( - Constant { - node: Node { - start: 11935, - end: 11936, - }, - value: 4, - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - Keyword { - node: Node { - start: 11943, - end: 11995, - }, - arg: Some( - "before_sleep", - ), - value: Call( - Call { - node: Node { - start: 11956, - end: 11995, - }, - func: Name( - Name { - node: Node { - start: 11956, - end: 11972, - }, - id: "before_sleep_log", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 11973, - end: 11979, - }, - id: "logger", - }, - ), - Attribute( - Attribute { - node: Node { - start: 11981, - end: 11994, - }, - value: Name( - Name { - node: Node { - start: 11981, - end: 11988, - }, - id: "logging", - }, - ), - attr: "DEBUG", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - ], - returns: None, - type_comment: None, - type_params: [], - }, - ), - FunctionDef( - FunctionDef { - node: Node { - start: 13481, - end: 13980, - }, - name: "get_symbol_id", - args: Arguments { - node: Node { - start: 13499, - end: 13515, - }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 13499, - end: 13515, - }, - arg: "symbol_name", - annotation: Some( - Name( - Name { - node: Node { - start: 13512, - end: 13515, - }, - id: "str", - }, - ), - ), - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: [ - AssignStatement( - Assign { - node: Node { - start: 13522, - end: 13586, - }, - targets: [ - Name( - Name { - node: Node { - start: 13522, - end: 13525, - }, - id: "url", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 13565, - end: 13586, - }, - func: Attribute( - Attribute { - node: Node { - start: 13528, - end: 13565, - }, - value: Attribute( - Attribute { - node: Node { - start: 13528, - end: 13558, - }, - value: Name( - Name { - node: Node { - start: 13528, - end: 13540, - }, - id: "tse_settings", - }, - ), - attr: "TSE_SYMBOL_ID_URL", - }, - ), - attr: "format", - }, - ), - args: [ - Call( - Call { - node: Node { - start: 13583, - end: 13585, - }, - func: Attribute( - Attribute { - node: Node { - start: 13566, - end: 13583, - }, - value: Name( - Name { - node: Node { - start: 13566, - end: 13577, - }, - id: "symbol_name", - }, - ), - attr: "strip", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 13591, - end: 13647, - }, - targets: [ - Name( - Name { - node: Node { - start: 13591, - end: 13599, - }, - id: "response", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 13630, - end: 13647, - }, - func: Attribute( - Attribute { - node: Node { - start: 13626, - end: 13630, - }, - value: Call( - Call { - node: Node { - start: 13602, - end: 13626, - }, - func: Name( - Name { - node: Node { - start: 13602, - end: 13624, - }, - id: "requests_retry_session", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - attr: "get", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 13631, - end: 13634, - }, - id: "url", - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 13636, - end: 13646, - }, - arg: Some( - "timeout", - ), - value: Constant( - Constant { - node: Node { - start: 13644, - end: 13646, - }, - value: 10, - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - ), - TryStatement( - Try { - node: Node { - start: 13652, - end: 13781, - }, - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 13690, - end: 13692, - }, - func: Attribute( - Attribute { - node: Node { - start: 13665, - end: 13690, - }, - value: Name( - Name { - node: Node { - start: 13665, - end: 13673, - }, - id: "response", - }, - ), - attr: "raise_for_status", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - ], - handlers: [ - ExceptHandler { - node: Node { - start: 13697, - end: 13781, - }, - typ: Some( - Name( - Name { - node: Node { - start: 13704, - end: 13713, - }, - id: "HTTPError", - }, - ), - ), - name: None, - body: [ - Raise( - Raise { - node: Node { - start: 13723, - end: 13775, - }, - exc: Some( - Call( - Call { - node: Node { - start: 13729, - end: 13775, - }, - func: Name( - Name { - node: Node { - start: 13729, - end: 13738, - }, - id: "Exception", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 13739, - end: 13774, - }, - value: "Sorry, tse server did not respond", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - cause: None, - }, - ), - ], - }, - ], - orelse: [], - finalbody: [], - }, - ), - AssignStatement( - Assign { - node: Node { - start: 13781, - end: 13838, - }, - targets: [ - Name( - Name { - node: Node { - start: 13781, - end: 13797, - }, - id: "symbol_full_info", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 13833, - end: 13838, - }, - func: Attribute( - Attribute { - node: Node { - start: 13827, - end: 13833, - }, - value: Subscript( - Subscript { - node: Node { - start: 13824, - end: 13827, - }, - value: Call( - Call { - node: Node { - start: 13819, - end: 13824, - }, - func: Attribute( - Attribute { - node: Node { - start: 13800, - end: 13819, - }, - value: Attribute( - Attribute { - node: Node { - start: 13800, - end: 13813, - }, - value: Name( - Name { - node: Node { - start: 13800, - end: 13808, - }, - id: "response", - }, - ), - attr: "text", - }, - ), - attr: "split", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 13820, - end: 13823, - }, - value: ";", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - slice: Constant( - Constant { - node: Node { - start: 13825, - end: 13826, - }, - value: 0, - }, - ), - }, - ), - attr: "split", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 13834, - end: 13837, - }, - value: ",", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - IfStatement( - If { - node: Node { - start: 13843, - end: 13966, - }, - test: Compare( - Compare { - node: Node { - start: 13846, - end: 13912, - }, - left: Call( - Call { - node: Node { - start: 13868, - end: 13881, - }, - func: Attribute( - Attribute { - node: Node { - start: 13846, - end: 13868, - }, - value: Name( - Name { - node: Node { - start: 13846, - end: 13853, - }, - id: "persian", - }, - ), - attr: "replace_arabic", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 13869, - end: 13880, - }, - id: "symbol_name", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ops: [ - Eq, - ], - comparators: [ - Call( - Call { - node: Node { - start: 13910, - end: 13912, - }, - func: Attribute( - Attribute { - node: Node { - start: 13904, - end: 13910, - }, - value: Subscript( - Subscript { - node: Node { - start: 13885, - end: 13904, - }, - value: Name( - Name { - node: Node { - start: 13885, - end: 13901, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 13902, - end: 13903, - }, - value: 0, - }, - ), - }, - ), - attr: "strip", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ], - }, - ), - body: [ - Return( - Return { - node: Node { - start: 13922, - end: 13961, - }, - value: Some( - Subscript( - Subscript { - node: Node { - start: 13929, - end: 13961, - }, - value: Name( - Name { - node: Node { - start: 13929, - end: 13945, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 13946, - end: 13947, - }, - value: 2, - }, - ), - }, - ), - ), - }, - ), - ], - orelse: [], - }, - ), - Return( - Return { - node: Node { - start: 13966, - end: 13977, - }, - value: Some( - Constant( - Constant { - node: Node { - start: 13973, - end: 13977, - }, - value: None, - }, - ), - ), - }, - ), - ], - decorator_list: [], - returns: None, - type_comment: None, - type_params: [], - }, - ), - FunctionDef( - FunctionDef { - node: Node { - start: 13980, - end: 15273, - }, - name: "get_symbol_info", - args: Arguments { - node: Node { - start: 14000, - end: 14016, - }, - posonlyargs: [], - args: [ - Arg { - node: Node { - start: 14000, - end: 14016, - }, - arg: "symbol_name", - annotation: Some( - Name( - Name { - node: Node { - start: 14013, - end: 14016, - }, - id: "str", - }, - ), - ), - }, - ], - vararg: None, - kwonlyargs: [], - kw_defaults: [], - kwarg: None, - defaults: [], - }, - body: [ - AssignStatement( - Assign { - node: Node { - start: 14023, - end: 14087, - }, - targets: [ - Name( - Name { - node: Node { - start: 14023, - end: 14026, - }, - id: "url", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 14066, - end: 14087, - }, - func: Attribute( - Attribute { - node: Node { - start: 14029, - end: 14066, - }, - value: Attribute( - Attribute { - node: Node { - start: 14029, - end: 14059, - }, - value: Name( - Name { - node: Node { - start: 14029, - end: 14041, - }, - id: "tse_settings", - }, - ), - attr: "TSE_SYMBOL_ID_URL", - }, - ), - attr: "format", - }, - ), - args: [ - Call( - Call { - node: Node { - start: 14084, - end: 14086, - }, - func: Attribute( - Attribute { - node: Node { - start: 14067, - end: 14084, - }, - value: Name( - Name { - node: Node { - start: 14067, - end: 14078, - }, - id: "symbol_name", - }, - ), - attr: "strip", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 14092, - end: 14148, - }, - targets: [ - Name( - Name { - node: Node { - start: 14092, - end: 14100, - }, - id: "response", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 14131, - end: 14148, - }, - func: Attribute( - Attribute { - node: Node { - start: 14127, - end: 14131, - }, - value: Call( - Call { - node: Node { - start: 14103, - end: 14127, - }, - func: Name( - Name { - node: Node { - start: 14103, - end: 14125, - }, - id: "requests_retry_session", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - attr: "get", - }, - ), - args: [ - Name( - Name { - node: Node { - start: 14132, - end: 14135, - }, - id: "url", - }, - ), - ], - keywords: [ - Keyword { - node: Node { - start: 14137, - end: 14147, - }, - arg: Some( - "timeout", - ), - value: Constant( - Constant { - node: Node { - start: 14145, - end: 14147, - }, - value: 10, - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - ), - TryStatement( - Try { - node: Node { - start: 14153, - end: 14298, - }, - body: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 14191, - end: 14193, - }, - func: Attribute( - Attribute { - node: Node { - start: 14166, - end: 14191, - }, - value: Name( - Name { - node: Node { - start: 14166, - end: 14174, - }, - id: "response", - }, - ), - attr: "raise_for_status", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - ], - handlers: [ - ExceptHandler { - node: Node { - start: 14198, - end: 14298, - }, - typ: Some( - Name( - Name { - node: Node { - start: 14205, - end: 14214, - }, - id: "HTTPError", - }, - ), - ), - name: None, - body: [ - Raise( - Raise { - node: Node { - start: 14224, - end: 14292, - }, - exc: Some( - Call( - Call { - node: Node { - start: 14230, - end: 14292, - }, - func: Name( - Name { - node: Node { - start: 14230, - end: 14239, - }, - id: "Exception", - }, - ), - args: [ - JoinedStr( - JoinedStr { - node: Node { - start: 14240, - end: 14291, - }, - values: [ - Name( - Name { - node: Node { - start: 14243, - end: 14254, - }, - id: "symbol_name", - }, - ), - Constant( - Constant { - node: Node { - start: 14290, - end: 0, - }, - value: ": Sorry, tse server did not respond", - }, - ), - ], - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - cause: None, - }, - ), - ], - }, - ], - orelse: [], - finalbody: [], - }, - ), - AssignStatement( - Assign { - node: Node { - start: 14298, - end: 14332, - }, - targets: [ - Name( - Name { - node: Node { - start: 14298, - end: 14305, - }, - id: "symbols", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 14327, - end: 14332, - }, - func: Attribute( - Attribute { - node: Node { - start: 14308, - end: 14327, - }, - value: Attribute( - Attribute { - node: Node { - start: 14308, - end: 14321, - }, - value: Name( - Name { - node: Node { - start: 14308, - end: 14316, - }, - id: "response", - }, - ), - attr: "text", - }, - ), - attr: "split", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 14328, - end: 14331, - }, - value: ";", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 14337, - end: 14467, - }, - targets: [ - Name( - Name { - node: Node { - start: 14337, - end: 14350, - }, - id: "market_symbol", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 14353, - end: 14467, - }, - func: Name( - Name { - node: Node { - start: 14353, - end: 14365, - }, - id: "MarketSymbol", - }, - ), - args: [], - keywords: [ - Keyword { - node: Node { - start: 14375, - end: 14384, - }, - arg: Some( - "code", - ), - value: Constant( - Constant { - node: Node { - start: 14380, - end: 14384, - }, - value: None, - }, - ), - }, - Keyword { - node: Node { - start: 14394, - end: 14405, - }, - arg: Some( - "symbol", - ), - value: Constant( - Constant { - node: Node { - start: 14401, - end: 14405, - }, - value: None, - }, - ), - }, - Keyword { - node: Node { - start: 14415, - end: 14425, - }, - arg: Some( - "index", - ), - value: Constant( - Constant { - node: Node { - start: 14421, - end: 14425, - }, - value: None, - }, - ), - }, - Keyword { - node: Node { - start: 14435, - end: 14444, - }, - arg: Some( - "name", - ), - value: Constant( - Constant { - node: Node { - start: 14440, - end: 14444, - }, - value: None, - }, - ), - }, - Keyword { - node: Node { - start: 14454, - end: 14460, - }, - arg: Some( - "old", - ), - value: List( - List { - node: Node { - start: 14458, - end: 14460, - }, - elements: [], - }, - ), - }, - ], - starargs: None, - kwargs: None, - }, - ), - }, - ), - ForStatement( - For { - node: Node { - start: 14472, - end: 15195, - }, - target: Name( - Name { - node: Node { - start: 14476, - end: 14492, - }, - id: "symbol_full_info", - }, - ), - iter: Name( - Name { - node: Node { - start: 14496, - end: 14503, - }, - id: "symbols", - }, - ), - body: [ - IfStatement( - If { - node: Node { - start: 14513, - end: 14577, - }, - test: Compare( - Compare { - node: Node { - start: 14516, - end: 14546, - }, - left: Call( - Call { - node: Node { - start: 14538, - end: 14540, - }, - func: Attribute( - Attribute { - node: Node { - start: 14516, - end: 14538, - }, - value: Name( - Name { - node: Node { - start: 14516, - end: 14532, - }, - id: "symbol_full_info", - }, - ), - attr: "strip", - }, - ), - args: [], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ops: [ - Eq, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 14544, - end: 14546, - }, - value: "", - }, - ), - ], - }, - ), - body: [ - Continue( - Continue { - node: Node { - start: 14560, - end: 14568, - }, - }, - ), - ], - orelse: [], - }, - ), - AssignStatement( - Assign { - node: Node { - start: 14577, - end: 14623, - }, - targets: [ - Name( - Name { - node: Node { - start: 14577, - end: 14593, - }, - id: "symbol_full_info", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 14618, - end: 14623, - }, - func: Attribute( - Attribute { - node: Node { - start: 14596, - end: 14618, - }, - value: Name( - Name { - node: Node { - start: 14596, - end: 14612, - }, - id: "symbol_full_info", - }, - ), - attr: "split", - }, - ), - args: [ - Constant( - Constant { - node: Node { - start: 14619, - end: 14622, - }, - value: ",", - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - IfStatement( - If { - node: Node { - start: 14632, - end: 15195, - }, - test: Compare( - Compare { - node: Node { - start: 14635, - end: 14693, - }, - left: Call( - Call { - node: Node { - start: 14657, - end: 14678, - }, - func: Attribute( - Attribute { - node: Node { - start: 14635, - end: 14657, - }, - value: Name( - Name { - node: Node { - start: 14635, - end: 14642, - }, - id: "persian", - }, - ), - attr: "replace_arabic", - }, - ), - args: [ - Subscript( - Subscript { - node: Node { - start: 14658, - end: 14677, - }, - value: Name( - Name { - node: Node { - start: 14658, - end: 14674, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 14675, - end: 14676, - }, - value: 0, - }, - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ops: [ - Eq, - ], - comparators: [ - Name( - Name { - node: Node { - start: 14682, - end: 14693, - }, - id: "symbol_name", - }, - ), - ], - }, - ), - body: [ - IfStatement( - If { - node: Node { - start: 14744, - end: 15195, - }, - test: Compare( - Compare { - node: Node { - start: 14747, - end: 14773, - }, - left: Subscript( - Subscript { - node: Node { - start: 14747, - end: 14766, - }, - value: Name( - Name { - node: Node { - start: 14747, - end: 14763, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 14764, - end: 14765, - }, - value: 7, - }, - ), - }, - ), - ops: [ - Eq, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 14770, - end: 14773, - }, - value: "1", - }, - ), - ], - }, - ), - body: [ - AssignStatement( - Assign { - node: Node { - start: 14791, - end: 14895, - }, - targets: [ - Attribute( - Attribute { - node: Node { - start: 14791, - end: 14811, - }, - value: Name( - Name { - node: Node { - start: 14791, - end: 14804, - }, - id: "market_symbol", - }, - ), - attr: "symbol", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 14836, - end: 14895, - }, - func: Attribute( - Attribute { - node: Node { - start: 14814, - end: 14836, - }, - value: Name( - Name { - node: Node { - start: 14814, - end: 14821, - }, - id: "persian", - }, - ), - attr: "replace_arabic", - }, - ), - args: [ - Subscript( - Subscript { - node: Node { - start: 14858, - end: 14877, - }, - value: Name( - Name { - node: Node { - start: 14858, - end: 14874, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 14875, - end: 14876, - }, - value: 0, - }, - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 14912, - end: 15014, - }, - targets: [ - Attribute( - Attribute { - node: Node { - start: 14912, - end: 14930, - }, - value: Name( - Name { - node: Node { - start: 14912, - end: 14925, - }, - id: "market_symbol", - }, - ), - attr: "name", - }, - ), - ], - value: Call( - Call { - node: Node { - start: 14955, - end: 15014, - }, - func: Attribute( - Attribute { - node: Node { - start: 14933, - end: 14955, - }, - value: Name( - Name { - node: Node { - start: 14933, - end: 14940, - }, - id: "persian", - }, - ), - attr: "replace_arabic", - }, - ), - args: [ - Subscript( - Subscript { - node: Node { - start: 14977, - end: 14996, - }, - value: Name( - Name { - node: Node { - start: 14977, - end: 14993, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 14994, - end: 14995, - }, - value: 1, - }, - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - }, - ), - AssignStatement( - Assign { - node: Node { - start: 15031, - end: 15092, - }, - targets: [ - Attribute( - Attribute { - node: Node { - start: 15031, - end: 15050, - }, - value: Name( - Name { - node: Node { - start: 15031, - end: 15044, - }, - id: "market_symbol", - }, - ), - attr: "index", - }, - ), - ], - value: Subscript( - Subscript { - node: Node { - start: 15053, - end: 15092, - }, - value: Name( - Name { - node: Node { - start: 15053, - end: 15069, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 15070, - end: 15071, - }, - value: 2, - }, - ), - }, - ), - }, - ), - ], - orelse: [ - ExpressionStatement( - Call( - Call { - node: Node { - start: 15151, - end: 15189, - }, - func: Attribute( - Attribute { - node: Node { - start: 15127, - end: 15151, - }, - value: Attribute( - Attribute { - node: Node { - start: 15127, - end: 15144, - }, - value: Name( - Name { - node: Node { - start: 15127, - end: 15140, - }, - id: "market_symbol", - }, - ), - attr: "old", - }, - ), - attr: "append", - }, - ), - args: [ - Subscript( - Subscript { - node: Node { - start: 15152, - end: 15171, - }, - value: Name( - Name { - node: Node { - start: 15152, - end: 15168, - }, - id: "symbol_full_info", - }, - ), - slice: Constant( - Constant { - node: Node { - start: 15169, - end: 15170, - }, - value: 2, - }, - ), - }, - ), - ], - keywords: [], - starargs: None, - kwargs: None, - }, - ), - ), - ], - }, - ), - ], - orelse: [], - }, - ), - ], - orelse: [], - }, - ), - IfStatement( - If { - node: Node { - start: 15195, - end: 15251, - }, - test: Compare( - Compare { - node: Node { - start: 15198, - end: 15225, - }, - left: Attribute( - Attribute { - node: Node { - start: 15198, - end: 15217, - }, - value: Name( - Name { - node: Node { - start: 15198, - end: 15211, - }, - id: "market_symbol", - }, - ), - attr: "index", - }, - ), - ops: [ - Is, - ], - comparators: [ - Constant( - Constant { - node: Node { - start: 15221, - end: 15225, - }, - value: None, - }, - ), - ], - }, - ), - body: [ - Return( - Return { - node: Node { - start: 15235, - end: 15246, - }, - value: Some( - Constant( - Constant { - node: Node { - start: 15242, - end: 15246, - }, - value: None, - }, - ), - ), - }, - ), - ], - orelse: [], - }, - ), - Return( - Return { - node: Node { - start: 15251, - end: 15271, - }, - value: Some( - Name( - Name { - node: Node { - start: 15258, - end: 15271, - }, - id: "market_symbol", - }, - ), - ), - }, - ), - ], - decorator_list: [], - returns: None, - type_comment: None, - type_params: [], - }, - ), - ], -} diff --git a/parser/test_data/inputs/input_program.py b/parser/test_data/inputs/input_program.py deleted file mode 100644 index 18499c6b..00000000 --- a/parser/test_data/inputs/input_program.py +++ /dev/null @@ -1,467 +0,0 @@ -def _handle_ticker_index(symbol): - ticker_index = symbols_data.get_ticker_index(symbol) - - if ticker_index is None: - market_symbol = get_symbol_info(symbol) - if market_symbol is not None: - symbols_data.append_symbol_to_file(market_symbol) - ticker_index = market_symbol.index - return ticker_index - - -def _extract_ticker_client_types_data(ticker_index: str) -> List: - url = TSE_CLIENT_TYPE_DATA_URL.format(ticker_index) - with requests_retry_session() as session: - response = session.get(url, timeout=5) - data = response.text.split(";") - data = [row.split(",") for row in data] - return data - - -def _create_financial_index_from_text_response(data): - data = pd.DataFrame(re.split(r"\;", data)) - columns = ["date", "high", "low", "open", "close", "volume", "__"] - data[columns] = data[0].str.split(",", expand=True) - return data.drop(columns=["__", 0]) - - -def _adjust_data_frame(df, include_jdate): - df.date = pd.to_datetime(df.date, format="%Y%m%d") - if include_jdate: - df["jdate"] = "" - df.jdate = df.date.apply( - lambda gregorian: jdatetime.date.fromgregorian(date=gregorian) - ) - - -def _adjust_data_frame_for_fIndex(df, include_jdate): - df["date"] = pd.to_datetime(df["date"], format="%Y%m%d") - if include_jdate: - df["jdate"] = df.date.apply( - lambda gregorian: jdatetime.date.fromgregorian(date=gregorian) - ) - - -def download( - symbols: Union[List, str], - write_to_csv: bool = False, - include_jdate: bool = False, - base_path: str = config.DATA_BASE_PATH, - adjust: bool = False, -) -> Dict[str, pd.DataFrame]: - if symbols == "all": - symbols = symbols_data.all_symbols() - elif isinstance(symbols, str): - symbols = [symbols] - - df_list = {} - future_to_symbol = {} - with futures.ThreadPoolExecutor(max_workers=10) as executor: - session = requests_retry_session() - for symbol in symbols: - if ( - symbol.isnumeric() - and symbols_data.get_ticker_index(symbol) is None - ): - ticker_indexes = [symbol] - else: - ticker_index = _handle_ticker_index(symbol) - if ticker_index is None: - raise Exception(f"Cannot find symbol: {symbol}") - ticker_indexes = symbols_data.get_ticker_old_index(symbol) - ticker_indexes.insert(0, ticker_index) - - for index in ticker_indexes: - future = executor.submit( - download_ticker_daily_record, index, session - ) - - future_to_symbol[future] = symbol - - for future in futures.as_completed(future_to_symbol): - symbol = future_to_symbol[future] - try: - df: pd.DataFrame = future.result() - except pd.errors.EmptyDataError as ex: - logger.error( - f"Cannot read daily trade records for symbol: {symbol}", - extra={"Error": ex}, - ) - continue - df = df.iloc[::-1].reset_index(drop=True) - df = df.rename(columns=translations.HISTORY_FIELD_MAPPINGS) - df = df.drop(columns=["", ""]) - _adjust_data_frame(df, include_jdate) - - if symbol in df_list: - df_list[symbol] = ( - pd.concat( - [df_list[symbol], df], ignore_index=True, sort=False - ) - .sort_values("date") - .reset_index(drop=True) - ) - else: - df_list[symbol] = df - - if adjust: - df_list[symbol] = adjust_price(df_list[symbol]) - - if write_to_csv: - Path(base_path).mkdir(parents=True, exist_ok=True) - if adjust: - df_list[symbol].to_csv( - f"{base_path}/{symbol}-ت.csv", index=False - ) - else: - df_list[symbol].to_csv( - f"{base_path}/{symbol}.csv", index=False - ) - - if len(df_list) != len(symbols): - print("Warning, download did not complete, re-run the code") - session.close() - return df_list - - -def adjust_price(df: pd.DataFrame) -> pd.DataFrame: - """ - Adjust historical records of stock - - There is a capital increase/profit sharing, - if today "Final Close Price" is not equal to next day - "Yesterday Final Close Price" by using this ratio, - performance adjustment of stocks is achieved - - Parameters - ---------- - df : pd.DataFrame - DataFrame with historical records. - - Returns - ------- - pd.DataFrame - DataFrame with adjusted historical records. - - Notes - ----- - DataFrame can not be empty or else it makes runtime error - Type of DataFrame must be RangeIndex to make proper range of records - that need to be modified - - diff: list - list of indexs of the day after capital increase/profit sharing - ratio_list: List - List of ratios to adjust historical data of stock - ratio: Float - ratio = df.loc[i].adjClose / df.loc[i+1].yesterday - - Description - ----------- - # Note: adjustment does not include Tenth and twentieth days - df.index = range(0,101,1) - # step is 1 - step = df.index.step - diff = [10,20] - ratio_list = [0.5, 0.8] - df.loc[0:10-step, [open,...]] * ratio[0] - df.loc[10:20-step, [open,...]] * ratio[1] - """ - if df.empty or not isinstance(df.index, pd.core.indexes.range.RangeIndex): - return df - - new_df = df.copy() - step = new_df.index.step - diff = list(new_df.index[new_df.shift(1).adjClose != new_df.yesterday]) - if len(diff) > 0: - diff.pop(0) - ratio = 1 - ratio_list = [] - for i in diff[::-1]: - ratio *= ( - new_df.loc[i, "yesterday"] / new_df.shift(1).loc[i, "adjClose"] - ) - ratio_list.insert(0, ratio) - for i, k in enumerate(diff): - if i == 0: - start = new_df.index.start - else: - start = diff[i - 1] - end = diff[i] - step - new_df.loc[ - start:end, - [ - "open", - "high", - "low", - "close", - "adjClose", - "yesterday", - ], - ] = round( - new_df.loc[ - start:end, - [ - "open", - "high", - "low", - "close", - "adjClose", - "yesterday", - ], - ] - * ratio_list[i] - ) - - return new_df - - -@retry( - retry=retry_if_exception_type(HTTPError), - wait=wait_random(min=1, max=4), - before_sleep=before_sleep_log(logger, logging.DEBUG), -) -def download_ticker_daily_record(ticker_index: str, session: Session): - url = tse_settings.TSE_TICKER_EXPORT_DATA_ADDRESS.format(ticker_index) - response = session.get(url, timeout=10) - if 400 <= response.status_code < 500: - logger.error( - f"Cannot read daily trade records from the url: {url}", - extra={"response": response.text, "code": response.status_code}, - ) - - response.raise_for_status() - - data = StringIO(response.text) - return pd.read_csv(data) - - -@retry( - retry=retry_if_exception_type(HTTPError), - wait=wait_random(min=1, max=4), - before_sleep=before_sleep_log(logger, logging.DEBUG), -) -def download_fIndex_record(fIndex: str, session: Session): - url = tse_settings.TSE_FINANCIAL_INDEX_EXPORT_DATA_ADDRESS.format(fIndex) - response = session.get(url, timeout=10) - if 400 <= response.status_code < 500: - logger.error( - f"Cannot read daily trade records from the url: {url}", - extra={"response": response.text, "code": response.status_code}, - ) - - response.raise_for_status() - data = response.text - if not data or ";" not in data or "," not in data: - raise ValueError( - f"""Invalid response from the url: {url}. - \nExpected valid financial index data.""" - ) - df = _create_financial_index_from_text_response(data) - return df - - -def download_financial_indexes( - symbols: Union[List, str], - write_to_csv: bool = False, - include_jdate: bool = False, - base_path: str = config.FINANCIAL_INDEX_BASE_PATH, -) -> Dict[str, pd.DataFrame]: - if symbols == "all": - symbols = symbols_data.all_financial_index() - elif isinstance(symbols, str): - symbols = [symbols] - - df_list = {} - future_to_symbol = {} - with futures.ThreadPoolExecutor(max_workers=10) as executor: - session = requests_retry_session() - for symbol in symbols: - symbol = persian.replace_persian(symbol) - if ( - symbol.isnumeric() - and symbols_data.get_financial_index(symbol) is None - ): - financial_index = symbol - else: - financial_index = symbols_data.get_financial_index(symbol) - if financial_index is None: - raise Exception(f"Cannot find financial index: {symbol}") - - future = executor.submit( - download_fIndex_record, financial_index, session - ) - - future_to_symbol[future] = symbol - - for future in futures.as_completed(future_to_symbol): - symbol = future_to_symbol[future] - try: - df: pd.DataFrame = future.result() - except pd.errors.EmptyDataError as ex: - logger.error( - f"Cannot read daily trade records for symbol: {symbol}", - extra={"Error": ex}, - ) - continue - _adjust_data_frame_for_fIndex(df, include_jdate) - df_list[symbol] = df - - if write_to_csv: - Path(base_path).mkdir(parents=True, exist_ok=True) - df_list[symbol].to_csv( - f"{base_path}/{symbol}.csv", index=False - ) - - if len(df_list) != len(symbols): - print("Warning, download did not complete, re-run the code") - session.close() - return df_list - - -def download_client_types_records( - symbols: Union[List, str], - write_to_csv: bool = False, - include_jdate: bool = False, - base_path: str = config.CLIENT_TYPES_DATA_BASE_PATH, -): - if symbols == "all": - symbols = symbols_data.all_symbols() - elif isinstance(symbols, str): - symbols = [symbols] - - df_list = {} - future_to_symbol = {} - with futures.ThreadPoolExecutor(max_workers=10) as executor: - for symbol in symbols: - ticker_index = _handle_ticker_index(symbol) - if ticker_index is None: - raise Exception(f"Cannot find symbol: {symbol}") - future = executor.submit( - download_ticker_client_types_record, ticker_index - ) - future_to_symbol[future] = symbol - for future in futures.as_completed(future_to_symbol): - symbol = future_to_symbol[future] - df: pd.DataFrame = future.result() - # ignore failures - if df is None: - continue - _adjust_data_frame(df, include_jdate) - df_list[symbol] = df - if write_to_csv: - Path(base_path).mkdir(parents=True, exist_ok=True) - df.to_csv(f"{base_path}/{symbol}.csv") - - if len(df_list) != len(symbols): - print( - """could not download client types for all the symbols make - sure you have what you need or re-run the function""" - ) - return df_list - - -@retry( - retry=retry_if_exception_type(HTTPError), - wait=wait_random(min=1, max=4), - before_sleep=before_sleep_log(logger, logging.DEBUG), -) -def download_ticker_client_types_record(ticker_index: Optional[str]): - data = _extract_ticker_client_types_data(ticker_index) - if len(data) == 1: - logger.warning( - f"""Cannot create client types data for ticker{ticker_index} - from data: {data}""", - extra={"ticker_index": ticker_index}, - ) - return None - client_types_data_frame = pd.DataFrame( - data, - columns=[ - "date", - "individual_buy_count", - "corporate_buy_count", - "individual_sell_count", - "corporate_sell_count", - "individual_buy_vol", - "corporate_buy_vol", - "individual_sell_vol", - "corporate_sell_vol", - "individual_buy_value", - "corporate_buy_value", - "individual_sell_value", - "corporate_sell_value", - ], - ) - for i in [ - "individual_buy_", - "individual_sell_", - "corporate_buy_", - "corporate_sell_", - ]: - client_types_data_frame[f"{i}mean_price"] = client_types_data_frame[ - f"{i}value" - ].astype(float) / client_types_data_frame[f"{i}vol"].astype(float) - client_types_data_frame[ - "individual_ownership_change" - ] = client_types_data_frame["corporate_sell_vol"].astype( - float - ) - client_types_data_frame[ - "corporate_buy_vol" - ].astype( - float - ) - return client_types_data_frame - - -def get_symbol_id(symbol_name: str): - url = tse_settings.TSE_SYMBOL_ID_URL.format(symbol_name.strip()) - response = requests_retry_session().get(url, timeout=10) - try: - response.raise_for_status() - except HTTPError: - raise Exception("Sorry, tse server did not respond") - - symbol_full_info = response.text.split(";")[0].split(",") - if persian.replace_arabic(symbol_name) == symbol_full_info[0].strip(): - return symbol_full_info[2] # symbol id - return None - - -def get_symbol_info(symbol_name: str): - url = tse_settings.TSE_SYMBOL_ID_URL.format(symbol_name.strip()) - response = requests_retry_session().get(url, timeout=10) - try: - response.raise_for_status() - except HTTPError: - raise Exception(f"{symbol_name}: Sorry, tse server did not respond") - - symbols = response.text.split(";") - market_symbol = MarketSymbol( - code=None, - symbol=None, - index=None, - name=None, - old=[], - ) - for symbol_full_info in symbols: - if symbol_full_info.strip() == "": - continue - symbol_full_info = symbol_full_info.split(",") - if persian.replace_arabic(symbol_full_info[0]) == symbol_name: - # if symbol id is active - if symbol_full_info[7] == "1": - market_symbol.symbol = persian.replace_arabic( - symbol_full_info[0] - ) - market_symbol.name = persian.replace_arabic( - symbol_full_info[1] - ) - market_symbol.index = symbol_full_info[2] # active symbol id - else: - market_symbol.old.append(symbol_full_info[2]) # old symbol id - - if market_symbol.index is None: - return None - return market_symbol - From f4f18efe77f546a7cd54fbfc87187e74fb0e8629 Mon Sep 17 00:00:00 2001 From: Glyphack Date: Sun, 29 Oct 2023 19:51:37 +0100 Subject: [PATCH 5/6] Add type parameter to semantic analyzer --- parser/src/parser/ast.rs | 20 +++++++++++++ typechecker/src/semantic_analyzer.rs | 31 +++++++++++++++++++- typechecker/src/symbol_table.rs | 22 ++++++++++---- typechecker/src/type_check/type_evaluator.rs | 1 + 4 files changed, 67 insertions(+), 7 deletions(-) diff --git a/parser/src/parser/ast.rs b/parser/src/parser/ast.rs index c91fb36c..6345e35b 100644 --- a/parser/src/parser/ast.rs +++ b/parser/src/parser/ast.rs @@ -861,6 +861,26 @@ pub enum TypeParam { TypeVarTuple(TypeVarTuple), } +impl GetNode for TypeParam { + fn get_node(&self) -> Node { + match self { + TypeParam::TypeVar(t) => t.node, + TypeParam::ParamSpec(p) => p.node, + TypeParam::TypeVarTuple(t) => t.node, + } + } +} + +impl TypeParam { + pub fn get_name(&self) -> String { + match self { + TypeParam::TypeVar(t) => t.name.clone(), + TypeParam::ParamSpec(p) => p.name.clone(), + TypeParam::TypeVarTuple(t) => t.name.clone(), + } + } +} + // https://docs.python.org/3/library/ast.html#ast.TypeVar #[derive(Debug, Clone)] diff --git a/typechecker/src/semantic_analyzer.rs b/typechecker/src/semantic_analyzer.rs index 9c92ef53..57aa1ca1 100644 --- a/typechecker/src/semantic_analyzer.rs +++ b/typechecker/src/semantic_analyzer.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use enderpy_python_parser as parser; use enderpy_python_parser::ast::Expression; -use parser::ast::Statement; +use parser::ast::{Statement, GetNode}; use crate::{ ast_visitor::TraversalVisitor, @@ -437,6 +437,20 @@ impl TraversalVisitor for SemanticAnalyzer { _ => (), } } + + for type_parameter in &f.type_params { + let declaration_path = DeclarationPath { + module_name: self.file.module_name().clone(), + node: type_parameter.get_node(), + }; + self.create_symbol( + type_parameter.get_name(), + Declaration::TypeParameter(Box::new(crate::symbol_table::TypeParameter { + declaration_path, + type_parameter_node: type_parameter.clone(), + })), + ); + } self.globals.exit_scope(); let function_declaration = Declaration::Function(Box::new(Function { @@ -462,6 +476,20 @@ impl TraversalVisitor for SemanticAnalyzer { SymbolTableType::Class, c.name.clone(), )); + + for type_parameter in &c.type_params { + let declaration_path = DeclarationPath { + module_name: self.file.module_name().clone(), + node: type_parameter.get_node(), + }; + self.create_symbol( + type_parameter.get_name(), + Declaration::TypeParameter(Box::new(crate::symbol_table::TypeParameter { + declaration_path, + type_parameter_node: type_parameter.clone(), + })), + ); + } let mut methods = vec![]; for stmt in &c.body { match stmt { @@ -472,6 +500,7 @@ impl TraversalVisitor for SemanticAnalyzer { } self.visit_stmt(stmt); } + self.globals.exit_scope(); let class_declaration = Declaration::Class(Box::new(Class { diff --git a/typechecker/src/symbol_table.rs b/typechecker/src/symbol_table.rs index 559cb758..8981157b 100644 --- a/typechecker/src/symbol_table.rs +++ b/typechecker/src/symbol_table.rs @@ -62,7 +62,9 @@ pub enum Declaration { Alias(Box), Parameter(Box), - // TypeParameterDeclaration represents a type parameter in a generic class or function. It models type parameters declared on classes and functions like T in List[T]. + // TypeParameterDeclaration represents a type parameter in a generic class or function. + // It models type parameters declared on classes and functions like T in List[T]. + TypeParameter(Box), } impl Declaration { @@ -73,6 +75,7 @@ impl Declaration { Declaration::Class(c) => &c.declaration_path, Declaration::Parameter(p) => &p.declaration_path, Declaration::Alias(a) => &a.declaration_path, + Declaration::TypeParameter(t) => &t.declaration_path, } } } @@ -120,6 +123,12 @@ pub struct Paramter { pub default_value: Option, } +#[derive(Debug, Clone)] +pub struct TypeParameter { + pub declaration_path: DeclarationPath, + pub type_parameter_node: ast::TypeParam, +} + #[derive(Debug, Clone)] pub struct Alias { pub declaration_path: DeclarationPath, @@ -284,11 +293,12 @@ impl std::fmt::Display for SymbolTableScope { impl std::fmt::Display for Declaration { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Declaration::Variable(v) => write!(f, "{:#?}", v), - Declaration::Function(fun) => write!(f, "{:#?}", fun), - Declaration::Class(c) => write!(f, "{:#?}", c), - Declaration::Parameter(p) => write!(f, "{:#?}", p), - Declaration::Alias(a) => write!(f, "{:#?}", a), + Declaration::Variable(v) => write!(f, "{:?}", v), + Declaration::Function(fun) => write!(f, "{:?}", fun), + Declaration::Class(c) => write!(f, "{:?}", c), + Declaration::Parameter(p) => write!(f, "{:?}", p), + Declaration::Alias(a) => write!(f, "{:?}", a), + Declaration::TypeParameter(t) => write!(f, "{:?}", t), } } } diff --git a/typechecker/src/type_check/type_evaluator.rs b/typechecker/src/type_check/type_evaluator.rs index a8adeb0e..680b5b93 100755 --- a/typechecker/src/type_check/type_evaluator.rs +++ b/typechecker/src/type_check/type_evaluator.rs @@ -225,6 +225,7 @@ impl TypeEvaluator { Declaration::Class(_) => Ok(PythonType::Unknown), Declaration::Parameter(_) => Ok(PythonType::Unknown), Declaration::Alias(_) => Ok(PythonType::Unknown), + Declaration::TypeParameter(_) => Ok(PythonType::Unknown), } } From 190b316cf5f9ad07bd99b70b69c17358d37e39d7 Mon Sep 17 00:00:00 2001 From: Glyphack Date: Sun, 29 Oct 2023 19:53:33 +0100 Subject: [PATCH 6/6] prettry print symbol table nodes --- typechecker/src/symbol_table.rs | 12 ++++++------ ...ild__tests__symbol_table@class_definition.py.snap | 5 +---- ...__tests__symbol_table@function_definition.py.snap | 5 +---- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/typechecker/src/symbol_table.rs b/typechecker/src/symbol_table.rs index 8981157b..07c930ba 100644 --- a/typechecker/src/symbol_table.rs +++ b/typechecker/src/symbol_table.rs @@ -293,12 +293,12 @@ impl std::fmt::Display for SymbolTableScope { impl std::fmt::Display for Declaration { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Declaration::Variable(v) => write!(f, "{:?}", v), - Declaration::Function(fun) => write!(f, "{:?}", fun), - Declaration::Class(c) => write!(f, "{:?}", c), - Declaration::Parameter(p) => write!(f, "{:?}", p), - Declaration::Alias(a) => write!(f, "{:?}", a), - Declaration::TypeParameter(t) => write!(f, "{:?}", t), + Declaration::Variable(v) => write!(f, "{:#?}", v), + Declaration::Function(fun) => write!(f, "{:#?}", fun), + Declaration::Class(c) => write!(f, "{:#?}", c), + Declaration::Parameter(p) => write!(f, "{:#?}", p), + Declaration::Alias(a) => write!(f, "{:#?}", a), + Declaration::TypeParameter(t) => write!(f, "{:#?}", t), } } } diff --git a/typechecker/testdata/output/enderpy_python_type_checker__build__tests__symbol_table@class_definition.py.snap b/typechecker/testdata/output/enderpy_python_type_checker__build__tests__symbol_table@class_definition.py.snap index f7fa44f7..cf0957f3 100644 --- a/typechecker/testdata/output/enderpy_python_type_checker__build__tests__symbol_table@class_definition.py.snap +++ b/typechecker/testdata/output/enderpy_python_type_checker__build__tests__symbol_table@class_definition.py.snap @@ -74,7 +74,6 @@ self Symbols: __init__ - Declarations: -<<<<<<< HEAD --: Function { declaration_path: DeclarationPath { module_name: [REDACTED]", @@ -144,6 +143,7 @@ __init__ decorator_list: [], returns: None, type_comment: None, + type_params: [], }, is_method: true, is_generator: false, @@ -151,9 +151,6 @@ __init__ yeild_statements: [], raise_statements: [], } -======= ---: Function { declaration_path: DeclarationPath { module_name: ".Users.glyphack.Programming.enderpy.typechecker.test_data.inputs.symbol_table.class_definition.py", node: Node { start: 13, end: 47 } }, function_node: FunctionDef { node: Node { start: 13, end: 47 }, name: "__init__", args: Arguments { node: Node { start: 26, end: 30 }, posonlyargs: [], args: [Arg { node: Node { start: 26, end: 30 }, arg: "self", annotation: None }], vararg: None, kwonlyargs: [], kw_defaults: [], kwarg: None, defaults: [] }, body: [AssignStatement(Assign { node: Node { start: 41, end: 46 }, targets: [Name(Name { node: Node { start: 41, end: 42 }, id: "a" })], value: Constant(Constant { node: Node { start: 45, end: 46 }, value: 1 }) })], decorator_list: [], returns: None, type_comment: None, type_params: [] }, is_method: true, is_generator: false, return_statements: [], yeild_statements: [], raise_statements: [] } ->>>>>>> d6d917b (Check for type alias in ast visitors) ------------------- diff --git a/typechecker/testdata/output/enderpy_python_type_checker__build__tests__symbol_table@function_definition.py.snap b/typechecker/testdata/output/enderpy_python_type_checker__build__tests__symbol_table@function_definition.py.snap index 9ef53fb1..cb512b2c 100644 --- a/typechecker/testdata/output/enderpy_python_type_checker__build__tests__symbol_table@function_definition.py.snap +++ b/typechecker/testdata/output/enderpy_python_type_checker__build__tests__symbol_table@function_definition.py.snap @@ -9,7 +9,6 @@ global scope: Symbols: func - Declarations: -<<<<<<< HEAD --: Function { declaration_path: DeclarationPath { module_name: [REDACTED]", @@ -95,6 +94,7 @@ func decorator_list: [], returns: None, type_comment: None, + type_params: [], }, is_method: false, is_generator: false, @@ -102,9 +102,6 @@ func yeild_statements: [], raise_statements: [], } -======= ---: Function { declaration_path: DeclarationPath { module_name: ".Users.glyphack.Programming.enderpy.typechecker.test_data.inputs.symbol_table.function_definition.py", node: Node { start: 0, end: 37 } }, function_node: FunctionDef { node: Node { start: 0, end: 37 }, name: "func", args: Arguments { node: Node { start: 9, end: 29 }, posonlyargs: [Arg { node: Node { start: 9, end: 10 }, arg: "a", annotation: None }, Arg { node: Node { start: 12, end: 13 }, arg: "b", annotation: None }], args: [Arg { node: Node { start: 19, end: 24 }, arg: "c", annotation: None }], vararg: None, kwonlyargs: [], kw_defaults: [], kwarg: Some(Arg { node: Node { start: 28, end: 29 }, arg: "e", annotation: None }), defaults: [Constant(Constant { node: Node { start: 23, end: 24 }, value: 2 })] }, body: [Pass(Pass { node: Node { start: 32, end: 36 } })], decorator_list: [], returns: None, type_comment: None, type_params: [] }, is_method: false, is_generator: false, return_statements: [], yeild_statements: [], raise_statements: [] } ->>>>>>> d6d917b (Check for type alias in ast visitors) all scopes: Symbols: