[BE]: Enable RUF013 ban implicit optional (#141706)

Enables RUF013 rule to ban implicit Optional (from areas not already checked by mypy).

Pull Request resolved: https://github.com/pytorch/pytorch/pull/141706
Approved by: https://github.com/ezyang
This commit is contained in:
Aaron Gokaslan
2024-11-28 04:02:58 +00:00
committed by PyTorch MergeBot
parent b33f770574
commit 9f48881ba8
4 changed files with 6 additions and 4 deletions

View File

@ -308,7 +308,7 @@ def write_decl_impl(
family_name: str,
impl_file: str,
autogen_dir: Path,
disable_def: str = None,
disable_def: Optional[str] = None,
) -> None:
cpp_file_header = """/*
* Copyright (c) Meta Platforms, Inc. and affiliates.

View File

@ -141,6 +141,7 @@ select = [
"Q004", # unnecessary escaped quote
"RSE",
"RUF008", # mutable dataclass default
"RUF013", # ban implicit optional
"RUF015", # access first ele in constant time
"RUF016", # type error non-integer index
"RUF017",

View File

@ -215,7 +215,8 @@ class TracerBase:
kwargs: Dict[str, Any],
name: Optional[str] = None,
type_expr: Optional[Any] = None,
proxy_factory_fn: Callable[[Node], "Proxy"] = None,
# fix noqa when updating bc tests
proxy_factory_fn: Callable[[Node], "Proxy"] = None, # noqa: RUF013
):
"""
Create a Node from the given arguments, then return the Node

View File

@ -1846,7 +1846,7 @@ def skipCUDAIfNotMiopenSuggestNHWC(fn):
# Skips a test for specified CUDA versions, given in the form of a list of [major, minor]s.
def skipCUDAVersionIn(versions: List[Tuple[int, int]] = None):
def skipCUDAVersionIn(versions: Optional[List[Tuple[int, int]]] = None):
def dec_fn(fn):
@wraps(fn)
def wrap_fn(self, *args, **kwargs):
@ -1864,7 +1864,7 @@ def skipCUDAVersionIn(versions: List[Tuple[int, int]] = None):
# Skips a test for CUDA versions less than specified, given in the form of [major, minor].
def skipCUDAIfVersionLessThan(versions: Tuple[int, int] = None):
def skipCUDAIfVersionLessThan(versions: Optional[Tuple[int, int]] = None):
def dec_fn(fn):
@wraps(fn)
def wrap_fn(self, *args, **kwargs):