From 51768151404f49165fa1c788b98338c24537c1a6 Mon Sep 17 00:00:00 2001 From: Justin DuJardin Date: Wed, 29 Nov 2023 11:08:23 -0800 Subject: [PATCH] chore: type errors and auto formatting --- mathy_core/expressions.py | 4 ---- mathy_core/layout.py | 1 - mathy_core/problems.py | 2 +- tests/test_problems.py | 1 - tests/test_tokenizer.py | 2 -- tests/test_tree.py | 1 - tests/test_tree_node.py | 1 - 7 files changed, 1 insertion(+), 11 deletions(-) diff --git a/mathy_core/expressions.py b/mathy_core/expressions.py index 881a64f..624b222 100644 --- a/mathy_core/expressions.py +++ b/mathy_core/expressions.py @@ -140,7 +140,6 @@ def clear_classes(self) -> None: def visit_fn( node: MathExpression, depth: int, data: Any ) -> Optional[VisitStop]: - node.classes = [] return None @@ -153,7 +152,6 @@ def to_list(self, visit: str = "preorder") -> List["MathExpression"]: def visit_fn( node: MathExpression, depth: int, data: Any ) -> Optional[VisitStop]: - results.append(node) return None @@ -179,7 +177,6 @@ def find_type(self, instanceType: Type[NodeType]) -> List[NodeType]: def visit_fn( node: MathExpression, depth: int, data: Any ) -> Optional[VisitStop]: - if isinstance(node, instanceType): results.append(node) # type:ignore return None @@ -197,7 +194,6 @@ def find_id(self, id: str) -> Optional["MathExpression"]: def visit_fn( node: MathExpression, depth: int, data: Any ) -> Optional[VisitStop]: - nonlocal result if node.id == id: result = node diff --git a/mathy_core/layout.py b/mathy_core/layout.py index fb88924..af82d1b 100644 --- a/mathy_core/layout.py +++ b/mathy_core/layout.py @@ -4,7 +4,6 @@ class TidierExtreme: - left: Optional[BinaryTreeNode] right: Optional[BinaryTreeNode] thread: Optional[BinaryTreeNode] diff --git a/mathy_core/problems.py b/mathy_core/problems.py index f9b1681..6fa4e01 100644 --- a/mathy_core/problems.py +++ b/mathy_core/problems.py @@ -25,7 +25,7 @@ class MathyTermTemplate(BaseModel): variable: Optional[str] = Field(None, description="the term variable") - exponent: Optional[int] = Field(None, description="the term exponent") + exponent: Optional[int | float] = Field(None, description="the term exponent") def make(self) -> str: return mathy_term_string( diff --git a/tests/test_problems.py b/tests/test_problems.py index 36156aa..02840e2 100644 --- a/tests/test_problems.py +++ b/tests/test_problems.py @@ -12,7 +12,6 @@ def test_number_generation() -> None: - random.seed(1337) # When using pretty number generation, all values diff --git a/tests/test_tokenizer.py b/tests/test_tokenizer.py index d7739cc..faf1f3f 100644 --- a/tests/test_tokenizer.py +++ b/tests/test_tokenizer.py @@ -6,7 +6,6 @@ def test_tokenizer_tokenize() -> None: - text = "4x + 2x^3 * 7!" tokenizer = Tokenizer() tokens: List[Token] = tokenizer.tokenize(text) @@ -18,7 +17,6 @@ def test_tokenizer_tokenize() -> None: def test_tokenizer_errors() -> None: - text = "4x + 2x^3 * 7\\" tokenizer = Tokenizer() diff --git a/tests/test_tree.py b/tests/test_tree.py index c80b0c8..5cb982a 100644 --- a/tests/test_tree.py +++ b/tests/test_tree.py @@ -55,7 +55,6 @@ def node_visit(node, depth, data): def test_tree_node_is_leaf(): - """check that the known extremes of a tree are reported as leaf nodes and that all other known non - extremes are not.""" tree = BinarySearchTree(0) diff --git a/tests/test_tree_node.py b/tests/test_tree_node.py index 3eea1e3..090f0bc 100644 --- a/tests/test_tree_node.py +++ b/tests/test_tree_node.py @@ -50,7 +50,6 @@ def node_visit(node, depth, data): def test_tree_node_is_leaf(): - """check that the known extremes of a tree are reported as leaf nodes and that all other known non - extremes are not.""" tree = BinarySearchTree(0)