Skip to content

Commit

Permalink
fix: get default api key from os.getenv
Browse files Browse the repository at this point in the history
  • Loading branch information
justinsunyt committed Dec 13, 2024
1 parent ff58c44 commit 29364be
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "scrapybara"
version = "2.0.1"
version = "2.0.2"
description = ""
readme = "README.md"
authors = []
Expand Down
12 changes: 6 additions & 6 deletions src/scrapybara/client.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/custom/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 29364be

Please sign in to comment.