Skip to content

Commit

Permalink
Merge branch 'main' into edgarrmondragon/feat/sqltype-to-json-schema-…
Browse files Browse the repository at this point in the history
…singledispatch
  • Loading branch information
edgarrmondragon authored Sep 6, 2024
2 parents 78f1499 + 778c358 commit ee45bce
Show file tree
Hide file tree
Showing 21 changed files with 115 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ repos:
- id: check-readthedocs

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.3
rev: v0.6.4
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --show-fixes]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.29.1
rev: 0.29.2
hooks:
- id: check-dependabot
- id: check-github-workflows

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.6
rev: v0.6.4
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --show-fixes]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.1
rev: v1.11.2
hooks:
- id: mypy
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.29.1
rev: 0.29.2
hooks:
- id: check-dependabot
- id: check-github-workflows

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.6
rev: v0.6.4
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --show-fixes]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.1
rev: v1.11.2
hooks:
- id: mypy
additional_dependencies:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.29.1
rev: 0.29.2
hooks:
- id: check-dependabot
- id: check-github-workflows

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.6
rev: v0.6.4
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --show-fixes]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.1
rev: v1.11.2
hooks:
- id: mypy
additional_dependencies:
Expand Down
58 changes: 29 additions & 29 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 15 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,15 @@ types-PyYAML = ">=6.0.12"
pytest-codspeed = ">=2.2.0"

[tool.pytest.ini_options]
addopts = '--durations=10 --ignore=singer_sdk/helpers/_simpleeval.py -m "not external"'
addopts = [
"--durations=10",
"--ignore=singer_sdk/helpers/_simpleeval.py",
"-m",
"not external",
"-ra",
"--strict-config",
"--strict-markers",
]
filterwarnings = [
"error",
"ignore:Could not configure external gitlab tests:UserWarning",
Expand All @@ -167,13 +175,16 @@ filterwarnings = [
# https://github.com/joblib/joblib/pull/1518
"ignore:Attribute n is deprecated:DeprecationWarning:joblib._utils",
]
log_cli_level = "INFO"
markers = [
"external: Tests relying on external resources",
"windows: Tests that only run on Windows",
"snapshot: Tests that use pytest-snapshot",
]
minversion = "7"
testpaths = ["tests"]
norecursedirs = "cookiecutter"
xfail_strict = false

[tool.commitizen]
name = "cz_version_bump"
Expand Down Expand Up @@ -257,11 +268,14 @@ DEP002 = [
]

[tool.mypy]
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
exclude = "tests"
files = "singer_sdk"
local_partial_types = true
strict = false
warn_redundant_casts = true
warn_return_any = true
warn_unreachable = true
warn_unused_configs = true
warn_unused_ignores = true

Expand Down Expand Up @@ -295,7 +309,6 @@ extend-exclude = [
"*simpleeval*",
]
line-length = 88
src = ["samples", "singer_sdk", "tests"]
target-version = "py38"

[tool.ruff.format]
Expand Down
4 changes: 2 additions & 2 deletions singer_sdk/_singerlib/encoding/_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ def __post_init__(self) -> None:
self.type = SingerMessageType.SCHEMA

if isinstance(self.bookmark_properties, (str, bytes)):
self.bookmark_properties = [self.bookmark_properties]
self.bookmark_properties = [self.bookmark_properties] # type: ignore[unreachable]
if self.bookmark_properties and not isinstance(self.bookmark_properties, list):
msg = "bookmark_properties must be a string or list of strings"
msg = "bookmark_properties must be a string or list of strings" # type: ignore[unreachable]
raise ValueError(msg)


Expand Down
29 changes: 16 additions & 13 deletions singer_sdk/authenticators.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,20 @@
import base64
import datetime
import math
import sys
import typing as t
import warnings
from types import MappingProxyType
from urllib.parse import parse_qs, urlencode, urlsplit, urlunsplit

import requests

from singer_sdk.helpers._util import utc_now

if sys.version_info < (3, 13):
from typing_extensions import deprecated
else:
from warnings import deprecated

if t.TYPE_CHECKING:
import logging

Expand Down Expand Up @@ -71,7 +76,7 @@ def __call__(cls, *args: t.Any, **kwargs: t.Any) -> t.Any: # noqa: ANN401
A singleton instance of the derived class.
"""
if cls.__single_instance:
return cls.__single_instance
return cls.__single_instance # type: ignore[unreachable]
single_obj = cls.__new__(cls, None) # type: ignore[call-overload]
single_obj.__init__(*args, **kwargs)
cls.__single_instance = single_obj
Expand Down Expand Up @@ -165,7 +170,7 @@ def __init__(
"""
super().__init__(stream=stream)
if self.auth_headers is None:
self.auth_headers = {}
self.auth_headers = {} # type: ignore[unreachable]
if auth_headers:
self.auth_headers.update(auth_headers)

Expand Down Expand Up @@ -206,11 +211,11 @@ def __init__(

if location == "header":
if self.auth_headers is None:
self.auth_headers = {}
self.auth_headers = {} # type: ignore[unreachable]
self.auth_headers.update(auth_credentials)
elif location == "params":
if self.auth_params is None:
self.auth_params = {}
self.auth_params = {} # type: ignore[unreachable]
self.auth_params.update(auth_credentials)

@classmethod
Expand Down Expand Up @@ -255,7 +260,7 @@ def __init__(self, stream: RESTStream, token: str) -> None:
auth_credentials = {"Authorization": f"Bearer {token}"}

if self.auth_headers is None:
self.auth_headers = {}
self.auth_headers = {} # type: ignore[unreachable]
self.auth_headers.update(auth_credentials)

@classmethod
Expand All @@ -277,6 +282,10 @@ def create_for_stream(
return cls(stream=stream, token=token)


@deprecated(
"BasicAuthenticator is deprecated. Use requests.auth.HTTPBasicAuth instead.",
category=DeprecationWarning,
)
class BasicAuthenticator(APIAuthenticatorBase):
"""Implements basic authentication for REST Streams.
Expand All @@ -302,19 +311,13 @@ def __init__(
password: API password.
"""
super().__init__(stream=stream)
warnings.warn(
"BasicAuthenticator is deprecated. Use "
"requests.auth.HTTPBasicAuth instead.",
DeprecationWarning,
stacklevel=2,
)

credentials = f"{username}:{password}".encode()
auth_token = base64.b64encode(credentials).decode("ascii")
auth_credentials = {"Authorization": f"Basic {auth_token}"}

if self.auth_headers is None:
self.auth_headers = {}
self.auth_headers = {} # type: ignore[unreachable]
self.auth_headers.update(auth_credentials)

@classmethod
Expand Down
Loading

0 comments on commit ee45bce

Please sign in to comment.