Skip to content

Commit 7cff360

Browse files
committed
Fixed the rest of the errors that would only concern 1 - 3 files
Signed-off-by: Florian <[email protected]>
1 parent 4a82f9a commit 7cff360

File tree

11 files changed

+26
-27
lines changed

11 files changed

+26
-27
lines changed

docling_core/transforms/chunker/code_chunking/code_chunk.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

55
from enum import Enum
6-
from typing import Literal, Optional
6+
from typing import Literal
77

88
from pydantic import Field
99

@@ -28,12 +28,12 @@ class CodeDocMeta(DocMeta):
2828
default="docling_core.transforms.chunker.CodeDocMeta",
2929
alias=_KEY_SCHEMA_NAME,
3030
)
31-
part_name: Optional[str] = Field(default=None)
32-
docstring: Optional[str] = Field(default=None)
33-
sha256: Optional[int] = Field(default=None)
34-
start_line: Optional[int] = Field(default=None)
35-
end_line: Optional[int] = Field(default=None)
36-
end_line_signature: Optional[int] = Field(default=None)
31+
part_name: str | None = Field(default=None)
32+
docstring: str | None = Field(default=None)
33+
sha256: int | None = Field(default=None)
34+
start_line: int | None = Field(default=None)
35+
end_line: int | None = Field(default=None)
36+
end_line_signature: int | None = Field(default=None)
3737
chunk_type: CodeChunkType = Field(default=CodeChunkType.CODE_BLOCK)
3838

3939

docling_core/transforms/chunker/hierarchical_chunker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

55
import logging
6-
from typing import Any, Iterator, Optional
6+
from typing import Any, Iterator
77

88
from pydantic import ConfigDict, Field
99
from typing_extensions import Annotated, override
@@ -125,7 +125,7 @@ class HierarchicalChunker(BaseChunker):
125125
model_config = ConfigDict(arbitrary_types_allowed=True)
126126

127127
serializer_provider: BaseSerializerProvider = ChunkingSerializerProvider()
128-
code_chunking_strategy: Optional[BaseCodeChunkingStrategy] = Field(default=None)
128+
code_chunking_strategy: BaseCodeChunkingStrategy | None = Field(default=None)
129129

130130
# deprecated:
131131
merge_list_items: Annotated[bool, Field(deprecated=True)] = True

docling_core/transforms/serializer/markdown.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,9 @@ def serialize(
175175

176176
# wrap with outer marker (if applicable)
177177
if params.ensure_valid_list_item_marker and not case_already_valid:
178-
assert item.parent and isinstance(
179-
(list_group := item.parent.resolve(doc)), ListGroup
180-
)
178+
assert item.parent
179+
list_group = item.parent.resolve(doc)
180+
assert isinstance(list_group, ListGroup)
181181
if list_group.first_item_is_enumerated(doc) and (
182182
params.orig_list_item_marker_mode != OrigListItemMarkerMode.AUTO
183183
or not item.marker

docling_core/types/doc/page.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,8 +1253,7 @@ def iterate_pages(
12531253
Returns:
12541254
Iterator of (page number, page) tuples
12551255
"""
1256-
for page_no, page in self.pages.items():
1257-
yield (page_no, page)
1256+
yield from self.pages.items()
12581257

12591258
def export_to_dict(
12601259
self,

docling_core/types/legacy_doc/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ def export_to_html(self) -> str:
246246
for j in range(ncols):
247247
cell: TableCell = self.data[i][j]
248248

249-
rowspan, rowstart, rowend = self._get_tablecell_span(cell, 0)
250-
colspan, colstart, colend = self._get_tablecell_span(cell, 1)
249+
rowspan, rowstart, _ = self._get_tablecell_span(cell, 0)
250+
colspan, colstart, _ = self._get_tablecell_span(cell, 1)
251251

252252
if rowstart is not None and rowstart != i:
253253
continue

test/test_base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ def test_collection_document_info():
214214
CCSDocumentDescription(**desc_dict)
215215

216216
desc_dict["collection"]["type"] = "Record"
217-
with pytest.raises(ValidationError, match="collection.type"):
217+
with pytest.raises(ValidationError, match="collection\\.type"):
218218
CCSDocumentDescription(**desc_dict)
219219

220220

@@ -251,11 +251,11 @@ def test_collection_record_info():
251251
RecordDescription(**desc_dict)
252252

253253
desc_dict["collection"]["type"] = "Document"
254-
with pytest.raises(ValidationError, match="collection.type"):
254+
with pytest.raises(ValidationError, match="collection\\.type"):
255255
RecordDescription(**desc_dict)
256256

257257
desc_dict["collection"]["type"] = "record"
258-
with pytest.raises(ValidationError, match="collection.type"):
258+
with pytest.raises(ValidationError, match="collection\\.type"):
259259
RecordDescription(**desc_dict)
260260

261261

test/test_code_chunker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def create_documents_from_repository(
6262
]
6363
)
6464

65-
all_files = sorted(list(set(all_files)))
65+
all_files = sorted(set(all_files))
6666

6767
for file_path in all_files:
6868
with open(file_path, "r", encoding="utf-8") as f:

test/test_rec_schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def test_predicates_wrong(self):
3737

3838
filename = "test/data/rec/error-predicate-02.json"
3939
with (
40-
pytest.raises(ValidationError, match="geopoint_value.conf"),
40+
pytest.raises(ValidationError, match="geopoint_value\\.conf"),
4141
open(filename, encoding="utf-8") as file_obj,
4242
):
4343
file_json = file_obj.read()

test/test_regions_to_table.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ def test_regions_to_table_convert():
6767
assert table_data.table_cells[0].bbox.b == 25.0
6868

6969
assert table_data.table_cells[0].col_span == 2
70-
assert table_data.table_cells[0].column_header == True
71-
assert table_data.table_cells[1].column_header == True
70+
assert table_data.table_cells[0].column_header
71+
assert table_data.table_cells[1].column_header
7272

73-
assert table_data.table_cells[10].row_header == True
74-
assert table_data.table_cells[12].row_section == True
73+
assert table_data.table_cells[10].row_header
74+
assert table_data.table_cells[12].row_section
7575

7676
assert table_data.table_cells[17].bbox.l == 75.0
7777
assert table_data.table_cells[17].bbox.t == 100.0

test/test_serialization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def verify(exp_file: Path, actual: str):
4343

4444
# Normalize platform-dependent quote escaping for DocTags outputs
4545
name = exp_file.name
46-
if name.endswith(".dt") or name.endswith(".idt.xml"):
46+
if name.endswith((".dt", ".idt.xml")):
4747

4848
def _normalize_quotes(s: str) -> str:
4949
return s.replace("&quot;", '"').replace("&#34;", '"')

0 commit comments

Comments
 (0)