From 9c799641d45a6b261d6a271868b2346d49ce3099 Mon Sep 17 00:00:00 2001 From: Brendon Smith Date: Mon, 21 Sep 2020 01:02:59 -0400 Subject: [PATCH] Use Optional[str] for values that could be None br3ndonland/inboard#11 br3ndonland/inboard@02b249e https://mypy.readthedocs.io/en/latest/cheat_sheet_py3.html --- inboard/app/utilities.py | 4 ++-- inboard/gunicorn_conf.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/inboard/app/utilities.py b/inboard/app/utilities.py index 39e334e..01e4665 100644 --- a/inboard/app/utilities.py +++ b/inboard/app/utilities.py @@ -1,7 +1,7 @@ import base64 import os from secrets import compare_digest -from typing import Tuple, Union +from typing import Optional, Tuple from fastapi import Depends, HTTPException, status from fastapi.security import HTTPBasic, HTTPBasicCredentials @@ -17,7 +17,7 @@ class BasicAuth(AuthenticationBackend): async def authenticate( self, request: HTTPConnection - ) -> Union[Tuple[AuthCredentials, SimpleUser], None]: + ) -> Optional[Tuple[AuthCredentials, SimpleUser]]: if "Authorization" not in request.headers: return None diff --git a/inboard/gunicorn_conf.py b/inboard/gunicorn_conf.py index af33526..cb736d8 100644 --- a/inboard/gunicorn_conf.py +++ b/inboard/gunicorn_conf.py @@ -1,13 +1,13 @@ import multiprocessing import os -from typing import Union +from typing import Optional from inboard.start import configure_logging def calculate_workers( - max_workers_str: Union[str, None], - web_concurrency_str: Union[str, None], + max_workers_str: Optional[str], + web_concurrency_str: Optional[str], workers_per_core_str: str, cores: int = multiprocessing.cpu_count(), ) -> int: