Skip to content

Commit 44ecbbc

Browse files
Remove unnecessary calls to isinstance()
1 parent 17893e9 commit 44ecbbc

2 files changed

Lines changed: 2 additions & 11 deletions

File tree

src/pdfrest/client.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,6 @@ def _normalize_file_type(file_value: FileTypes) -> NormalizedFileTypes:
258258
normalized_content_type = (
259259
str(content_type) if content_type is not None else None
260260
)
261-
if not isinstance(headers, Mapping):
262-
msg = "Headers must be provided as a mapping of str keys to str values."
263-
raise TypeError(msg)
264261
normalized_headers = _normalize_headers(headers)
265262
return (
266263
normalized_filename,
@@ -303,9 +300,6 @@ def _parse_path_spec(spec: FilePathTypes) -> tuple[Path, str | None, Mapping[str
303300
headers: Mapping[str, str] = {}
304301
elif length == 3:
305302
raw_path, content_type, headers = cast(FilePathTuple3, spec)
306-
if not isinstance(headers, Mapping):
307-
msg = "Headers must be provided as a mapping of str keys to str values."
308-
raise TypeError(msg)
309303
else:
310304
msg = "File path tuples must contain a path plus optional content type and headers."
311305
raise TypeError(msg)
@@ -452,7 +446,7 @@ def __init__(
452446
max_retries: int = DEFAULT_MAX_RETRIES,
453447
) -> None:
454448
self._logger = LOGGER
455-
if not isinstance(max_retries, int) or max_retries < 0:
449+
if max_retries < 0:
456450
msg = "max_retries must be a non-negative integer."
457451
raise PdfRestConfigurationError(msg)
458452
self._max_retries = max_retries

src/pdfrest/models/public.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ class PdfRestFileID(str):
4747
)
4848

4949
def __new__(cls, value: str) -> PdfRestFileID:
50-
if not isinstance(value, str):
51-
msg = "PdfRestPrefixedUUID4 requires a str"
52-
raise TypeError(msg)
5350
if not cls._PY_PATTERN.fullmatch(value):
5451
msg = (
5552
"Invalid PdfRestPrefixedUUID4. Expected: "
@@ -88,7 +85,7 @@ def uuid_obj(self) -> _uuid.UUID:
8885
@classmethod
8986
def is_valid(cls, value: str) -> bool:
9087
"""Quick validity check without constructing the object."""
91-
return isinstance(value, str) and bool(cls._PY_PATTERN.fullmatch(value))
88+
return bool(cls._PY_PATTERN.fullmatch(value))
9289

9390
@classmethod
9491
def from_parts(

0 commit comments

Comments
 (0)