Skip to content

Commit

Permalink
removes unnecessary check for API key because dlt already handles it …
Browse files Browse the repository at this point in the history
…well
  • Loading branch information
willi-mueller committed Feb 8, 2024
1 parent eeb1a9b commit 43a6fe7
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
4 changes: 1 addition & 3 deletions sources/bing_webmaster/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from dlt.common.typing import DictStrAny, DictStrStr
from dlt.sources import DltResource

from .helpers import get_stats_with_retry, parse_response, check_api_key
from .helpers import get_stats_with_retry, parse_response


@dlt.source(name="bing_webmaster")
Expand Down Expand Up @@ -54,7 +54,6 @@ def page_stats(
Yields:
Iterator[Dict[str, Any]]: An iterator over list of organic traffic statistics.
"""
check_api_key(api_key)
api_path = "GetPageStats"
for site_url in site_urls:
params = {"siteUrl": site_url, "apikey": api_key}
Expand Down Expand Up @@ -85,7 +84,6 @@ def page_query_stats(
Yields:
Iterator[Dict[str, Any]]: An iterator over list of organic traffic statistics.
"""
check_api_key(api_key)
api_path = "GetPageQueryStats"
for record in site_url_pages:
time.sleep(0.5) # this avoids rate limit observed after dozens of requests
Expand Down
8 changes: 0 additions & 8 deletions sources/bing_webmaster/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@
from .settings import BASE_URL, HEADERS


def check_api_key(api_key: str) -> None:
if api_key is None or len(api_key) == 0:
raise ValueError(
"""Please provide a Bing Webmaster API key in secrets.toml under
[sources.bing_webmaster]
api_key="your_api_key" """
)


def get_url_with_retry(url: str, params: DictStrStr) -> DictStrAny:
try:
Expand Down

0 comments on commit 43a6fe7

Please sign in to comment.