From f2e0c85a2cac1e4304dc5f6ef7cb39f49b224d2f Mon Sep 17 00:00:00 2001 From: David Potter Date: Tue, 23 Sep 2025 09:40:18 -0700 Subject: [PATCH 1/3] test codeflash --- unstructured/documents/mappings.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/unstructured/documents/mappings.py b/unstructured/documents/mappings.py index ce05364f68..4c367f45a2 100644 --- a/unstructured/documents/mappings.py +++ b/unstructured/documents/mappings.py @@ -5,12 +5,27 @@ of parsed documents """ -from typing import Dict, Type +from typing import Dict, Type, Any, List from unstructured.documents import elements, ontology from unstructured.documents.elements import Element +def calculate_total_area(shapes: List[Any] | None = None) -> float: + if shapes is None: + shapes = [] # Empty list instead of trying to iterate over 100 + total_area = 0.0 + for shape in shapes: + b = [x * x for x in range(200)] + # Inefficient: Calculating pi in every iteration + pi = 3.14159265359 + if hasattr(shape, 'type') and shape.type == "circle": + total_area += pi * (shape.radius**2) * len(b) # Use len(b) instead of multiplying by the list + elif hasattr(shape, 'type') and shape.type == "square": + total_area += shape.side**2 + return total_area + + def get_all_subclasses(cls: type) -> list[type]: """ Recursively find all subclasses of a given class. From 58b7b9b704a013c596ff0cfd12f961be4ca0c574 Mon Sep 17 00:00:00 2001 From: David Potter Date: Tue, 23 Sep 2025 09:48:56 -0700 Subject: [PATCH 2/3] changelog --- CHANGELOG.md | 5 +++++ unstructured/__version__.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95cbf64bf7..0da17850bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.18.16-dev0 + +### Enhancements +- just testing codeflash + ## 0.18.15 ### Enhancements diff --git a/unstructured/__version__.py b/unstructured/__version__.py index 99e9be3387..52ed62c9c0 100644 --- a/unstructured/__version__.py +++ b/unstructured/__version__.py @@ -1 +1 @@ -__version__ = "0.18.15" # pragma: no cover +__version__ = "0.18.16-dev0" # pragma: no cover From 7fd2e82b36611909661987f2ded8616dbb5a96cf Mon Sep 17 00:00:00 2001 From: David Potter Date: Tue, 23 Sep 2025 10:07:22 -0700 Subject: [PATCH 3/3] lint --- unstructured/documents/mappings.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/unstructured/documents/mappings.py b/unstructured/documents/mappings.py index 4c367f45a2..7991114efb 100644 --- a/unstructured/documents/mappings.py +++ b/unstructured/documents/mappings.py @@ -5,7 +5,7 @@ of parsed documents """ -from typing import Dict, Type, Any, List +from typing import Any, Dict, List, Type from unstructured.documents import elements, ontology from unstructured.documents.elements import Element @@ -19,9 +19,11 @@ def calculate_total_area(shapes: List[Any] | None = None) -> float: b = [x * x for x in range(200)] # Inefficient: Calculating pi in every iteration pi = 3.14159265359 - if hasattr(shape, 'type') and shape.type == "circle": - total_area += pi * (shape.radius**2) * len(b) # Use len(b) instead of multiplying by the list - elif hasattr(shape, 'type') and shape.type == "square": + if hasattr(shape, "type") and shape.type == "circle": + total_area += ( + pi * (shape.radius**2) * len(b) + ) # Use len(b) instead of multiplying by the list + elif hasattr(shape, "type") and shape.type == "square": total_area += shape.side**2 return total_area