Skip to content

Commit

Permalink
[BE] Update flake8-comprehensions and adapt to rule C418 (pytorch#99178)
Browse files Browse the repository at this point in the history
Applies rule C418 and fixes all instances of it. Also updates flake8-comprehension

Pull Request resolved: pytorch#99178
Approved by: https://github.com/ezyang
  • Loading branch information
Skylion007 authored and pytorchmergebot committed Apr 15, 2023
1 parent 506bd05 commit 85f38b8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ignore =
# these ignores are from flake8-bugbear; please fix!
B007,B008,B017,B019,B020,B023,B024,B026,B027,B028,B903,B904,B905,B906,B907
# these ignores are from flake8-comprehensions; please fix!
C407
C407,C419,
# these ignores are from flake8-logging-format; please fix!
G100,G101,G200,G201,G202
# these ignores are from flake8-simplify. please fix or ignore with commented reason
Expand Down
2 changes: 1 addition & 1 deletion .lintrunner.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ init_command = [
'--dry-run={{DRYRUN}}',
'flake8==6.0.0',
'flake8-bugbear==23.3.23',
'flake8-comprehensions==3.11.1',
'flake8-comprehensions==3.12.0',
'flake8-executable==2.1.3',
'flake8-logging-format==0.9.0',
'flake8-pyi==23.3.1',
Expand Down
6 changes: 3 additions & 3 deletions test/jit/test_list_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def fn():

def test_dict_keyword_with_mapping(self):
def fn():
return dict({"foo" : 1, "bar" : 2, "baz" : 3})
return {"foo" : 1, "bar" : 2, "baz" : 3}

self.checkScript(fn, ())

Expand All @@ -275,7 +275,7 @@ def fn():

def test_dict_keyword_with_dict_comprehension(self):
def fn():
return dict({i: chr(i + 65) for i in range(4)})
return {i: chr(i + 65) for i in range(4)}

self.checkScript(fn, ())

Expand All @@ -287,7 +287,7 @@ def fn():

def test_dict_keyword_with_empty_dict_comprehension(self):
def fn():
return dict({})
return {}

self.checkScript(fn, ())

Expand Down
2 changes: 1 addition & 1 deletion test/test_datapipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2185,7 +2185,7 @@ def test_issubinstance(self):
self.assertFalse(issubinstance(d, t[int])) # type: ignore[index]

# dict
d = dict({'1': 1, '2': 2.})
d = {'1': 1, '2': 2.}
self.assertTrue(issubinstance(d, Dict))
self.assertTrue(issubinstance(d, Dict[str, T_co]))
self.assertFalse(issubinstance(d, Dict[str, int]))
Expand Down
8 changes: 4 additions & 4 deletions torch/ao/pruning/_mappings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

def get_static_sparse_quantized_mapping():
import torch.ao.nn.sparse
_static_sparse_quantized_mapping = dict({
_static_sparse_quantized_mapping = {
torch.nn.Linear: torch.ao.nn.sparse.quantized.Linear,
})
}
return _static_sparse_quantized_mapping

def get_dynamic_sparse_quantized_mapping():
import torch.ao.nn.sparse
_dynamic_sparse_quantized_mapping = dict({
_dynamic_sparse_quantized_mapping = {
torch.nn.Linear: torch.ao.nn.sparse.quantized.dynamic.Linear,
})
}
return _dynamic_sparse_quantized_mapping

0 comments on commit 85f38b8

Please sign in to comment.