Skip to content

Commit d51b402

Browse files
Remove unnecessary calls to isinstance()
1 parent d174b07 commit d51b402

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
@@ -261,9 +261,6 @@ def _normalize_file_type(file_value: FileTypes) -> NormalizedFileTypes:
261261
normalized_content_type = (
262262
str(content_type) if content_type is not None else None
263263
)
264-
if not isinstance(headers, Mapping):
265-
msg = "Headers must be provided as a mapping of str keys to str values."
266-
raise TypeError(msg)
267264
normalized_headers = _normalize_headers(headers)
268265
return (
269266
normalized_filename,
@@ -306,9 +303,6 @@ def _parse_path_spec(spec: FilePathTypes) -> tuple[Path, str | None, Mapping[str
306303
headers: Mapping[str, str] = {}
307304
elif length == 3:
308305
raw_path, content_type, headers = cast(FilePathTuple3, spec)
309-
if not isinstance(headers, Mapping):
310-
msg = "Headers must be provided as a mapping of str keys to str values."
311-
raise TypeError(msg)
312306
else:
313307
msg = "File path tuples must contain a path plus optional content type and headers."
314308
raise TypeError(msg)
@@ -473,7 +467,7 @@ def __init__(
473467
max_retries: int = DEFAULT_MAX_RETRIES,
474468
) -> None:
475469
self._logger = LOGGER
476-
if not isinstance(max_retries, int) or max_retries < 0:
470+
if max_retries < 0:
477471
msg = "max_retries must be a non-negative integer."
478472
raise PdfRestConfigurationError(msg)
479473
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)