Skip to content

Commit

Permalink
fix: invalid dataclass mutable default (#388)
Browse files Browse the repository at this point in the history
Modify the default value of mutable variable in dataclass to be assigned via default_factory as instructed.
  • Loading branch information
ds-filipknefel authored Sep 30, 2024
1 parent f35ffd7 commit 3071c85
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.7.38-dev0

* fix: Correctly assign mutable default value to variable in `TextRegions` class

## 0.7.37

* refactor: remove layout analysis related code
Expand Down
2 changes: 1 addition & 1 deletion unstructured_inference/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.7.37" # pragma: no cover
__version__ = "0.7.38-dev0" # pragma: no cover
4 changes: 2 additions & 2 deletions unstructured_inference/inference/elements.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from copy import deepcopy
from dataclasses import dataclass
from dataclasses import dataclass, field
from functools import cached_property
from typing import Optional, Union

Expand Down Expand Up @@ -209,7 +209,7 @@ def from_coords(
@dataclass
class TextRegions:
element_coords: np.ndarray
texts: np.ndarray = np.array([])
texts: np.ndarray = field(default_factory=lambda: np.array([]))
source: Source | None = None

def __post_init__(self):
Expand Down

1 comment on commit 3071c85

@cragwolfe
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we cut a new release for this @ds-filipknefel , @badGarnet ?

Please sign in to comment.