mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[BE][Ez]: Update ruff to 0.12.2 (#157937)
Updates to the latest version of ruff and apply some fixes that it flagged and silence a few new lints Pull Request resolved: https://github.com/pytorch/pytorch/pull/157937 Approved by: https://github.com/ezyang
This commit is contained in:
committed by
PyTorch MergeBot
parent
0d17029fea
commit
7a08755c5f
@ -1462,7 +1462,7 @@ init_command = [
|
||||
'black==23.12.1',
|
||||
'usort==1.0.8.post1',
|
||||
'isort==6.0.1',
|
||||
'ruff==0.11.13', # sync with RUFF
|
||||
'ruff==0.12.2', # sync with RUFF
|
||||
]
|
||||
is_formatter = true
|
||||
|
||||
@ -1597,7 +1597,7 @@ init_command = [
|
||||
'python3',
|
||||
'tools/linter/adapters/pip_init.py',
|
||||
'--dry-run={{DRYRUN}}',
|
||||
'ruff==0.11.13', # sync with PYFMT
|
||||
'ruff==0.12.2', # sync with PYFMT
|
||||
]
|
||||
is_formatter = true
|
||||
|
||||
|
@ -130,6 +130,7 @@ ignore = [
|
||||
"E741",
|
||||
"EXE001",
|
||||
"F405",
|
||||
"FURB122", # writelines
|
||||
# these ignores are from flake8-logging-format; please fix!
|
||||
"G101",
|
||||
# these ignores are from ruff NPY; please fix!
|
||||
@ -152,6 +153,7 @@ ignore = [
|
||||
"SIM117",
|
||||
"SIM118",
|
||||
"UP007", # keep-runtime-typing
|
||||
"UP045", # keep-runtime-typing
|
||||
"TC006",
|
||||
]
|
||||
select = [
|
||||
@ -233,6 +235,10 @@ select = [
|
||||
"YTT",
|
||||
]
|
||||
|
||||
[tool.ruff.lint.pyupgrade]
|
||||
# Preserve types, even if a file imports `from __future__ import annotations`.
|
||||
keep-runtime-typing = true
|
||||
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
"__init__.py" = [
|
||||
"F401",
|
||||
|
@ -6648,7 +6648,7 @@ class TestQuantizeFx(QuantizationTestCase):
|
||||
"""
|
||||
|
||||
def __init__(self, input_dim, output_dim):
|
||||
super(__class__, self).__init__()
|
||||
super().__init__()
|
||||
self.w = nn.Parameter(torch.randn(input_dim, output_dim))
|
||||
self.b = nn.Parameter(torch.randn(input_dim))
|
||||
|
||||
@ -6661,7 +6661,7 @@ class TestQuantizeFx(QuantizationTestCase):
|
||||
"""
|
||||
|
||||
def __init__(self, input_dim, hidden_dim, output_dim):
|
||||
super(__class__, self).__init__()
|
||||
super().__init__()
|
||||
self.submodule_1 = SubModule(hidden_dim, input_dim)
|
||||
setattr(self, 'submodule|2', SubModule(hidden_dim, hidden_dim))
|
||||
setattr(self, 'submodule/3', SubModule(hidden_dim, hidden_dim))
|
||||
|
@ -2597,11 +2597,14 @@ class AlgorithmSelectorCache(PersistentCache):
|
||||
"Exception %s for benchmark choice %s",
|
||||
e,
|
||||
futures[future],
|
||||
exc_info=True,
|
||||
exc_info=e,
|
||||
)
|
||||
else:
|
||||
log.error(
|
||||
"Exception %s for benchmark choice %s", e, futures[future]
|
||||
log.exception( # noqa: G202
|
||||
"Exception %s for benchmark choice %s",
|
||||
e,
|
||||
futures[future],
|
||||
exc_info=e,
|
||||
)
|
||||
else:
|
||||
counters["inductor"]["select_algorithm_num_precompiles"] += 1
|
||||
|
@ -17,12 +17,12 @@ def is_stdlib_module(module: str) -> bool:
|
||||
|
||||
|
||||
def _get_stdlib_modules():
|
||||
if sys.version_info.major == 3:
|
||||
if sys.version_info.major == 3: # noqa: UP036
|
||||
if sys.version_info.minor == 9:
|
||||
return stdlib3_9
|
||||
if sys.version_info.minor >= 10: # noqa: YTT204
|
||||
return sys.stdlib_module_names # type: ignore[attr-defined]
|
||||
elif sys.version_info.major > 3:
|
||||
elif sys.version_info.major > 3: # noqa: UP036
|
||||
return sys.stdlib_module_names # type: ignore[attr-defined]
|
||||
|
||||
raise RuntimeError(f"Unsupported Python version: {sys.version_info}")
|
||||
|
Reference in New Issue
Block a user