diff --git a/pyproject.toml b/pyproject.toml index 722a7c9..b0f8435 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "scrapybara" -version = "2.0.1" +version = "2.0.2" description = "" readme = "README.md" authors = [] diff --git a/src/scrapybara/client.py b/src/scrapybara/client.py index 683508a..b289242 100644 --- a/src/scrapybara/client.py +++ b/src/scrapybara/client.py @@ -1,6 +1,8 @@ from datetime import datetime from typing import Optional, Any, Dict, List, Sequence, Union, Literal import typing +import httpx +import os from scrapybara.environment import ScrapybaraEnvironment from .core.request_options import RequestOptions @@ -22,12 +24,10 @@ StopBrowserResponse, StopInstanceResponse, ) - -OMIT = typing.cast(typing.Any, ...) - from .base_client import BaseClient, AsyncBaseClient from .instance.types import Action, Command -import httpx + +OMIT = typing.cast(typing.Any, ...) class Browser: @@ -680,7 +680,7 @@ def __init__( *, base_url: Optional[str] = None, environment: ScrapybaraEnvironment = ScrapybaraEnvironment.PRODUCTION, - api_key: Optional[str] = None, + api_key: Optional[str] = os.getenv("SCRAPYBARA_API_KEY"), timeout: Optional[float] = None, follow_redirects: Optional[bool] = True, httpx_client: Optional[httpx.Client] = None, @@ -735,7 +735,7 @@ def __init__( *, base_url: Optional[str] = None, environment: ScrapybaraEnvironment = ScrapybaraEnvironment.PRODUCTION, - api_key: Optional[str] = None, + api_key: Optional[str] = os.getenv("SCRAPYBARA_API_KEY"), timeout: Optional[float] = None, follow_redirects: Optional[bool] = True, httpx_client: Optional[httpx.AsyncClient] = None, diff --git a/tests/custom/test_client.py b/tests/custom/test_client.py index 7dcd4b9..a9a60a0 100644 --- a/tests/custom/test_client.py +++ b/tests/custom/test_client.py @@ -5,7 +5,7 @@ def test_client() -> None: if os.getenv("SCRAPYBARA_API_KEY") is None: raise ValueError("SCRAPYBARA_API_KEY is not set") - client = Scrapybara(api_key=os.getenv("SCRAPYBARA_API_KEY")) + client = Scrapybara() instance = client.start() assert instance.id is not None screenshot_response = instance.screenshot()