Skip to content

Commit 54cc28e

Browse files
committed
minor refactoring
1 parent eeab4ce commit 54cc28e

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

‎browserbase/__init__.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
import os
2-
from typing import List, Union
2+
from typing import Optional, Sequence, Union
33
from playwright.sync_api import sync_playwright
44

55

66
class Browserbase:
7-
def __init__(self, api_key: str = os.environ["BROWSERBASE_KEY"]):
8-
"""Create new Browserbase instance"""
9-
if not api_key:
10-
raise ValueError("Browserbase API key was not provided")
7+
def __init__(self, api_key: Optional[str] = None):
8+
"""Create new Browserbase SDK client instance"""
9+
self.api_key = api_key or os.environ["BROWSERBASE_API_KEY"]
1110

12-
self.api_key = api_key
13-
14-
def load(self, url: Union[str, List[str]], **args):
11+
def load(self, url: Union[str, Sequence[str]], **args):
1512
if isinstance(url, str):
1613
return self.load_url(url, **args)
17-
elif isinstance(url, list):
14+
elif isinstance(url, Sequence):
1815
return self.load_urls(url, **args)
1916
else:
20-
raise TypeError("Input must be a URL string or a list of URLs")
17+
raise TypeError("Input must be a URL string or a Sequence of URLs")
2118

2219
def load_url(self, url: str, text_content: bool = False):
2320
"""Load a page in a headless browser and return the contents"""
@@ -43,7 +40,7 @@ def load_url(self, url: str, text_content: bool = False):
4340

4441
return html
4542

46-
def load_urls(self, urls: List[str], text_content: bool = False):
43+
def load_urls(self, urls: Sequence[str], text_content: bool = False):
4744
"""Load multiple pages in a headless browser and return the contents"""
4845
if not urls:
4946
raise ValueError("Page URL was not provided")

0 commit comments

Comments
 (0)