Skip to content

Commit

Permalink
refactor: Deprecate singer_sdk.authenticators.BasicAuthenticator in…
Browse files Browse the repository at this point in the history
… favor of `requests.auth.HTTPBasicAuth`

Closes #2040
  • Loading branch information
edgarrmondragon committed Feb 15, 2024
1 parent a8cd892 commit f03ef53
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from singer_sdk.streams import {{ cookiecutter.stream_type }}Stream

{% elif cookiecutter.auth_method == "Basic Auth" -%}
from singer_sdk.authenticators import BasicAuthenticator
from requests.auth import HTTPBasicAuth
from singer_sdk.helpers.jsonpath import extract_jsonpath
from singer_sdk.pagination import BaseAPIPaginator # noqa: TCH002
from singer_sdk.streams import {{ cookiecutter.stream_type }}Stream
Expand Down Expand Up @@ -110,14 +110,13 @@ def authenticator(self) -> BearerTokenAuthenticator:
{%- elif cookiecutter.auth_method == "Basic Auth" %}

@property
def authenticator(self) -> BasicAuthenticator:
def authenticator(self) -> HTTPBasicAuth:
"""Return a new authenticator object.
Returns:
An authenticator instance.
"""
return BasicAuthenticator.create_for_stream(
self,
return HTTPBasicAuth(
username=self.config.get("username", ""),
password=self.config.get("password", ""),
)
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ jsonl = "singer_sdk.contrib.batch_encoder_jsonl:JSONLinesBatcher"
parquet = "singer_sdk.contrib.batch_encoder_parquet:ParquetBatcher"

[tool.ruff]
extend-exclude = [
"cookiecutter/*",
"*simpleeval*",
]
line-length = 88
src = ["samples", "singer_sdk", "tests"]
target-version = "py38"
Expand All @@ -257,10 +261,6 @@ target-version = "py38"
docstring-code-format = true

[tool.ruff.lint]
exclude = [
"cookiecutter/*",
"*simpleeval*",
]
ignore = [
"ANN101", # Missing type annotation for `self` in method
"ANN102", # Missing type annotation for `cls` in class method
Expand Down
5 changes: 4 additions & 1 deletion singer_sdk/authenticators.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,10 @@ def create_for_stream(
class BasicAuthenticator(APIAuthenticatorBase):
"""Implements basic authentication for REST Streams.
This Authenticator implements basic authentication by concatinating a
.. deprecated:: 0.36.0
Use :class:`requests.auth.HTTPBasicAuth` instead.
This Authenticator implements basic authentication by concatenating a
username and password then base64 encoding the string. The resulting
token will be merged with any HTTP headers specified on the stream.
"""
Expand Down
2 changes: 1 addition & 1 deletion singer_sdk/helpers/_flattening.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def get_flattening_options(
Returns:
A new FlatteningOptions object or None if flattening is disabled.
"""
if plugin_config.get("flattening_enabled"):
if plugin_config.get("flattening_enabled", False):
return FlatteningOptions(max_level=int(plugin_config["flattening_max_depth"]))

return None
Expand Down

0 comments on commit f03ef53

Please sign in to comment.