Skip to content

Commit

Permalink
Fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mconigliaro committed Jan 30, 2025
1 parent ba0c04c commit 6d6c969
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 38 deletions.
1 change: 0 additions & 1 deletion authum/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__})"
Expand Down
2 changes: 0 additions & 2 deletions authum/duo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import socket
import threading
import time
from typing import Union
import webbrowser

import flask
Expand All @@ -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__)
Expand Down
5 changes: 2 additions & 3 deletions authum/gui.py
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions authum/http.py
Original file line number Diff line number Diff line change
@@ -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__)


Expand Down
3 changes: 1 addition & 2 deletions authum/persistence.py
Original file line number Diff line number Diff line change
@@ -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__)


Expand Down
3 changes: 1 addition & 2 deletions authum/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__}-"
Expand Down Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions authum/plugins/aws/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 6 additions & 7 deletions authum/plugins/aws/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -18,7 +18,6 @@
import authum.plugin
import authum.util


logging.getLogger("botocore").propagate = False
log = logging.getLogger(__name__)

Expand All @@ -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:
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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}")

Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion authum/plugins/jumpcloud/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down
8 changes: 4 additions & 4 deletions authum/plugins/jumpcloud/lib.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import dataclasses
import logging
from typing import Type, Union
from typing import Type

import authum.duo
import authum.http
Expand Down Expand Up @@ -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")
Expand All @@ -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)}
Expand All @@ -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(
Expand Down
11 changes: 5 additions & 6 deletions authum/plugins/okta/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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/
Expand Down Expand Up @@ -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",
Expand All @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions authum/util.py
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import pathlib
from typing import Any
import uuid
from typing import Any

import keyring
import keyring.backend
Expand Down
2 changes: 1 addition & 1 deletion tests/test_jumpcloud_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import pytest
import responses

import authum.plugins.jumpcloud.lib
import authum.http
import authum.plugins.jumpcloud.lib


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion tests/test_okta_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import pytest
import responses

import authum.plugins.okta.lib
import authum.http
import authum.plugins.okta.lib


@pytest.fixture
Expand Down

0 comments on commit 6d6c969

Please sign in to comment.