From 93cc3513fe4a9269db4830f422c2972c43c3c0ed Mon Sep 17 00:00:00 2001 From: Louis Mandel Date: Wed, 28 Aug 2024 15:57:43 -0400 Subject: [PATCH] Remove toplevel `__init__.py` (#1) --- .travis.yml | 2 +- __init__.py | 0 docsource/contrib.md | 2 +- tests/test_array.py | 5 ++--- tests/test_code.py | 5 ++--- tests/test_cond.py | 5 ++--- tests/test_defs.py | 5 ++--- tests/test_errors.py | 10 +++------- tests/test_examples.py | 2 +- tests/test_expr.py | 6 +++--- tests/test_fallback.py | 5 ++--- tests/test_for.py | 6 +++--- tests/test_function.py | 5 ++--- tests/test_hello.py | 13 +++++++------ tests/test_include.py | 5 ++--- tests/test_input.py | 5 ++--- tests/test_line_table.py | 2 +- tests/test_messages.py | 5 ++--- tests/test_model.py | 5 ++--- tests/test_parse.py | 5 ++--- tests/test_parser.py | 6 +++--- tests/test_role.py | 5 ++--- tests/test_schema.py | 2 +- tests/test_type_checking.py | 8 ++++---- tests/test_var.py | 6 +++--- 25 files changed, 55 insertions(+), 70 deletions(-) delete mode 100644 __init__.py diff --git a/.travis.yml b/.travis.yml index 189b0b4a..e3294be8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,5 +17,5 @@ script: - >- echo -e "${ANSI_GREEN}Running Tests...${ANSI_RESET}" && echo -en 'travis_fold:start:tests\\r' - - pytest + - pytest tests - echo -en 'travis_fold:end:tests\\r' diff --git a/__init__.py b/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/docsource/contrib.md b/docsource/contrib.md index 8a463f5d..b3011c85 100644 --- a/docsource/contrib.md +++ b/docsource/contrib.md @@ -17,7 +17,7 @@ To suggest a change to this repository, [submit a pull request](https://github.i The test suite can be executed with the following command in the top-level folder: ``` -pytest +pytest tests ``` Also, please make sure that your changes pass static checks such as code styles by executing the following command: diff --git a/tests/test_array.py b/tests/test_array.py index 920337b9..67204552 100644 --- a/tests/test_array.py +++ b/tests/test_array.py @@ -1,6 +1,5 @@ -from pdl.pdl.pdl_ast import Program # pyright: ignore -from pdl.pdl.pdl_interpreter import empty_scope # pyright: ignore -from pdl.pdl.pdl_interpreter import InterpreterState, process_prog # pyright: ignore +from pdl.pdl_ast import Program +from pdl.pdl_interpreter import InterpreterState, empty_scope, process_prog array_data = {"description": "Array", "array": ["1", "2", "3", "4"]} diff --git a/tests/test_code.py b/tests/test_code.py index 3aab98ef..a4ce6f3a 100644 --- a/tests/test_code.py +++ b/tests/test_code.py @@ -1,6 +1,5 @@ -from pdl.pdl.pdl_ast import Program # pyright: ignore -from pdl.pdl.pdl_interpreter import empty_scope # pyright: ignore -from pdl.pdl.pdl_interpreter import InterpreterState, process_prog # pyright: ignore +from pdl.pdl_ast import Program +from pdl.pdl_interpreter import InterpreterState, empty_scope, process_prog python_data = { "description": "Hello world showing call out to python code", diff --git a/tests/test_cond.py b/tests/test_cond.py index 0475478d..96c0f0e2 100644 --- a/tests/test_cond.py +++ b/tests/test_cond.py @@ -1,6 +1,5 @@ -from pdl.pdl.pdl_ast import Program # pyright: ignore -from pdl.pdl.pdl_interpreter import empty_scope # pyright: ignore -from pdl.pdl.pdl_interpreter import InterpreterState, process_prog # pyright: ignore +from pdl.pdl_ast import Program +from pdl.pdl_interpreter import InterpreterState, empty_scope, process_prog cond_data = { "description": "Arithmetic Expressions", diff --git a/tests/test_defs.py b/tests/test_defs.py index 858da33c..2be03d7a 100644 --- a/tests/test_defs.py +++ b/tests/test_defs.py @@ -1,6 +1,5 @@ -from pdl.pdl.pdl_ast import Program # pyright: ignore -from pdl.pdl.pdl_interpreter import empty_scope # pyright: ignore -from pdl.pdl.pdl_interpreter import InterpreterState, process_prog # pyright: ignore +from pdl.pdl_ast import Program +from pdl.pdl_interpreter import InterpreterState, empty_scope, process_prog defs_data = { "description": "Hello world with variable use", diff --git a/tests/test_errors.py b/tests/test_errors.py index f7d8845f..94f929d4 100644 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -2,13 +2,9 @@ from pydantic import ValidationError -from pdl.pdl.pdl_ast import Program, empty_block_location # pyright: ignore -from pdl.pdl.pdl_interpreter import ( # pyright: ignore - InterpreterState, - empty_scope, - process_prog, -) -from pdl.pdl.pdl_schema_error_analyzer import analyze_errors # pyright: ignore +from pdl.pdl_ast import Program, empty_block_location +from pdl.pdl_interpreter import InterpreterState, empty_scope, process_prog +from pdl.pdl_schema_error_analyzer import analyze_errors def error(raw_data, assertion): diff --git a/tests/test_examples.py b/tests/test_examples.py index 77e98878..8a20e043 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -3,7 +3,7 @@ import pydantic import yaml -from pdl.pdl.pdl_ast import Program # pyright: ignore +from pdl.pdl_ast import Program EXPECTED_INVALID = [ pathlib.Path("tests") / "data" / "line" / "hello.pdl", diff --git a/tests/test_expr.py b/tests/test_expr.py index 92ed8d35..c48486ce 100644 --- a/tests/test_expr.py +++ b/tests/test_expr.py @@ -1,8 +1,8 @@ -from pdl.pdl.pdl_ast import Program # pyright: ignore -from pdl.pdl.pdl_interpreter import empty_scope # pyright: ignore -from pdl.pdl.pdl_interpreter import ( # pyright: ignore +from pdl.pdl_ast import Program +from pdl.pdl_interpreter import ( InterpreterState, contains_error, + empty_scope, process_prog, ) diff --git a/tests/test_fallback.py b/tests/test_fallback.py index c0118b75..9a25ec85 100644 --- a/tests/test_fallback.py +++ b/tests/test_fallback.py @@ -1,6 +1,5 @@ -from pdl.pdl.pdl_ast import Program # pyright: ignore -from pdl.pdl.pdl_interpreter import empty_scope # pyright: ignore -from pdl.pdl.pdl_interpreter import InterpreterState, process_prog # pyright: ignore +from pdl.pdl_ast import Program +from pdl.pdl_interpreter import InterpreterState, empty_scope, process_prog direct_fallback_data = {"model": "raise an error", "fallback": "The error was caught"} diff --git a/tests/test_for.py b/tests/test_for.py index 9dcc58a8..b9ee29b2 100644 --- a/tests/test_for.py +++ b/tests/test_for.py @@ -1,8 +1,8 @@ -from pdl.pdl.pdl_ast import Program # pyright: ignore -from pdl.pdl.pdl_interpreter import empty_scope # pyright: ignore -from pdl.pdl.pdl_interpreter import ( # pyright: ignore +from pdl.pdl_ast import Program +from pdl.pdl_interpreter import ( InterpreterState, contains_error, + empty_scope, process_prog, ) diff --git a/tests/test_function.py b/tests/test_function.py index 598f4fb6..0f0ebe30 100644 --- a/tests/test_function.py +++ b/tests/test_function.py @@ -1,6 +1,5 @@ -from pdl.pdl.pdl_ast import Program # pyright: ignore -from pdl.pdl.pdl_interpreter import empty_scope # pyright: ignore -from pdl.pdl.pdl_interpreter import InterpreterState, process_prog # pyright: ignore +from pdl.pdl_ast import Program +from pdl.pdl_interpreter import InterpreterState, empty_scope, process_prog hello_def = { "def": "hello", diff --git a/tests/test_hello.py b/tests/test_hello.py index 089b352b..aa4dc06d 100644 --- a/tests/test_hello.py +++ b/tests/test_hello.py @@ -1,8 +1,8 @@ -from pdl.pdl.pdl_ast import Program # pyright: ignore -from pdl.pdl.pdl_interpreter import empty_scope # pyright: ignore -from pdl.pdl.pdl_interpreter import ( # pyright: ignore +from pdl.pdl_ast import Program, RepeatBlock +from pdl.pdl_interpreter import ( InterpreterState, contains_error, + empty_scope, process_prog, ) @@ -121,8 +121,9 @@ def test_repeat_error(): _, _, _, trace = process_prog(state, empty_scope, data) errors = 0 print(trace) - for document in trace.trace: - if contains_error(document): - errors += 1 + if trace is not None and isinstance(trace, RepeatBlock): + for document in trace.trace: + if contains_error(document): + errors += 1 assert errors == 1 diff --git a/tests/test_include.py b/tests/test_include.py index 50ee9770..0e4f03d5 100644 --- a/tests/test_include.py +++ b/tests/test_include.py @@ -1,6 +1,5 @@ -from pdl.pdl.pdl_ast import Program # pyright: ignore -from pdl.pdl.pdl_interpreter import empty_scope # pyright: ignore -from pdl.pdl.pdl_interpreter import InterpreterState, process_prog # pyright: ignore +from pdl.pdl_ast import Program +from pdl.pdl_interpreter import InterpreterState, empty_scope, process_prog include_data = { "description": "Include test", diff --git a/tests/test_input.py b/tests/test_input.py index cf618e27..f9e73a8b 100644 --- a/tests/test_input.py +++ b/tests/test_input.py @@ -1,6 +1,5 @@ -from pdl.pdl.pdl_ast import Program # pyright: ignore -from pdl.pdl.pdl_interpreter import empty_scope # pyright: ignore -from pdl.pdl.pdl_interpreter import InterpreterState, process_prog # pyright: ignore +from pdl.pdl_ast import Program +from pdl.pdl_interpreter import InterpreterState, empty_scope, process_prog input_data = { "description": "Input block example", diff --git a/tests/test_line_table.py b/tests/test_line_table.py index 4e02cf14..2b8c848c 100644 --- a/tests/test_line_table.py +++ b/tests/test_line_table.py @@ -1,4 +1,4 @@ -from pdl.pdl.pdl_interpreter import generate # pyright: ignore +from pdl.pdl_interpreter import generate def do_test(t, capsys): diff --git a/tests/test_messages.py b/tests/test_messages.py index 0675a3c4..0a8f63f0 100644 --- a/tests/test_messages.py +++ b/tests/test_messages.py @@ -1,8 +1,7 @@ import yaml -from pdl.pdl.pdl_ast import Program # pyright: ignore -from pdl.pdl.pdl_interpreter import empty_scope # pyright: ignore -from pdl.pdl.pdl_interpreter import InterpreterState, process_prog # pyright: ignore +from pdl.pdl_ast import Program +from pdl.pdl_interpreter import InterpreterState, empty_scope, process_prog def parse_prog_str(prog_str): diff --git a/tests/test_model.py b/tests/test_model.py index 43ac81ba..6e962adf 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -1,6 +1,5 @@ -from pdl.pdl.pdl_ast import Program # pyright: ignore -from pdl.pdl.pdl_interpreter import empty_scope # pyright: ignore -from pdl.pdl.pdl_interpreter import InterpreterState, process_prog # pyright: ignore +from pdl.pdl_ast import Program +from pdl.pdl_interpreter import InterpreterState, empty_scope, process_prog model_data = { "description": "Hello world with a variable to call into a model", diff --git a/tests/test_parse.py b/tests/test_parse.py index 5ced0827..e5a91a8e 100644 --- a/tests/test_parse.py +++ b/tests/test_parse.py @@ -1,6 +1,5 @@ -from pdl.pdl.pdl_ast import Program # pyright: ignore -from pdl.pdl.pdl_interpreter import empty_scope # pyright: ignore -from pdl.pdl.pdl_interpreter import InterpreterState, process_prog # pyright: ignore +from pdl.pdl_ast import Program +from pdl.pdl_interpreter import InterpreterState, empty_scope, process_prog regex_data = { "description": "Parsing using regex", diff --git a/tests/test_parser.py b/tests/test_parser.py index e1f0e64b..5db8b9d4 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -1,8 +1,8 @@ -from pdl.pdl.pdl_ast import Program # pyright: ignore -from pdl.pdl.pdl_interpreter import empty_scope # pyright: ignore -from pdl.pdl.pdl_interpreter import ( # pyright: ignore +from pdl.pdl_ast import Program +from pdl.pdl_interpreter import ( InterpreterState, contains_error, + empty_scope, process_prog, ) diff --git a/tests/test_role.py b/tests/test_role.py index 907fb072..ccf25d93 100644 --- a/tests/test_role.py +++ b/tests/test_role.py @@ -1,8 +1,7 @@ import yaml -from pdl.pdl.pdl_ast import Program # pyright: ignore -from pdl.pdl.pdl_interpreter import empty_scope # pyright: ignore -from pdl.pdl.pdl_interpreter import InterpreterState, process_prog # pyright: ignore +from pdl.pdl_ast import Program +from pdl.pdl_interpreter import InterpreterState, empty_scope, process_prog def parse_prog_str(prog_str): diff --git a/tests/test_schema.py b/tests/test_schema.py index 85c9eb87..db08dae2 100644 --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -2,7 +2,7 @@ from pydantic.json_schema import models_json_schema -from pdl.pdl.pdl_ast import PdlBlock, PdlBlocks, Program # pyright: ignore +from pdl.pdl_ast import PdlBlock, PdlBlocks, Program def test_saved_schema(): diff --git a/tests/test_type_checking.py b/tests/test_type_checking.py index 65c72b12..ace3e576 100644 --- a/tests/test_type_checking.py +++ b/tests/test_type_checking.py @@ -1,13 +1,13 @@ import yaml -from pdl.pdl.pdl_ast import Program # pyright: ignore -from pdl.pdl.pdl_interpreter import empty_scope # pyright: ignore -from pdl.pdl.pdl_interpreter import ( # pyright: ignore +from pdl.pdl_ast import Program +from pdl.pdl_interpreter import ( InterpreterState, contains_error, + empty_scope, process_prog, ) -from pdl.pdl.pdl_schema_utils import pdltype_to_jsonschema # pyright: ignore +from pdl.pdl_schema_utils import pdltype_to_jsonschema _PDLTYPE_TO_JSONSCHEMA_TESTS = [ { diff --git a/tests/test_var.py b/tests/test_var.py index 398032d9..2940db7e 100644 --- a/tests/test_var.py +++ b/tests/test_var.py @@ -1,8 +1,8 @@ -from pdl.pdl.pdl_ast import Program # pyright: ignore -from pdl.pdl.pdl_interpreter import empty_scope # pyright: ignore -from pdl.pdl.pdl_interpreter import ( # pyright: ignore +from pdl.pdl_ast import Program +from pdl.pdl_interpreter import ( InterpreterState, contains_error, + empty_scope, process_prog, )