Skip to content

Commit e779a30

Browse files
justinchubypytorchmergebot
authored andcommitted
[BE] Fix SIM109 compare-with-tuple (pytorch#100337)
Use {replacement} instead of multiple equality comparisons Pull Request resolved: pytorch#100337 Approved by: https://github.com/Skylion007
1 parent 01abbfb commit e779a30

File tree

6 files changed

+6
-10
lines changed

6 files changed

+6
-10
lines changed

.flake8

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ignore =
2020
# these ignores are from flake8-logging-format; please fix!
2121
G100,G101,G200,G201,G202
2222
# these ignores are from flake8-simplify. please fix or ignore with commented reason
23-
SIM105,SIM108,SIM109,SIM110,SIM111,SIM113,SIM114,SIM115,SIM116,SIM117,SIM118,SIM119,SIM12,
23+
SIM105,SIM108,SIM110,SIM111,SIM113,SIM114,SIM115,SIM116,SIM117,SIM118,SIM119,SIM12,
2424
# flake8-simplify code styles
2525
SIM102,SIM103,SIM106,SIM112,
2626
per-file-ignores =

.github/scripts/filter_test_configs.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,7 @@ def remove_disabled_jobs(
250250
)
251251
return filtered_test_matrix
252252

253-
if (
254-
disabled_job_cfg == TEST_JOB_NAME
255-
or disabled_job_cfg == BUILD_AND_TEST_JOB_NAME
256-
):
253+
if disabled_job_cfg in (TEST_JOB_NAME, BUILD_AND_TEST_JOB_NAME):
257254
print(
258255
f"Issue {disabled_url} created by {author} has disabled all the test jobs for {workflow} / {job_name}"
259256
)
@@ -263,7 +260,7 @@ def remove_disabled_jobs(
263260
if m:
264261
disabled_job = m.group("job")
265262
# Make sure that the job name is a valid test job name first before checking the config
266-
if disabled_job == TEST_JOB_NAME or disabled_job == BUILD_AND_TEST_JOB_NAME:
263+
if disabled_job in (TEST_JOB_NAME, BUILD_AND_TEST_JOB_NAME):
267264
disabled_cfg = m.group("cfg")
268265
# Remove the disabled config from the test matrix
269266
filtered_test_matrix["include"] = [

pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ ignore = [
4848
"SIM102", "SIM103", "SIM112", # flake8-simplify code styles
4949
"SIM105", # these ignores are from flake8-simplify. please fix or ignore with commented reason
5050
"SIM108",
51-
"SIM109",
5251
"SIM110",
5352
"SIM114", # Combine `if` branches using logical `or` operator
5453
"SIM115",

test/functorch/test_vmap.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5018,7 +5018,7 @@ def backward(_, grad_input):
50185018
def f(x):
50195019
return Test.apply(x)
50205020

5021-
if transform == grad or transform == grad_and_value:
5021+
if transform in (grad, grad_and_value):
50225022
input = torch.tensor(4.)
50235023
else:
50245024
input = torch.randn(5)

torch/_meta_registrations.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1625,7 +1625,7 @@ def is_fast_path(src, scale, output, padding_idx):
16251625
max_indices = indices.new_empty(0)
16261626
else:
16271627
fast_path_sum = is_fast_path(weight, per_sample_weights, output, padding_idx)
1628-
if mode == MODE_MEAN or mode == MODE_MAX or not fast_path_sum:
1628+
if mode in (MODE_MEAN, MODE_MAX) or not fast_path_sum:
16291629
offset2bag = offsets.new_empty(indices.size(0))
16301630
else:
16311631
offset2bag = offsets.new_empty(0)

torch/utils/hipify/hipify_python.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def grab_method_and_template(in_kernel):
278278
char = string[i]
279279

280280
# Handle Templating Arguments
281-
if status == START or status == AT_TEMPLATE:
281+
if status in (START, AT_TEMPLATE):
282282
if char == ">":
283283
if status == START:
284284
status = AT_TEMPLATE

0 commit comments

Comments
 (0)