Skip to content

Commit

Permalink
Fixed some more ruff stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
reinout committed Mar 12, 2024
1 parent 8605024 commit 10184d1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
3 changes: 1 addition & 2 deletions api/bro_upload/delivery.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import time
import traceback
from typing import Union

from . import config, utils

Expand Down Expand Up @@ -121,7 +120,7 @@ def _deliver_xml_file(self, xml_file: str) -> str:

return delivery_url

def _check_delivery(self, delivery_url: str) -> Union[str, None]:
def _check_delivery(self, delivery_url: str) -> str | None:
"""Checks the delivery status."""

delivery_info = utils.check_delivery_status(
Expand Down
2 changes: 1 addition & 1 deletion bro_hub/settings/development.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .base import *
from .base import * # noqa: F403

DEBUG = True

Expand Down
2 changes: 1 addition & 1 deletion bro_hub/settings/production.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .base import *
from .base import * # noqa: F403

DEBUG = True

Expand Down
10 changes: 7 additions & 3 deletions streamlit/authentication.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import json
from typing import Union
import logging

import config
import requests

import streamlit as st

logger = logging.getLogger(__name__)


def is_authenticated() -> bool:
"""Returns `True` if the api token is set correctly to the session state."""
Expand Down Expand Up @@ -38,7 +40,7 @@ def check_credentials() -> None:
return True


def get_api_token(username, password) -> Union[str, None]:
def get_api_token(username, password) -> str | None:
"""Uses the username and password combination to create an API token."""
url = f"{config.BASE_URL}/api/token/"
headers = {"Content-Type": "application/json"}
Expand All @@ -51,7 +53,9 @@ def get_api_token(username, password) -> Union[str, None]:
data=json.dumps(payload),
)
return r.json()["access"]
except:
except: # noqa: E722
# TODO: fix bare except
logger.exception("get_api_token error")
return None


Expand Down
6 changes: 5 additions & 1 deletion streamlit/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
from datetime import datetime, timedelta
from typing import Any

Expand All @@ -8,6 +9,8 @@

import streamlit as st

logger = logging.getLogger(__name__)


def set_user_details() -> None:
"""Saves the user details to the session state."""
Expand Down Expand Up @@ -90,7 +93,8 @@ def lookup_most_recent_datetime(endpoint: str) -> str:
)
return last_update

except:
except: # noqa: E722
logger.exception("TODO: bare except, fix this")
return None


Expand Down

0 comments on commit 10184d1

Please sign in to comment.