From 2b8e87d31fd92b41c41f866a2618936d64b01ed9 Mon Sep 17 00:00:00 2001 From: Przemek Denkiewicz Date: Tue, 6 Aug 2024 13:21:41 +0200 Subject: [PATCH] Fix types-all installation failure in pre-commit --- .pre-commit-config.yaml | 2 -- setup.cfg | 1 + trino/auth.py | 12 ++++++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a781ab8c..321f6e47 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,8 +10,6 @@ repos: hooks: - id: "mypy" name: "Python: types" - additional_dependencies: - - "types-all" - repo: https://github.com/pycqa/isort rev: "5.13.2" diff --git a/setup.cfg b/setup.cfg index 372d84b0..c7cc318a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -18,6 +18,7 @@ disallow_untyped_defs = true ignore_missing_imports = true no_implicit_optional = true warn_unused_ignores = true +disable_error_code = import-untyped [mypy-tests.*,trino.client,trino.dbapi,trino.sqlalchemy.*] ignore_errors = true diff --git a/trino/auth.py b/trino/auth.py index 6262f95a..c739ff8f 100644 --- a/trino/auth.py +++ b/trino/auth.py @@ -389,7 +389,7 @@ def __call__(self, r: PreparedRequest) -> PreparedRequest: if token is not None: r.headers['Authorization'] = "Bearer " + token - r.register_hook('response', self._authenticate) # type: ignore + r.register_hook('response', self._authenticate) return r @@ -422,7 +422,7 @@ def _attempt_oauth(self, response: Response, **kwargs: Any) -> None: raise exceptions.TrinoAuthError(f"Error: header info didn't match {auth_info}") auth_info_headers = parse_dict_header( - _OAuth2TokenBearer._BEARER_PREFIX.sub("", auth_info, count=1)) # type: ignore + _OAuth2TokenBearer._BEARER_PREFIX.sub("", auth_info, count=1)) auth_server = auth_info_headers.get('x_redirect_server') token_server = auth_info_headers.get('x_token_server') @@ -448,8 +448,8 @@ def _attempt_oauth(self, response: Response, **kwargs: Any) -> None: def _retry_request(self, response: Response, **kwargs: Any) -> Optional[Response]: request = response.request.copy() - extract_cookies_to_jar(request._cookies, response.request, response.raw) # type: ignore - request.prepare_cookies(request._cookies) # type: ignore + extract_cookies_to_jar(request._cookies, response.request, response.raw) + request.prepare_cookies(request._cookies) host = self._determine_host(response.request.url) user = self._determine_user(request.headers) @@ -457,7 +457,7 @@ def _retry_request(self, response: Response, **kwargs: Any) -> Optional[Response token = self._get_token_from_cache(key) if token is not None: request.headers['Authorization'] = "Bearer " + token - retry_response = response.connection.send(request, **kwargs) # type: ignore + retry_response = response.connection.send(request, **kwargs) retry_response.history.append(response) retry_response.request = request return retry_response @@ -466,7 +466,7 @@ def _get_token(self, token_server: str, response: Response, **kwargs: Any) -> st attempts = 0 while attempts < self.MAX_OAUTH_ATTEMPTS: attempts += 1 - with response.connection.send(Request( # type: ignore + with response.connection.send(Request( method='GET', url=token_server).prepare(), **kwargs) as response: if response.status_code == 200: token_response = json.loads(response.text)