From 4db84b04838523594c7fa2250649492e0d41e150 Mon Sep 17 00:00:00 2001 From: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Date: Mon, 15 Aug 2022 03:15:03 -0700 Subject: [PATCH] Use --no-implicit-optional for type checking (#6413) * Use --no-implicit-optional for type checking This is needed for PEP 484 compliant type checking (as of 2018). mypy will change its defaults soon. See https://github.com/python/mypy/issues/9091 * forcing CI rerun Co-authored-by: Vasilis Vryniotis --- mypy.ini | 1 + torchvision/datasets/utils.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mypy.ini b/mypy.ini index 6d7863b627e..c1d174f4595 100644 --- a/mypy.ini +++ b/mypy.ini @@ -4,6 +4,7 @@ files = torchvision show_error_codes = True pretty = True allow_redefinition = True +no_implicit_optional = True warn_redundant_casts = True [mypy-torchvision.prototype.features.*] diff --git a/torchvision/datasets/utils.py b/torchvision/datasets/utils.py index 30506b3fc79..32839163b7b 100644 --- a/torchvision/datasets/utils.py +++ b/torchvision/datasets/utils.py @@ -458,7 +458,7 @@ def iterable_to_str(iterable: Iterable) -> str: def verify_str_arg( value: T, arg: Optional[str] = None, - valid_values: Iterable[T] = None, + valid_values: Optional[Iterable[T]] = None, custom_msg: Optional[str] = None, ) -> T: if not isinstance(value, torch._six.string_classes):