diff --git a/authum/cli.py b/authum/cli.py index 8008da3..903a93d 100644 --- a/authum/cli.py +++ b/authum/cli.py @@ -9,7 +9,6 @@ import authum.plugin import authum.util - authum.plugin.load_plugins() plugin_list = "\n".join( f"- {p.__name__.split('.')[-1]} ({p.__name__})" diff --git a/authum/duo.py b/authum/duo.py index 897ba1d..6917eeb 100644 --- a/authum/duo.py +++ b/authum/duo.py @@ -3,7 +3,6 @@ import socket import threading import time -from typing import Union import webbrowser import flask @@ -12,7 +11,6 @@ import authum import authum.http - flask.cli.show_server_banner = lambda *args: None logging.getLogger("werkzeug").disabled = True log = logging.getLogger(__name__) diff --git a/authum/gui.py b/authum/gui.py index f991a3a..30f64b3 100644 --- a/authum/gui.py +++ b/authum/gui.py @@ -1,11 +1,10 @@ import signal import sys -from typing import Type, Union +from typing import Type import authum import authum.util - HAS_TTY = sys.stdout.isatty() HAS_TKINTER = False try: @@ -14,7 +13,7 @@ HAS_TKINTER = True - def prompt(prompt: str, type: Type = int) -> Union[None, str]: + def prompt(prompt: str, type: Type = int) -> None | str: """Prompt for text""" tkinter.Tk().withdraw() return sdg.askstring(authum.metadata["Name"].capitalize(), prompt) diff --git a/authum/http.py b/authum/http.py index 807de1f..4f16036 100644 --- a/authum/http.py +++ b/authum/http.py @@ -1,15 +1,14 @@ import base64 -from collections.abc import Mapping import dataclasses import json import logging -from typing import Any, Iterable import xml.etree.ElementTree +from collections.abc import Mapping +from typing import Any, Iterable import bs4 import requests - log = logging.getLogger(__name__) diff --git a/authum/persistence.py b/authum/persistence.py index 196327e..eddfe3f 100644 --- a/authum/persistence.py +++ b/authum/persistence.py @@ -1,12 +1,11 @@ -from collections.abc import MutableMapping import json import logging +from collections.abc import MutableMapping from typing import Any, Iterable import keyring import keyring.errors - log = logging.getLogger(__name__) diff --git a/authum/plugin.py b/authum/plugin.py index f3add7b..d4343e7 100644 --- a/authum/plugin.py +++ b/authum/plugin.py @@ -6,7 +6,6 @@ import pluggy - PLUGIN_MODULE_BUILTIN_PATH = os.path.join(os.path.dirname(__file__), "plugins") PLUGIN_MODULE_BUILTIN_PREFIX = f"{__package__}.plugins." PLUGIN_MODULE_PREFIX = f"{__package__}-" @@ -50,7 +49,7 @@ def saml_request(url): url (str): A SAML URL Returns: - Union[authum.http.SAMLAssertion, None]: A SAML assertion + authum.http.SAMLAssertion | None: A SAML assertion """ pass diff --git a/authum/plugins/aws/__init__.py b/authum/plugins/aws/__init__.py index e17e3c5..2bed2be 100644 --- a/authum/plugins/aws/__init__.py +++ b/authum/plugins/aws/__init__.py @@ -1,8 +1,9 @@ -import click import os -import rich.table import sys +import click +import rich.table + import authum.plugin import authum.plugins.aws.lib import authum.util diff --git a/authum/plugins/aws/lib.py b/authum/plugins/aws/lib.py index df51f73..9e0aaa9 100644 --- a/authum/plugins/aws/lib.py +++ b/authum/plugins/aws/lib.py @@ -6,8 +6,8 @@ import os import subprocess import time -from typing import ClassVar, Union import webbrowser +from typing import ClassVar import arn.iam import boto3 @@ -18,7 +18,6 @@ import authum.plugin import authum.util - logging.getLogger("botocore").propagate = False log = logging.getLogger(__name__) @@ -36,7 +35,7 @@ def set_credentials(self, name: str, v: "AWSRoleCredentials") -> None: def credentials( self, name: str - ) -> Union["AWSSSORoleCredentials", "AWSSAMLRoleCredentials"]: + ) -> "AWSSSORoleCredentials" | "AWSSAMLRoleCredentials": """Return credentials by name""" args = self["credentials"][name] if "start_url" in args: @@ -150,7 +149,7 @@ def renew( if not force and not self.is_expired: return - log.debug(f"Renewing SSO client registration") + log.debug("Renewing SSO client registration") if not boto_sso_oidc_client: boto_sso_oidc_client = boto3.client("sso-oidc") response = boto_sso_oidc_client.register_client( @@ -268,7 +267,7 @@ def list_accounts(self, boto_sso_client=None) -> list: """Returns a list of available accounts and roles""" account_list = [] - log.debug(f"Requesting account list") + log.debug("Requesting account list") if not boto_sso_client: boto_sso_client = boto3.client("sso") accounts = boto_sso_client.list_accounts( @@ -349,7 +348,7 @@ def assume_role(self, boto_sts_client=None): endpoint_url=self.sts_endpoint if self.sts_endpoint else None, ) - log.debug(f"Requesting STS caller identity") + log.debug("Requesting STS caller identity") response = boto_sts_client.get_caller_identity() log.debug(f"AWS response: {response}") @@ -452,7 +451,7 @@ def renew(self, force: bool = False): "," ) except IndexError: - raise AWSPluginError(f"No role ARN found in SAML assertion") + raise AWSPluginError("No role ARN found in SAML assertion") try: assume_role_args["DurationSeconds"] = int( diff --git a/authum/plugins/jumpcloud/__init__.py b/authum/plugins/jumpcloud/__init__.py index 703a6dd..ccc276e 100644 --- a/authum/plugins/jumpcloud/__init__.py +++ b/authum/plugins/jumpcloud/__init__.py @@ -102,7 +102,7 @@ def jumpcloud(email: str, password: str, rm_session: bool, rm: bool) -> None: jumpcloud_data.email = email if password: jumpcloud_data.password = click.prompt( - f"JumpCloud password", hide_input=True + "JumpCloud password", hide_input=True ) if rm_session: jumpcloud_data.session = {} diff --git a/authum/plugins/jumpcloud/lib.py b/authum/plugins/jumpcloud/lib.py index 1b4a9ab..942271c 100644 --- a/authum/plugins/jumpcloud/lib.py +++ b/authum/plugins/jumpcloud/lib.py @@ -1,6 +1,6 @@ import dataclasses import logging -from typing import Type, Union +from typing import Type import authum.duo import authum.http @@ -103,7 +103,7 @@ def auth(self, lazy: bool = False) -> authum.http.RESTResponse: def xsrf(self) -> authum.http.RESTResponse: """Requests an XSRF token, updates the session, and returns the response""" - log.debug(f"Requesting XSRF token") + log.debug("Requesting XSRF token") response = self.rest_request(url=self.urls["xsrf"], method="get") log.debug("Saving session data") @@ -112,7 +112,7 @@ def xsrf(self) -> authum.http.RESTResponse: return response - def auth_totp(self, otp: str) -> Union[authum.http.RESTResponse, None]: + def auth_totp(self, otp: str) -> authum.http.RESTResponse | None: """Performs MFA factor verification for the "totp" factor type""" response = self.rest_request( url=self.urls["auth_totp"], method="post", data={"otp": str(otp)} @@ -122,7 +122,7 @@ def auth_totp(self, otp: str) -> Union[authum.http.RESTResponse, None]: return response - def auth_duo(self) -> Union[authum.http.RESTResponse, None]: + def auth_duo(self) -> authum.http.RESTResponse | None: """Performs MFA factor verification for the "duo" factor type""" response = self.rest_request(url=self.urls["auth_duo"], method="get") duo = authum.duo.DuoWebV2( diff --git a/authum/plugins/okta/lib.py b/authum/plugins/okta/lib.py index 37bde69..b601df5 100644 --- a/authum/plugins/okta/lib.py +++ b/authum/plugins/okta/lib.py @@ -2,12 +2,11 @@ import itertools import logging import time -from typing import Type, Union +from typing import Type import authum.duo -import authum.persistence import authum.http - +import authum.persistence log = logging.getLogger(__name__) @@ -118,7 +117,7 @@ def verify( mfa_response: authum.http.RESTResponse, factor_id: str, factor_args: dict = {}, - ) -> Union[authum.http.RESTResponse, None]: + ) -> authum.http.RESTResponse | None: """Performs MFA factor verification. See: https://developer.okta.com/docs/reference/api/factors/ @@ -174,7 +173,7 @@ def session_create(self, session_token: str) -> authum.http.RESTResponse: See: https://developer.okta.com/docs/reference/api/sessions/ """ - log.debug(f"Creating session") + log.debug("Creating session") response = self.rest_request( url=self.urls["sessions"], method="post", @@ -195,7 +194,7 @@ def session_refresh(self) -> authum.http.RESTResponse: if not self._session.refresh_url: raise OktaError("No session refresh URL found") - log.debug(f"Refreshing session") + log.debug("Refreshing session") return self.rest_request(url=self._session.refresh_url, method="post") def app_links(self) -> authum.http.RESTResponse: diff --git a/authum/util.py b/authum/util.py index 9f02980..a4d7ef6 100644 --- a/authum/util.py +++ b/authum/util.py @@ -1,11 +1,10 @@ -from typing import Any import urllib.parse +from typing import Any import rich.box import rich.console import rich.table - rich_stdout = rich.console.Console(soft_wrap=True) rich_stderr = rich.console.Console(stderr=True) diff --git a/tests/conftest.py b/tests/conftest.py index 3b85d82..a3dcf19 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,7 +1,7 @@ import os import pathlib -from typing import Any import uuid +from typing import Any import keyring import keyring.backend diff --git a/tests/test_jumpcloud_lib.py b/tests/test_jumpcloud_lib.py index 1ddd95e..c4959d7 100644 --- a/tests/test_jumpcloud_lib.py +++ b/tests/test_jumpcloud_lib.py @@ -3,8 +3,8 @@ import pytest import responses -import authum.plugins.jumpcloud.lib import authum.http +import authum.plugins.jumpcloud.lib @pytest.fixture diff --git a/tests/test_okta_lib.py b/tests/test_okta_lib.py index 8af8696..85ebffb 100644 --- a/tests/test_okta_lib.py +++ b/tests/test_okta_lib.py @@ -3,8 +3,8 @@ import pytest import responses -import authum.plugins.okta.lib import authum.http +import authum.plugins.okta.lib @pytest.fixture