Skip to content

Commit 28c8729

Browse files
committed
remove dupes
1 parent 1f88c24 commit 28c8729

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

hyperbrowser/models/_parsers.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from typing import Any
2+
3+
4+
def _parse_optional_int(value: Any):
5+
if value is None or isinstance(value, int):
6+
return value
7+
if isinstance(value, str) and value.strip() == "":
8+
return None
9+
if isinstance(value, str):
10+
return int(value)
11+
return value

hyperbrowser/models/sandbox.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
55

6+
from ._parsers import _parse_optional_int
67
from .session import SessionLaunchState, SessionStatus
78

89
SandboxStatus = SessionStatus
@@ -38,16 +39,6 @@ def _parse_optional_datetime(value):
3839
return value
3940

4041

41-
def _parse_optional_int(value):
42-
if value is None or isinstance(value, int):
43-
return value
44-
if isinstance(value, str) and value.strip() == "":
45-
return None
46-
if isinstance(value, str):
47-
return int(value)
48-
return value
49-
50-
5142
def _parse_optional_datetime_from_millis(value):
5243
if value in (None, ""):
5344
return None

hyperbrowser/models/volume.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,7 @@
22

33
from pydantic import BaseModel, ConfigDict, Field, field_validator
44

5-
6-
def _parse_optional_int(value):
7-
if value is None or isinstance(value, int):
8-
return value
9-
if isinstance(value, str) and value.strip() == "":
10-
return None
11-
if isinstance(value, str):
12-
return int(value)
13-
return value
5+
from ._parsers import _parse_optional_int
146

157

168
class VolumeBaseModel(BaseModel):

0 commit comments

Comments
 (0)