From eb26c97ef70edeafe3f6777759dcca7d6a08c98c Mon Sep 17 00:00:00 2001 From: dlee Date: Mon, 6 Feb 2023 15:29:53 -0600 Subject: [PATCH] implicit_optional flag added and errors related to flag fixed --- mypy.ini | 1 + src/allmydata/web/common.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mypy.ini b/mypy.ini index c6d8affe3..e6e7d16ff 100644 --- a/mypy.ini +++ b/mypy.ini @@ -5,5 +5,6 @@ show_column_numbers = True pretty = True show_error_codes = True warn_unused_configs =True +no_implicit_optional = True warn_redundant_casts = True strict_equality = True \ No newline at end of file diff --git a/src/allmydata/web/common.py b/src/allmydata/web/common.py index c49354217..3d85b1c4d 100644 --- a/src/allmydata/web/common.py +++ b/src/allmydata/web/common.py @@ -707,12 +707,12 @@ def url_for_string(req, url_string): T = TypeVar("T") @overload -def get_arg(req: IRequest, argname: str | bytes, default: T = None, *, multiple: Literal[False] = False) -> T | bytes: ... +def get_arg(req: IRequest, argname: str | bytes, default: Optional[T] = None, *, multiple: Literal[False] = False) -> T | bytes: ... @overload -def get_arg(req: IRequest, argname: str | bytes, default: T = None, *, multiple: Literal[True]) -> T | tuple[bytes, ...]: ... +def get_arg(req: IRequest, argname: str | bytes, default: Optional[T] = None, *, multiple: Literal[True]) -> T | tuple[bytes, ...]: ... -def get_arg(req: IRequest, argname: str | bytes, default: T = None, *, multiple: bool = False) -> None | T | bytes | tuple[bytes, ...]: +def get_arg(req: IRequest, argname: str | bytes, default: Optional[T] = None, *, multiple: bool = False) -> None | T | bytes | tuple[bytes, ...]: """Extract an argument from either the query args (req.args) or the form body fields (req.fields). If multiple=False, this returns a single value (or the default, which defaults to None), and the query args take