Skip to content

Commit

Permalink
style: type hints fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunato committed Jan 18, 2024
1 parent cbf26b8 commit 97cdf7a
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 20 deletions.
4 changes: 1 addition & 3 deletions eodag/plugins/authentication/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
"""EODAG authentication package"""
from __future__ import annotations

from typing import Dict, Union

from requests.auth import AuthBase

from eodag.plugins.authentication.base import Authentication
Expand All @@ -28,6 +26,6 @@
class DummyAuth(Authentication):
"""Dummy authentication"""

def authenticate(self) -> Union[AuthBase, Dict[str, str]]:
def authenticate(self) -> AuthBase:
"""authenticate"""
return AuthBase()
4 changes: 2 additions & 2 deletions eodag/plugins/authentication/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# limitations under the License.
from __future__ import annotations

from typing import TYPE_CHECKING, Dict, Union
from typing import TYPE_CHECKING

from requests.auth import HTTPBasicAuth, HTTPDigestAuth

Expand All @@ -31,7 +31,7 @@
class GenericAuth(Authentication):
"""GenericAuth authentication plugin"""

def authenticate(self) -> Union[AuthBase, Dict[str, str]]:
def authenticate(self) -> AuthBase:
"""Authenticate"""
self.validate_config_credentials()
method = getattr(self.config, "method", "basic")
Expand Down
4 changes: 2 additions & 2 deletions eodag/plugins/authentication/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# limitations under the License.
from __future__ import annotations

from typing import TYPE_CHECKING, Dict, Union
from typing import TYPE_CHECKING, Dict

from requests.auth import AuthBase

Expand Down Expand Up @@ -60,7 +60,7 @@ class HTTPHeaderAuth(Authentication):
Expect an undefined behaviour if you use empty braces in header value strings.
"""

def authenticate(self) -> Union[AuthBase, Dict[str, str]]:
def authenticate(self) -> AuthBase:
"""Authenticate"""
self.validate_config_credentials()
headers = {
Expand Down
2 changes: 1 addition & 1 deletion eodag/plugins/authentication/keycloak.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def validate_config_credentials(self) -> None:
f"{self.provider}: {param}",
)

def authenticate(self) -> Union[AuthBase, Dict[str, str]]:
def authenticate(self) -> AuthBase:
"""
Makes authentication request
"""
Expand Down
6 changes: 2 additions & 4 deletions eodag/plugins/authentication/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
# limitations under the License.
from __future__ import annotations

from typing import TYPE_CHECKING, Dict, Union
from typing import TYPE_CHECKING, Dict

from eodag.plugins.authentication.base import Authentication

if TYPE_CHECKING:
from requests.auth import AuthBase

from eodag.config import PluginConfig


Expand All @@ -35,7 +33,7 @@ def __init__(self, provider: str, config: PluginConfig) -> None:
self.access_key = None
self.secret_key = None

def authenticate(self) -> Union[AuthBase, Dict[str, str]]:
def authenticate(self) -> Dict[str, str]:
"""Authenticate"""
self.validate_config_credentials()
self.access_key = self.config.credentials["aws_access_key_id"]
Expand Down
4 changes: 2 additions & 2 deletions eodag/plugins/authentication/openid_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import re
import string
from random import SystemRandom
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
from typing import TYPE_CHECKING, Any, Optional

import requests
from lxml import etree
Expand Down Expand Up @@ -144,7 +144,7 @@ def __init__(self, provider: str, config: PluginConfig) -> None:
)
self.session = requests.Session()

def authenticate(self) -> Union[AuthBase, Dict[str, str]]:
def authenticate(self) -> AuthBase:
"""Authenticate"""
state = self.compute_state()
authentication_response = self.authenticate_user(state)
Expand Down
4 changes: 2 additions & 2 deletions eodag/plugins/authentication/qsauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# limitations under the License.
from __future__ import annotations

from typing import TYPE_CHECKING, Any, Dict, Union
from typing import TYPE_CHECKING, Any
from urllib.parse import parse_qs, urlparse

import requests
Expand Down Expand Up @@ -60,7 +60,7 @@ class HttpQueryStringAuth(Authentication):
:meth:`~eodag.plugins.authentication.query_string.HttpQueryStringAuth.authenticate`
"""

def authenticate(self) -> Union[AuthBase, Dict[str, str]]:
def authenticate(self) -> AuthBase:
"""Authenticate"""
self.validate_config_credentials()

Expand Down
4 changes: 2 additions & 2 deletions eodag/plugins/authentication/sas_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import logging
from json import JSONDecodeError
from typing import TYPE_CHECKING, Dict, Optional, Union
from typing import TYPE_CHECKING, Dict, Optional

import requests
from requests.auth import AuthBase
Expand Down Expand Up @@ -82,7 +82,7 @@ def validate_config_credentials(self) -> None:
# credentials are optionnal
pass

def authenticate(self) -> Union[AuthBase, Dict[str, str]]:
def authenticate(self) -> AuthBase:
"""Authenticate"""
self.validate_config_credentials()

Expand Down
4 changes: 2 additions & 2 deletions eodag/plugins/authentication/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from __future__ import annotations

import logging
from typing import TYPE_CHECKING, Dict, Optional, Union
from typing import TYPE_CHECKING, Dict, Optional
from urllib.parse import parse_qs, urlencode, urlparse, urlunparse

import requests
Expand Down Expand Up @@ -65,7 +65,7 @@ def validate_config_credentials(self) -> None:
f"Missing credentials inputs for provider {self.provider}: {e}"
)

def authenticate(self) -> Union[AuthBase, Dict[str, str]]:
def authenticate(self) -> AuthBase:
"""Authenticate"""
self.validate_config_credentials()

Expand Down

0 comments on commit 97cdf7a

Please sign in to comment.