opencode-pine2pyne 0.2.3__tar.gz → 0.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/PKG-INFO +4 -4
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/README.md +3 -3
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/opencode_pine2pyne.egg-info/PKG-INFO +4 -4
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/opencode_pine2pyne.egg-info/SOURCES.txt +2 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/__init__.py +1 -1
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/scope_renamer.py +49 -3
- opencode_pine2pyne-0.2.4/tests/test_input_and_parameter_named_like_a_function_card119.py +159 -0
- opencode_pine2pyne-0.2.4/tests/test_input_and_parameter_named_like_a_function_structure_card119.py +136 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/LICENSE +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/opencode_pine2pyne.egg-info/dependency_links.txt +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/opencode_pine2pyne.egg-info/entry_points.txt +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/opencode_pine2pyne.egg-info/requires.txt +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/opencode_pine2pyne.egg-info/top_level.txt +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/README.md +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/TRANSPILER_BEST_PRACTICES.md +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/TRANSPILER_USAGE.md +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/__main__.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/ast_nodes.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/ast_walk.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/block_value_lowering.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/bool_builtins.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/bool_value_typing.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/cli.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/codegen.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/conditional_history_calls.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/emitted_names.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/errors.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/for_loop_end_bound.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/grouped_history_lowering.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/import_resolver.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/legacy_function_names.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/lexer.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/library_collision.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/namespace_members.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/once_lowering.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/overload_resolution.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/parse_repair.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/parser.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/pine_builtins.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/pine_semantics.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/strategy_when_lowering.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/strict_boolean.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/symbol_table.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/tokens.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/transformer.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/type_inference.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/udt_field_defaults.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pyproject.toml +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/setup.cfg +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_assignment_to_a_call_result_field.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_block_tail_value_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_block_value_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_builtin_named_function_and_enum_input.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_cli.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_codegen.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_codegen_operator_grouping.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_codegen_refusal.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_collect_bool_annotations.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_collect_namespace_members.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_compare_ground_truth_completeness.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_conditional_history_call_warning.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_corpus_regression.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_dotted_udt_default_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_drawing_receiver_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_emitted_name_collision_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_emitted_name_plan.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_error_demo_claims.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_error_demo_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_errors.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_for_in_pairs_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_for_loop_dynamic_end_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_function_tail_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_generated_tables.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_ground_truth_check_no_output.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_ground_truth_check_own_directory.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_ground_truth_digests.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_ground_truth_manifest_order.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_ground_truth_no_output.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_ground_truth_nondeterministic_marks.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_ground_truth_pynecore_commit.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_ground_truth_run_dir_isolation.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_ground_truth_settings.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_ground_truth_wrapper_retired.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_grouped_history_lowering.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_grouped_history_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_import_resolver.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_input_constant_and_enum_order_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_input_history_read_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_input_numeric_positional_binding.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_legacy_unprefixed_functions_card116.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_lexer.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_library_boundary_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_library_name_collision.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_library_name_collision_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_local_named_like_a_function_card118.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_loop_and_array_edge_cases.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_loop_counter_history_refusal.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_method_namespaces.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_method_receiver_shape_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_method_routing_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_once_structure_parser.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_once_structure_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_overload_dispatch_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_overload_resolution.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_parse_repair_card55.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_parser.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_parser_positions.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_pine_builtins.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_pine_semantics.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_release_artifact_grouping.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_runtime_floor.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_scope_model_drift.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_scope_renamer.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_script_declaration_binding.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_shadowing_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_strategy_when_argument_card117.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_strict_and_or_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_suite_harness_exit_verdict.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_suite_report_compare.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_switch_subject_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_symbol_table.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_ta_conditional_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_transformer.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_transformer_receiver_typing.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_transformer_single_use.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_tuple_target_refusal.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_type_as_identifier_card115.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_udt_array_new_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_udt_bool_field_default_by_version_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_udt_field_defaults_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_udt_field_history_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_udt_type_proof.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_untyped_na_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_user_declaration_shadows_builtin_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_v5_bool_cast_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_var_history_runtime.py +0 -0
- {opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_variable_function_runtime.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: opencode-pine2pyne
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Pine Script v6 to PyneCore Python transpiler
|
|
5
5
|
Author: rubycell
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -35,9 +35,9 @@ Backlog and known bugs: [Projects board #10](https://github.com/users/rubycell/p
|
|
|
35
35
|
of the PyneCore runtime (repo `/home/mike/workspace/github/pynecore`).
|
|
36
36
|
- Where it runs: a command-line tool and a Python library. It has no service, no port and no host of its own.
|
|
37
37
|
Development happens on mike-PC. Full test suites run on Minh_pc (see section 7).
|
|
38
|
-
- Package: `opencode-pine2pyne` on PyPI, version `0.2.
|
|
39
|
-
Live PyPI state is UNVERIFIED: 0.2.
|
|
40
|
-
`CHANGELOG.md` lists #
|
|
38
|
+
- Package: `opencode-pine2pyne` on PyPI, version `0.2.4` in `pine2pyne/__init__.py` and `CHANGELOG.md`.
|
|
39
|
+
Live PyPI state is UNVERIFIED: 0.2.4 is prepared (commit and local tag `v0.2.4`), not uploaded. 0.2.3 is on PyPI.
|
|
40
|
+
`CHANGELOG.md` lists #119 and its export case under 0.2.4; the tag `v0.2.3` is the release before them.
|
|
41
41
|
- The transpiler imports only the standard library (`pyproject.toml`: `dependencies = []`).
|
|
42
42
|
The generated script needs the runtime `opencode-pyneruntime` (`runtime` extra, `>=6.9.1`).
|
|
43
43
|
- License: Apache-2.0 (`pyproject.toml`, `LICENSE`).
|
|
@@ -15,9 +15,9 @@ Backlog and known bugs: [Projects board #10](https://github.com/users/rubycell/p
|
|
|
15
15
|
of the PyneCore runtime (repo `/home/mike/workspace/github/pynecore`).
|
|
16
16
|
- Where it runs: a command-line tool and a Python library. It has no service, no port and no host of its own.
|
|
17
17
|
Development happens on mike-PC. Full test suites run on Minh_pc (see section 7).
|
|
18
|
-
- Package: `opencode-pine2pyne` on PyPI, version `0.2.
|
|
19
|
-
Live PyPI state is UNVERIFIED: 0.2.
|
|
20
|
-
`CHANGELOG.md` lists #
|
|
18
|
+
- Package: `opencode-pine2pyne` on PyPI, version `0.2.4` in `pine2pyne/__init__.py` and `CHANGELOG.md`.
|
|
19
|
+
Live PyPI state is UNVERIFIED: 0.2.4 is prepared (commit and local tag `v0.2.4`), not uploaded. 0.2.3 is on PyPI.
|
|
20
|
+
`CHANGELOG.md` lists #119 and its export case under 0.2.4; the tag `v0.2.3` is the release before them.
|
|
21
21
|
- The transpiler imports only the standard library (`pyproject.toml`: `dependencies = []`).
|
|
22
22
|
The generated script needs the runtime `opencode-pyneruntime` (`runtime` extra, `>=6.9.1`).
|
|
23
23
|
- License: Apache-2.0 (`pyproject.toml`, `LICENSE`).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: opencode-pine2pyne
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Pine Script v6 to PyneCore Python transpiler
|
|
5
5
|
Author: rubycell
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -35,9 +35,9 @@ Backlog and known bugs: [Projects board #10](https://github.com/users/rubycell/p
|
|
|
35
35
|
of the PyneCore runtime (repo `/home/mike/workspace/github/pynecore`).
|
|
36
36
|
- Where it runs: a command-line tool and a Python library. It has no service, no port and no host of its own.
|
|
37
37
|
Development happens on mike-PC. Full test suites run on Minh_pc (see section 7).
|
|
38
|
-
- Package: `opencode-pine2pyne` on PyPI, version `0.2.
|
|
39
|
-
Live PyPI state is UNVERIFIED: 0.2.
|
|
40
|
-
`CHANGELOG.md` lists #
|
|
38
|
+
- Package: `opencode-pine2pyne` on PyPI, version `0.2.4` in `pine2pyne/__init__.py` and `CHANGELOG.md`.
|
|
39
|
+
Live PyPI state is UNVERIFIED: 0.2.4 is prepared (commit and local tag `v0.2.4`), not uploaded. 0.2.3 is on PyPI.
|
|
40
|
+
`CHANGELOG.md` lists #119 and its export case under 0.2.4; the tag `v0.2.3` is the release before them.
|
|
41
41
|
- The transpiler imports only the standard library (`pyproject.toml`: `dependencies = []`).
|
|
42
42
|
The generated script needs the runtime `opencode-pyneruntime` (`runtime` extra, `>=6.9.1`).
|
|
43
43
|
- License: Apache-2.0 (`pyproject.toml`, `LICENSE`).
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/opencode_pine2pyne.egg-info/SOURCES.txt
RENAMED
|
@@ -80,6 +80,8 @@ tests/test_ground_truth_wrapper_retired.py
|
|
|
80
80
|
tests/test_grouped_history_lowering.py
|
|
81
81
|
tests/test_grouped_history_runtime.py
|
|
82
82
|
tests/test_import_resolver.py
|
|
83
|
+
tests/test_input_and_parameter_named_like_a_function_card119.py
|
|
84
|
+
tests/test_input_and_parameter_named_like_a_function_structure_card119.py
|
|
83
85
|
tests/test_input_constant_and_enum_order_runtime.py
|
|
84
86
|
tests/test_input_history_read_runtime.py
|
|
85
87
|
tests/test_input_numeric_positional_binding.py
|
|
@@ -22,6 +22,9 @@ not the binding's own member (see library_collision.MemberRule). Two kinds of
|
|
|
22
22
|
binding keep their name: an input (its name is the key of the script's input
|
|
23
23
|
settings) and an `export` declaration (its name is the library's API); a
|
|
24
24
|
namespace use under such a binding reads an alias of the namespace instead.
|
|
25
|
+
An `export` with a parameter named like a function or method of the script is split into a private `f_body<N>`
|
|
26
|
+
(the same body, its parameters renamed like any function's) and the public export, which keeps the parameter names
|
|
27
|
+
and calls it (card #119).
|
|
25
28
|
|
|
26
29
|
A local named like a builtin series variable (`close`, `time`, `hour`) gets its own name
|
|
27
30
|
wherever it is declared below the top level: in a function, as a loop variable (card #84) or
|
|
@@ -103,11 +106,39 @@ class Binding:
|
|
|
103
106
|
def rename_shadowing_locals(script: Script) -> RenamedScript:
|
|
104
107
|
"""Return a copy of `script` with shadowing locals and library-named
|
|
105
108
|
bindings renamed. The input script is not modified."""
|
|
109
|
+
script = split_exports_with_shadowed_callees(script)
|
|
106
110
|
renamer = _ScopeRenamer(script)
|
|
107
111
|
return RenamedScript(renamer.run(script), renamer.namespace_aliases,
|
|
108
112
|
{name: renames for name, renames in renamer.parameter_names.items() if renames})
|
|
109
113
|
|
|
110
114
|
|
|
115
|
+
def split_exports_with_shadowed_callees(script: Script) -> Script:
|
|
116
|
+
"""An `export` function keeps its parameter names (its public signature), so a parameter named like a
|
|
117
|
+
function or method of the script hides that function from the exported body. Such an export becomes a
|
|
118
|
+
private function with the same body, whose parameters the renamer then renames like any function's, and an
|
|
119
|
+
export of the same signature that calls it (card #119 follow-up)."""
|
|
120
|
+
function_names = {declaration.name for declaration in script.declarations if isinstance(declaration, FuncDecl)}
|
|
121
|
+
used_names = collect_names(script)
|
|
122
|
+
declarations = []
|
|
123
|
+
split_any = False
|
|
124
|
+
for declaration in script.declarations:
|
|
125
|
+
if not (isinstance(declaration, FuncDecl) and declaration.is_export
|
|
126
|
+
and any(parameter.name in function_names for parameter in declaration.params)):
|
|
127
|
+
declarations.append(declaration)
|
|
128
|
+
continue
|
|
129
|
+
split_any = True
|
|
130
|
+
private_name = fresh_name(f'{declaration.name}_body', used_names)
|
|
131
|
+
declarations.append(dataclasses.replace(
|
|
132
|
+
declaration, name=private_name, is_export=False, is_overload=False,
|
|
133
|
+
params=[dataclasses.replace(parameter, default=None) for parameter in declaration.params]))
|
|
134
|
+
declarations.append(dataclasses.replace(
|
|
135
|
+
declaration, indexed_params=set(),
|
|
136
|
+
body=FunctionCall(func=private_name, args=[Identifier(name=parameter.name)
|
|
137
|
+
for parameter in declaration.params],
|
|
138
|
+
line=declaration.line, column=declaration.column)))
|
|
139
|
+
return dataclasses.replace(script, declarations=declarations) if split_any else script
|
|
140
|
+
|
|
141
|
+
|
|
111
142
|
def collect_names(tree) -> Set[str]:
|
|
112
143
|
"""Every identifier-like string in the tree: the names a fresh name must avoid."""
|
|
113
144
|
names: Set[str] = set()
|
|
@@ -205,8 +236,11 @@ class _ScopeRenamer:
|
|
|
205
236
|
# sanitized spellings of keyword-named inputs and exports: the settings id and the
|
|
206
237
|
# library API keep them, so another binding of that spelling moves
|
|
207
238
|
self.external_spellings: Set[str] = set()
|
|
208
|
-
# keyword-named input whose spelling another input holds
|
|
239
|
+
# keyword-named input whose spelling another input holds, or input named like a function or method of
|
|
240
|
+
# the script -> its new name
|
|
209
241
|
self.moved_inputs: Dict[str, str] = {}
|
|
242
|
+
# the inputs named like a function or method of the script: they keep their Pine label (card #119)
|
|
243
|
+
self.inputs_named_like_a_function: Set[str] = set()
|
|
210
244
|
self.moved_bindings = False
|
|
211
245
|
# global named like a builtin series -> its first declaration: an input (card #86), a
|
|
212
246
|
# var, an assignment or a tuple target (card #89)
|
|
@@ -479,6 +513,9 @@ class _ScopeRenamer:
|
|
|
479
513
|
renames = self.parameter_names.setdefault(name, {})
|
|
480
514
|
renamed_names = self.library_names if name in exported else self.library_names | global_names
|
|
481
515
|
renamed_names = renamed_names | self.external_spellings
|
|
516
|
+
if name not in exported:
|
|
517
|
+
# a parameter named like a function or method of the script hides it from the body (card #119)
|
|
518
|
+
renamed_names = renamed_names | self.user_function_names | self.method_names
|
|
482
519
|
for parameter in declaration.params:
|
|
483
520
|
if parameter.name in renamed_names and parameter.name not in renames:
|
|
484
521
|
renames[parameter.name] = self.fresh_name(parameter.name)
|
|
@@ -511,6 +548,12 @@ class _ScopeRenamer:
|
|
|
511
548
|
self.moved_inputs[name] = free_spelling(spelling, self.spellings.occupied)
|
|
512
549
|
else:
|
|
513
550
|
self.external_spellings.add(spelling)
|
|
551
|
+
# an input named like a function or method of the script: the input is a parameter of main() and the
|
|
552
|
+
# script's functions are defined inside main(), so the function overwrites the parameter (card #119)
|
|
553
|
+
self.inputs_named_like_a_function = {name for name in input_names
|
|
554
|
+
if name in self.user_function_names or name in self.method_names}
|
|
555
|
+
for name in sorted(self.inputs_named_like_a_function - self.moved_inputs.keys()):
|
|
556
|
+
self.moved_inputs[name] = self.fresh_name(name)
|
|
514
557
|
exported = {node.name for node in script.declarations
|
|
515
558
|
if isinstance(node, FuncDecl) and node.is_export}
|
|
516
559
|
for name in sorted(exported & PYTHON_RESERVED_WORDS):
|
|
@@ -662,8 +705,11 @@ class _ScopeRenamer:
|
|
|
662
705
|
[declaration.args, declaration.kwargs])
|
|
663
706
|
arguments = self.expression(declaration.args), self.expression(declaration.kwargs)
|
|
664
707
|
self.scopes[0].update(saved)
|
|
665
|
-
|
|
666
|
-
|
|
708
|
+
args, kwargs = arguments
|
|
709
|
+
if name in self.inputs_named_like_a_function and len(args) < 2 and 'title' not in kwargs:
|
|
710
|
+
# Pine shows the variable name when the call gives no title: the rename must not change the label
|
|
711
|
+
kwargs = {**kwargs, 'title': Literal(value=name, literal_type='string', is_double_quoted=True)}
|
|
712
|
+
return dataclasses.replace(declaration, name=self.moved_inputs.get(name, name), args=args, kwargs=kwargs)
|
|
667
713
|
|
|
668
714
|
def read_builtin_by_alias(self, names: Set[str], tree) -> Dict[str, Binding]:
|
|
669
715
|
"""Until the caller restores the returned bindings, each input of `names` that `tree`
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"""An input or a function parameter named like a function or method of the script is its own variable (card #119).
|
|
2
|
+
|
|
3
|
+
Card #118 moved a LOCAL that is named like a function of the script. An input (kept through `keep()`) and a function
|
|
4
|
+
PARAMETER (skipped `declare()`) kept their names, and each program below failed at run with a `TypeError` while the
|
|
5
|
+
same program with distinct names passed:
|
|
6
|
+
|
|
7
|
+
- (a) an input named like a method: the nested `def src` inside `main()` overwrote the `main()` parameter
|
|
8
|
+
(`unsupported operand type(s) for +: 'float' and 'function'`);
|
|
9
|
+
- (b) a parameter named like a method, (b2) a parameter named like a function: the call `scale(s, scale)` read the
|
|
10
|
+
parameter (`'float' object is not callable`).
|
|
11
|
+
|
|
12
|
+
Each runtime probe plots `got` next to a closed form that does not use the construct under test. The transpile-only
|
|
13
|
+
tests of what the rename must keep (an input's title and place, the reach of a parameter's new name) are in
|
|
14
|
+
`test_input_and_parameter_named_like_a_function_structure_card119.py`.
|
|
15
|
+
"""
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
import pytest
|
|
19
|
+
|
|
20
|
+
pytestmark = pytest.mark.corpus_runtime
|
|
21
|
+
|
|
22
|
+
pine2pyne = pytest.importorskip("pine2pyne")
|
|
23
|
+
pytest.importorskip("pynecore.core.script_runner", reason="pynecore runtime not installed")
|
|
24
|
+
|
|
25
|
+
from test_shadowing_runtime import assert_got_matches_expected # noqa: E402
|
|
26
|
+
|
|
27
|
+
PROBES = {
|
|
28
|
+
"a_input_named_like_a_method": # the card's program (a)
|
|
29
|
+
'method src(float x) => x * 2\nsrc = input.source(close, "s")\n'
|
|
30
|
+
'plot(close.src() + src, "got")\nplot(close * 2 + close, "expected")\n',
|
|
31
|
+
"b_parameter_named_like_a_method": # the card's program (b)
|
|
32
|
+
'method scale(float s, float k) => s * k\nf(float s, float scale) => s.scale(scale)\n'
|
|
33
|
+
'plot(f(close, 3.0), "got")\nplot(close * 3.0, "expected")\n',
|
|
34
|
+
"b2_parameter_named_like_a_function": # the card's program (b2)
|
|
35
|
+
'twice(x) => x * 2\nf(s, twice) => twice(s) + twice\n'
|
|
36
|
+
'plot(f(close, 3.0), "got")\nplot(close * 2 + 3.0, "expected")\n',
|
|
37
|
+
"input_named_like_a_function":
|
|
38
|
+
'twice(x) => x * 2\ntwice = input.float(3.0, "t")\nplot(twice(close) + twice, "got")\n'
|
|
39
|
+
'plot(close * 2 + 3.0, "expected")\n',
|
|
40
|
+
"input_named_like_a_function_without_a_title":
|
|
41
|
+
'twice(x) => x * 2\ntwice = input.float(3.0)\nplot(twice(close) + twice, "got")\n'
|
|
42
|
+
'plot(close * 2 + 3.0, "expected")\n',
|
|
43
|
+
"input_named_like_a_method_read_by_a_function":
|
|
44
|
+
'method twice(float x) => x * 2\ntwice = input.float(3.0, "t")\n'
|
|
45
|
+
'g(float s) => s.twice() + twice\nplot(g(close), "got")\nplot(close * 2 + 3.0, "expected")\n',
|
|
46
|
+
"int_input_named_like_a_function_read_with_history":
|
|
47
|
+
'twice(x) => x * 2\ntwice = input.int(3, "t")\nplot(twice(close) + nz(twice[1], 3), "got")\n'
|
|
48
|
+
'plot(close * 2 + 3.0, "expected")\n',
|
|
49
|
+
"parameter_named_like_a_function_given_by_keyword":
|
|
50
|
+
'twice(x) => x * 2\nf(s, twice) => twice(s) + twice\nplot(f(close, twice = 3.0), "got")\n'
|
|
51
|
+
'plot(close * 2 + 3.0, "expected")\n',
|
|
52
|
+
"parameter_default_named_like_a_function":
|
|
53
|
+
'twice(x) => x * 2\nf(s, twice = 4.0) => twice(s) + twice\nplot(f(close), "got")\n'
|
|
54
|
+
'plot(close * 2 + 4.0, "expected")\n',
|
|
55
|
+
"method_parameter_named_like_another_method":
|
|
56
|
+
'method scale(float s, float k) => s * k\nmethod shift(float s, float scale) => s.scale(scale) + 1\n'
|
|
57
|
+
'plot(close.shift(3.0), "got")\nplot(close * 3.0 + 1, "expected")\n',
|
|
58
|
+
"parameter_named_like_its_own_function":
|
|
59
|
+
'twice(x) => x * 2\nf(s) => twice(s)\ng(float twice) => twice + 1\n'
|
|
60
|
+
'plot(f(close) + g(5.0), "got")\nplot(close * 2 + 6.0, "expected")\n',
|
|
61
|
+
"the_function_is_still_callable_after_the_parameter_ends":
|
|
62
|
+
'twice(x) => x * 2\nf(s, twice) => s + twice\nplot(f(close, 1.0) + twice(close), "got")\n'
|
|
63
|
+
'plot(close + 1.0 + close * 2, "expected")\n',
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
CONTROLS = { # the same programs with distinct names
|
|
67
|
+
"a_input_with_a_distinct_name":
|
|
68
|
+
'method src(float x) => x * 2\nsrcin = input.source(close, "s")\n'
|
|
69
|
+
'plot(close.src() + srcin, "got")\nplot(close * 2 + close, "expected")\n',
|
|
70
|
+
"b_parameter_with_a_distinct_name":
|
|
71
|
+
'method scale(float s, float k) => s * k\nf(float s, float factor) => s.scale(factor)\n'
|
|
72
|
+
'plot(f(close, 3.0), "got")\nplot(close * 3.0, "expected")\n',
|
|
73
|
+
"b2_parameter_with_a_distinct_name":
|
|
74
|
+
'twice(x) => x * 2\nf(s, extra) => twice(s) + extra\n'
|
|
75
|
+
'plot(f(close, 3.0), "got")\nplot(close * 2 + 3.0, "expected")\n',
|
|
76
|
+
"input_with_a_distinct_name_and_no_title":
|
|
77
|
+
'twice(x) => x * 2\nfactor = input.float(3.0)\nplot(twice(close) + factor, "got")\n'
|
|
78
|
+
'plot(close * 2 + 3.0, "expected")\n',
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
@pytest.mark.parametrize("name", sorted(PROBES))
|
|
83
|
+
def test_input_or_parameter_named_like_a_function_runs(name, tmp_path):
|
|
84
|
+
assert_got_matches_expected(PROBES[name], tmp_path, f"card119_{name}", version=5)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@pytest.mark.parametrize("name", sorted(CONTROLS))
|
|
88
|
+
def test_controls_with_distinct_names_run(name, tmp_path):
|
|
89
|
+
assert_got_matches_expected(CONTROLS[name], tmp_path, f"card119_control_{name}", version=5)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
LIBRARY_HEADER = '//@version=6\nlibrary("scalelib")\n'
|
|
93
|
+
IMPORTER_HEADER = '//@version=6\nindicator("scale_importer")\nimport someone/scalelib/1 as m\n'
|
|
94
|
+
|
|
95
|
+
EXPORT_PAIRS = { # (library body, importer body): `got` next to `expected`
|
|
96
|
+
"parameter_named_like_a_method":
|
|
97
|
+
('method scale(float s, float k) => s * k\nexport f(float s, float scale) =>\n s.scale(scale)\n',
|
|
98
|
+
'plot(m.f(close, 3.0), "got")\nplot(close * 3.0, "expected")\n'),
|
|
99
|
+
"parameter_named_like_a_function":
|
|
100
|
+
('twice(x) => x * 2\nexport f(float s, float twice) =>\n twice(s) + twice\n',
|
|
101
|
+
'plot(m.f(close, 3.0), "got")\nplot(close * 2 + 3.0, "expected")\n'),
|
|
102
|
+
"keyword_call_keeps_the_public_parameter_names":
|
|
103
|
+
('method scale(float s, float k) => s * k\nexport f(float s, float scale) =>\n s.scale(scale)\n',
|
|
104
|
+
'plot(m.f(scale = 3.0, s = close), "got")\nplot(close * 3.0, "expected")\n'),
|
|
105
|
+
"export_beside_a_plain_function_with_the_same_parameter_name":
|
|
106
|
+
('method scale(float s, float k) => s * k\ng(float s, float scale) => s.scale(scale)\n'
|
|
107
|
+
'export f(float s, float scale) =>\n g(s, scale) + s.scale(scale)\n',
|
|
108
|
+
'plot(m.f(close, 3.0), "got")\nplot(close * 6.0, "expected")\n'),
|
|
109
|
+
# the private function and the export differ on these paths (default, history, state, overload, call, method)
|
|
110
|
+
"parameter_with_a_default_value":
|
|
111
|
+
('method scale(float s, float k) => s * k\nexport f(float s, float scale = 2.0) =>\n s.scale(scale)\n',
|
|
112
|
+
'plot(m.f(close), "got")\nplot(close * 2.0, "expected")\n'),
|
|
113
|
+
"history_of_the_parameter":
|
|
114
|
+
('method scale(float s, float k) => s * k\nexport f(float s, float scale) =>\n'
|
|
115
|
+
' s.scale(scale) + nz(scale[1])\n',
|
|
116
|
+
'plot(m.f(close, bar_index + 1.0), "got")\nplot(close * (bar_index + 1.0) + bar_index, "expected")\n'),
|
|
117
|
+
"var_counter_and_sma_in_the_body":
|
|
118
|
+
('method scale(float s, float k) => s * k\nexport f(float s, float scale) =>\n var float n = 0.0\n'
|
|
119
|
+
' n += 1\n s.scale(scale) + n + nz(ta.sma(s, 3))\n',
|
|
120
|
+
'plot(m.f(close, 3.0), "got")\nplot(close * 3.0 + (bar_index + 1) + nz(ta.sma(close, 3)), "expected")\n'),
|
|
121
|
+
"two_overloaded_exports":
|
|
122
|
+
('method scale(float s, float k) => s * k\nexport f(float s, float scale) =>\n s.scale(scale)\n'
|
|
123
|
+
'export f(float s, float scale, float extra) =>\n s.scale(scale) + extra\n',
|
|
124
|
+
'plot(m.f(close, 3.0) + m.f(close, 3.0, 1.0), "got")\nplot(close * 6.0 + 1.0, "expected")\n'),
|
|
125
|
+
"export_called_by_export_and_tuple_export":
|
|
126
|
+
('method scale(float s, float k) => s * k\nexport f(float s, float scale) =>\n s.scale(scale)\n'
|
|
127
|
+
'export g(float s, float scale) =>\n f(s, scale) + 1\n'
|
|
128
|
+
'export pair(float s, float scale) =>\n [s.scale(scale), s]\n',
|
|
129
|
+
'[first, second] = m.pair(close, 3.0)\nplot(m.g(close, 3.0) + first + second, "got")\n'
|
|
130
|
+
'plot(close * 7.0 + 1.0, "expected")\n'),
|
|
131
|
+
"export_method_called_as_a_function":
|
|
132
|
+
('method scale(float s, float k) => s * k\nexport method f(float s, float scale) =>\n s.scale(scale)\n',
|
|
133
|
+
'plot(m.f(close, 3.0), "got")\nplot(close * 3.0, "expected")\n'),
|
|
134
|
+
"export_method_called_as_a_method": # pinned below: the importer's own limit
|
|
135
|
+
('method scale(float s, float k) => s * k\nexport method f(float s, float scale) =>\n s.scale(scale)\n',
|
|
136
|
+
'plot(close.f(3.0), "got")\nplot(close * 3.0, "expected")\n'),
|
|
137
|
+
"export_method_with_a_distinct_parameter_name_called_as_a_method": # the control of the pin: no split at all
|
|
138
|
+
('method scale(float s, float k) => s * k\nexport method f(float s, float factor) =>\n s.scale(factor)\n',
|
|
139
|
+
'plot(close.f(3.0), "got")\nplot(close * 3.0, "expected")\n'),
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
# `close.f(3.0)` on an imported exported method is emitted as a call on pynecore's `close` object, which has no
|
|
143
|
+
# method `f`: the importer cannot call an imported method as a method, whatever the parameter is named
|
|
144
|
+
PINNED_IMPORTER_LIMIT = {
|
|
145
|
+
"export_method_called_as_a_method", "export_method_with_a_distinct_parameter_name_called_as_a_method"}
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
@pytest.mark.parametrize("name", [
|
|
149
|
+
pytest.param(name, marks=pytest.mark.xfail(strict=True, raises=ModuleNotFoundError, reason=(
|
|
150
|
+
"pinned product bug, follow-up of card #119: an imported exported method called as `close.f(3.0)` is emitted "
|
|
151
|
+
"as a call on the built-in series `close`")))
|
|
152
|
+
if name in PINNED_IMPORTER_LIMIT else name for name in sorted(EXPORT_PAIRS)])
|
|
153
|
+
def test_an_exported_function_with_a_parameter_named_like_a_function_or_method_runs(name, tmp_path, monkeypatch):
|
|
154
|
+
"""An export keeps its parameter names (its public signature); the body must not read them as the function."""
|
|
155
|
+
from test_library_boundary_runtime import assert_got_equals_expected, run_pair
|
|
156
|
+
|
|
157
|
+
library_body, importer_body = EXPORT_PAIRS[name]
|
|
158
|
+
assert_got_equals_expected(run_pair(tmp_path, monkeypatch, "scalelib", LIBRARY_HEADER + library_body,
|
|
159
|
+
"scale_importer", IMPORTER_HEADER + importer_body))
|
opencode_pine2pyne-0.2.4/tests/test_input_and_parameter_named_like_a_function_structure_card119.py
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"""What the rename of an input or a parameter named like a function keeps (card #119).
|
|
2
|
+
|
|
3
|
+
An input renamed to a fresh name keeps the label the settings show (its title: Pine shows the variable name when
|
|
4
|
+
the call gives none) and its place in the settings (the order of `main()`'s parameters). A parameter is renamed
|
|
5
|
+
inside its own function only. The run-level probes are in `test_input_and_parameter_named_like_a_function_card119.py`.
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import ast
|
|
10
|
+
|
|
11
|
+
import pytest
|
|
12
|
+
|
|
13
|
+
pine2pyne = pytest.importorskip("pine2pyne")
|
|
14
|
+
|
|
15
|
+
HEADER = '//@version=5\nindicator("t")\n'
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def main_function(code: str) -> ast.FunctionDef:
|
|
19
|
+
return next(node for node in ast.walk(ast.parse(code)) if isinstance(node, ast.FunctionDef) and node.name == 'main')
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def function_named(code: str, name: str) -> ast.FunctionDef:
|
|
23
|
+
return next(node for node in ast.walk(ast.parse(code)) if isinstance(node, ast.FunctionDef) and node.name == name)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def input_settings(code: str) -> list[tuple[str, ast.Call]]:
|
|
27
|
+
"""Each `main()` parameter with the input call that is its default, in order."""
|
|
28
|
+
main = main_function(code)
|
|
29
|
+
return [(argument.arg, default) for argument, default in zip(main.args.args, main.args.defaults)]
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def titles_of(call: ast.Call) -> list[str]:
|
|
33
|
+
"""Every title the input call gives: the second positional argument and a `title=` keyword."""
|
|
34
|
+
positional = [ast.literal_eval(call.args[1])] if len(call.args) > 1 else []
|
|
35
|
+
return positional + [ast.literal_eval(keyword.value) for keyword in call.keywords if keyword.arg == 'title']
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def test_a_renamed_input_without_a_title_gets_its_pine_name_as_the_title():
|
|
39
|
+
code = pine2pyne.transpile(
|
|
40
|
+
HEADER + 'twice(x) => x * 2\ntwice = input.float(3.0)\nplot(twice(close) + twice)\n')
|
|
41
|
+
|
|
42
|
+
(name, call), = input_settings(code)
|
|
43
|
+
assert name != 'twice' and name.startswith('twice'), name
|
|
44
|
+
assert titles_of(call) == ['twice'], ast.unparse(call)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def test_a_renamed_source_input_without_a_title_gets_its_pine_name_as_the_title():
|
|
48
|
+
code = pine2pyne.transpile(
|
|
49
|
+
HEADER + 'method src(float x) => x * 2\nsrc = input.source(close)\nplot(close.src() + src)\n')
|
|
50
|
+
|
|
51
|
+
(name, call), = input_settings(code)
|
|
52
|
+
assert 'src' in name and name != 'src', name
|
|
53
|
+
assert titles_of(call) == ['src'], ast.unparse(call)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def test_a_renamed_input_with_a_positional_title_keeps_that_title_once():
|
|
57
|
+
code = pine2pyne.transpile(
|
|
58
|
+
HEADER + 'twice(x) => x * 2\ntwice = input.float(3.0, "Factor")\nplot(twice(close) + twice)\n')
|
|
59
|
+
|
|
60
|
+
(_, call), = input_settings(code)
|
|
61
|
+
assert titles_of(call) == ['Factor'], ast.unparse(call)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def test_a_renamed_input_with_a_title_keyword_keeps_that_title_once():
|
|
65
|
+
code = pine2pyne.transpile(
|
|
66
|
+
HEADER + 'twice(x) => x * 2\ntwice = input.float(3.0, title = "Factor")\nplot(twice(close) + twice)\n')
|
|
67
|
+
|
|
68
|
+
(_, call), = input_settings(code)
|
|
69
|
+
assert titles_of(call) == ['Factor'], ast.unparse(call)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def test_a_renamed_input_keeps_its_place_in_the_settings():
|
|
73
|
+
code = pine2pyne.transpile(
|
|
74
|
+
HEADER + 'twice(x) => x * 2\nfirst = input.int(1, "1")\ntwice = input.float(3.0)\nlast = input.int(2, "2")\n'
|
|
75
|
+
'plot(twice(close) + twice + first + last)\n')
|
|
76
|
+
|
|
77
|
+
settings = input_settings(code)
|
|
78
|
+
assert [name for name, _ in settings][0::2] == ['first', 'last'], settings
|
|
79
|
+
middle_name, middle_call = settings[1]
|
|
80
|
+
assert middle_name != 'twice' and middle_name.startswith('twice'), middle_name
|
|
81
|
+
assert ast.unparse(middle_call).startswith('input.float(3.0'), ast.unparse(middle_call)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def test_an_input_that_names_no_function_is_unchanged():
|
|
85
|
+
code = pine2pyne.transpile(
|
|
86
|
+
HEADER + 'twice(x) => x * 2\nfactor = input.float(3.0)\nplot(twice(close) + factor)\n')
|
|
87
|
+
|
|
88
|
+
(name, call), = input_settings(code)
|
|
89
|
+
assert name == 'factor' and titles_of(call) == [], ast.unparse(call)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def test_a_parameter_is_renamed_inside_its_own_function_only():
|
|
93
|
+
code = pine2pyne.transpile(
|
|
94
|
+
HEADER + 'method scale(float s, float k) => s * k\nf(float s, float scale) => s.scale(scale)\n'
|
|
95
|
+
'g(float scale) => scale + 1\nh(float x) => x\nplot(f(close, 3.0) + g(1.0) + h(close))\n')
|
|
96
|
+
|
|
97
|
+
assert [argument.arg for argument in function_named(code, 'f').args.args][1].startswith('scale_')
|
|
98
|
+
assert [argument.arg for argument in function_named(code, 'g').args.args] != ['scale'] # g(scale) is named like the method too
|
|
99
|
+
assert [argument.arg for argument in function_named(code, 'h').args.args] == ['x']
|
|
100
|
+
assert [argument.arg for argument in function_named(code, 'scale').args.args] == ['s', 'k'] # the method itself
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def test_a_keyword_named_input_that_is_also_a_function_name_keeps_its_pine_name_as_the_title():
|
|
104
|
+
"""`lambda` is a Python keyword and the input `lambda_` holds its spelling, so the keyword rename moves it;
|
|
105
|
+
the function-name rename must still add the title."""
|
|
106
|
+
code = pine2pyne.transpile(
|
|
107
|
+
HEADER + 'lambda(x) => x * 2\nlambda = input.float(3.0)\nlambda_ = input.int(1, "other")\n'
|
|
108
|
+
'plot(lambda(close) + lambda + lambda_)\n')
|
|
109
|
+
|
|
110
|
+
(name, call), (other_name, other_call) = input_settings(code)
|
|
111
|
+
assert name != 'lambda' and name.startswith('lambda'), name
|
|
112
|
+
assert titles_of(call) == ['lambda'], ast.unparse(call)
|
|
113
|
+
assert (other_name, titles_of(other_call)) == ('lambda_', ['other']), ast.unparse(other_call)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def test_an_exported_function_keeps_its_parameter_names_and_calls_a_private_function_with_renamed_parameters():
|
|
117
|
+
code = pine2pyne.transpile(
|
|
118
|
+
'//@version=6\nlibrary("scalelib")\nmethod scale(float s, float k) => s * k\n'
|
|
119
|
+
'export f(float s, float scale) =>\n s.scale(scale)\n')
|
|
120
|
+
|
|
121
|
+
exported = function_named(code, 'f')
|
|
122
|
+
assert [argument.arg for argument in exported.args.args] == ['s', 'scale'], ast.unparse(exported)
|
|
123
|
+
private = function_named(code, 'f_body1')
|
|
124
|
+
assert [argument.arg for argument in private.args.args][1].startswith('scale_'), ast.unparse(private)
|
|
125
|
+
assert ast.unparse(exported.body[0]) == 'return f_body1(s, scale)', ast.unparse(exported)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def test_an_export_that_names_no_function_or_method_is_emitted_as_before():
|
|
129
|
+
code = pine2pyne.transpile(
|
|
130
|
+
'//@version=6\nlibrary("scalelib")\nmethod scale(float s, float k) => s * k\n'
|
|
131
|
+
'export f(float s, float factor) =>\n s.scale(factor)\n')
|
|
132
|
+
|
|
133
|
+
names = [node.name for node in ast.walk(ast.parse(code)) if isinstance(node, ast.FunctionDef)]
|
|
134
|
+
assert not [name for name in names if '_body' in name], names # no private function was made
|
|
135
|
+
exported = function_named(code, 'f')
|
|
136
|
+
assert ast.unparse(exported.body[0]) == 'return scale(s, factor)', ast.unparse(exported)
|
|
File without changes
|
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/opencode_pine2pyne.egg-info/entry_points.txt
RENAMED
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/opencode_pine2pyne.egg-info/requires.txt
RENAMED
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/opencode_pine2pyne.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/TRANSPILER_BEST_PRACTICES.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/pine2pyne/conditional_history_calls.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_block_tail_value_runtime.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_codegen_operator_grouping.py
RENAMED
|
File without changes
|
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_collect_bool_annotations.py
RENAMED
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_collect_namespace_members.py
RENAMED
|
File without changes
|
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_conditional_history_call_warning.py
RENAMED
|
File without changes
|
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_dotted_udt_default_runtime.py
RENAMED
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_drawing_receiver_runtime.py
RENAMED
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_emitted_name_collision_runtime.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_for_loop_dynamic_end_runtime.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_ground_truth_check_no_output.py
RENAMED
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_ground_truth_check_own_directory.py
RENAMED
|
File without changes
|
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_ground_truth_manifest_order.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_ground_truth_pynecore_commit.py
RENAMED
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_ground_truth_run_dir_isolation.py
RENAMED
|
File without changes
|
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_ground_truth_wrapper_retired.py
RENAMED
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_grouped_history_lowering.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_input_history_read_runtime.py
RENAMED
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_input_numeric_positional_binding.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_library_boundary_runtime.py
RENAMED
|
File without changes
|
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_library_name_collision_runtime.py
RENAMED
|
File without changes
|
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_loop_and_array_edge_cases.py
RENAMED
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_loop_counter_history_refusal.py
RENAMED
|
File without changes
|
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_method_receiver_shape_runtime.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_overload_dispatch_runtime.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_release_artifact_grouping.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_script_declaration_binding.py
RENAMED
|
File without changes
|
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_strategy_when_argument_card117.py
RENAMED
|
File without changes
|
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_suite_harness_exit_verdict.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_transformer_receiver_typing.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_type_as_identifier_card115.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_udt_field_defaults_runtime.py
RENAMED
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_udt_field_history_runtime.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{opencode_pine2pyne-0.2.3 → opencode_pine2pyne-0.2.4}/tests/test_variable_function_runtime.py
RENAMED
|
File without changes
|