encode / httpx

A next generation HTTP client for Python. 🦋

Home Page:https://www.python-httpx.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Auth type makes problem in `dbt-duckdb` > `fsspec` > `webdav4` > `httpx`

ZergRocks opened this issue · comments

# _types.py
AuthTypes = Union[
    Mapping[str, Any], # added
    Tuple[Union[str, bytes], Union[str, bytes]],
    Callable[["Request"], "Request"],
    "Auth",
]
# _client.py
    def _build_auth(self, auth: typing.Optional[AuthTypes]) -> typing.Optional[Auth]:
        if auth is None:
            return None
        elif isinstance(auth, tuple):
            if any(
                [
                    type(auth == dict),
                    auth.get('username'),
                    auth.get('password'),
                ]
            ):
                return BasicAuth( # added
                    username=auth.get('username'),
                    passworkd=auth.get('password')
                )
            return BasicAuth(username=auth[0], password=auth[1])
        elif isinstance(auth, Auth):
            return auth
        elif callable(auth):
            return FunctionAuth(func=auth)
        else:
            raise TypeError(f'Invalid "auth" argument: {auth!r}')

The auth option that this made in when I use the webdav option in the file system interface used by dbt-duckdb and is related to the handling of AuthType in this repository.

However, the current fs: webdav option is almost unavailable because the external module(especially dbt) is restricted from processing the yaml file in profiles.yml and converting it into a tuple. Therefore, we can consider ways such as enhancing httpx or changing the profile.yaml treatment in dbt-core to handle it.

Can you give me any advice on this matter? @jwills