Skip to content

Commit c08aaed

Browse files
Ignore some types in Pydantic validators
Pydantic before validators deal with semi-unstructured data that will get fully validated when they reach the model, so ignore Pyright's complaints about unknown types.
1 parent c79875c commit c08aaed

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/pdfrest/models/_internal.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def _ensure_list(value: Any) -> Any:
3030
if value is None:
3131
return None
3232
if isinstance(value, list):
33-
return value
33+
return value # pyright: ignore[reportUnknownVariableType]
3434
if isinstance(value, Sequence) and not isinstance(value, (str, bytes, bytearray)):
3535
return list(value)
3636
return [value]
@@ -80,7 +80,7 @@ def _split_comma_list(value: Any) -> Any:
8080
if isinstance(value, str):
8181
return value.split(",")
8282
if isinstance(value, list):
83-
return value
83+
return value # pyright: ignore[reportUnknownVariableType]
8484
if isinstance(value, Sequence) and not isinstance(value, (str, bytes, bytearray)):
8585
return list(value)
8686
msg = "Must be a comma separated string or a list of strings."
@@ -152,7 +152,7 @@ def _int_to_string(value: Any) -> Any:
152152
if isinstance(value, int):
153153
return str(value)
154154
if isinstance(value, list):
155-
return [_int_to_string(item) for item in value]
155+
return [_int_to_string(item) for item in value] # pyright: ignore[reportUnknownVariableType]
156156
return value
157157

158158

@@ -429,13 +429,13 @@ class _PdfMergeItem(BaseModel):
429429
@classmethod
430430
def _transform_input(cls, data: Any) -> Any:
431431
if isinstance(data, tuple):
432-
if len(data) != 2:
432+
if len(data) != 2: # pyright: ignore[reportUnknownArgumentType]
433433
msg = (
434434
"Tuple merge entries must contain exactly two items: (file, pages)."
435435
)
436436
raise ValueError(msg)
437-
file_candidate, pages = data
438-
return {"file": file_candidate, "pages": pages}
437+
file_candidate, pages = data # pyright: ignore[reportUnknownVariableType]
438+
return {"file": file_candidate, "pages": pages} # pyright: ignore[reportUnknownVariableType]
439439
if isinstance(data, PdfRestFile):
440440
return {"file": data}
441441
return data

0 commit comments

Comments
 (0)