Skip to content

Commit a66c952

Browse files
Thomas Polasekfacebook-github-bot
authored andcommitted
[codemod][pyfmt][ruff] Convert directory fbcode/faim to use the Ruff Formatter
Summary: Converts the directory specified to use the Ruff formatter in pyfmt ruff_dog If this diff causes merge conflicts when rebasing, please run `hg status -n -0 --change . -I '**/*.{py,pyi}' | xargs -0 arc pyfmt` on your diff, and amend any changes before rebasing onto latest. That should help reduce or eliminate any merge conflicts. allow-large-files Reviewed By: amyreese Differential Revision: D66013237 fbshipit-source-id: 01748bc342d50faffd0030e3d52b5f5f640c58ac
1 parent 753edc7 commit a66c952

File tree

23 files changed

+124
-108
lines changed

23 files changed

+124
-108
lines changed

mmf/common/registry.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
- Register a test reporter: ``@registry.register_test_reporter``
2929
- Register a pl datamodule: ``@registry.register_datamodule``
3030
"""
31+
3132
from mmf.utils.env import setup_imports
3233

3334

@@ -508,9 +509,9 @@ def wrap(iteration_strategy_cls):
508509
assert issubclass(
509510
iteration_strategy_cls, IterationStrategy
510511
), "All datamodules must inherit IterationStrategy class"
511-
cls.mapping["iteration_strategy_name_mapping"][
512-
name
513-
] = iteration_strategy_cls
512+
cls.mapping["iteration_strategy_name_mapping"][name] = (
513+
iteration_strategy_cls
514+
)
514515
return iteration_strategy_cls
515516

516517
return wrap

mmf/common/sample.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,9 @@ def __setattr__(self, key, value):
163163
def __getattr__(self, key):
164164
if key not in self:
165165
raise AttributeError(
166-
"Key {} not found in the SampleList. "
167-
"Valid choices are {}".format(key, self.fields())
166+
"Key {} not found in the SampleList. " "Valid choices are {}".format(
167+
key, self.fields()
168+
)
168169
)
169170
fields = self.keys()
170171

@@ -245,8 +246,9 @@ def get_fields(self, fields):
245246
for field in fields:
246247
if field not in current_fields:
247248
raise AttributeError(
248-
"{} not present in SampleList. "
249-
"Valid choices are {}".format(field, current_fields)
249+
"{} not present in SampleList. " "Valid choices are {}".format(
250+
field, current_fields
251+
)
250252
)
251253
return_list.add_field(field, self[field])
252254

@@ -396,7 +398,7 @@ def to_dict(self) -> Dict[str, Any]:
396398

397399

398400
def convert_batch_to_sample_list(
399-
batch: Union[SampleList, Dict[str, Any]]
401+
batch: Union[SampleList, Dict[str, Any]],
400402
) -> SampleList:
401403
# Create and return sample list with proper name
402404
# and type set if it is already not a sample list
@@ -405,9 +407,7 @@ def convert_batch_to_sample_list(
405407
if (
406408
# Check if batch is a list before checking batch[0]
407409
# or len as sometimes batch is already SampleList
408-
isinstance(batch, list)
409-
and len(batch) == 1
410-
and isinstance(batch[0], SampleList)
410+
isinstance(batch, list) and len(batch) == 1 and isinstance(batch[0], SampleList)
411411
):
412412
sample_list = batch[0]
413413
elif not isinstance(batch, SampleList):

mmf/datasets/base_dataset_builder.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def build(self, config, dataset_type, *args, **kwargs):
3434
3535
.. _here: https://github.com/facebookresearch/mmf/blob/main/mmf/datasets/vqa/vqa2/builder.py
3636
"""
37+
3738
import uuid
3839
from typing import Optional
3940

mmf/datasets/builders/charades/_utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,9 @@ def get_clip(self, idx):
124124
"""
125125
if idx >= self.num_clips():
126126
raise IndexError(
127-
"Index {} out of range "
128-
"({} number of clips)".format(idx, self.num_clips())
127+
"Index {} out of range " "({} number of clips)".format(
128+
idx, self.num_clips()
129+
)
129130
)
130131
video_path = self.video_paths[idx]
131132
clip_pts = self.clips[idx]

mmf/datasets/multi_dataset_loader.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
MultiDatasetLoader class is used by DatasetLoader class to load multiple datasets
44
and more granular
55
"""
6+
67
import logging
78
import warnings
89
from typing import Dict, Iterator

mmf/datasets/processors/frcnn_processor.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
# Copyright (c) Facebook, Inc. and its affiliates.
22

33
"""
4-
coding=utf-8
5-
Copyright 2018, Antonio Mendoza Hao Tan, Mohit Bansal
6-
Adapted From Facebook Inc, Detectron2
7-
Licensed under the Apache License, Version 2.0 (the "License");
8-
you may not use this file except in compliance with the License.
9-
You may obtain a copy of the License at
10-
http://www.apache.org/licenses/LICENSE-2.0
11-
Unless required by applicable law or agreed to in writing, software
12-
distributed under the License is distributed on an "AS IS" BASIS,
13-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
See the License for the specific language governing permissions and
15-
limitations under the License.import copy
16-
"""
4+
coding=utf-8
5+
Copyright 2018, Antonio Mendoza Hao Tan, Mohit Bansal
6+
Adapted From Facebook Inc, Detectron2
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.import copy
16+
"""
17+
1718
import os
1819
import sys
1920
from dataclasses import dataclass

mmf/models/base_model.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ def forward(self, sample_list):
3939
return {"scores": scores}
4040
"""
4141

42-
4342
import collections
4443
import logging
4544
import warnings

mmf/models/frcnn.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
# Copyright (c) Facebook, Inc. and its affiliates.
22

33
"""
4-
coding=utf-8
5-
Copyright 2018, Antonio Mendoza Hao Tan, Mohit Bansal
6-
Adapted From Facebook Inc, Detectron2 && Huggingface Co.
7-
8-
Licensed under the Apache License, Version 2.0 (the "License");
9-
you may not use this file except in compliance with the License.
10-
You may obtain a copy of the License at
11-
12-
http://www.apache.org/licenses/LICENSE-2.0
13-
14-
Unless required by applicable law or agreed to in writing, software
15-
distributed under the License is distributed on an "AS IS" BASIS,
16-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17-
See the License for the specific language governing permissions and
18-
limitations under the License.import copy
19-
"""
4+
coding=utf-8
5+
Copyright 2018, Antonio Mendoza Hao Tan, Mohit Bansal
6+
Adapted From Facebook Inc, Detectron2 && Huggingface Co.
7+
8+
Licensed under the Apache License, Version 2.0 (the "License");
9+
you may not use this file except in compliance with the License.
10+
You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing, software
15+
distributed under the License is distributed on an "AS IS" BASIS,
16+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
See the License for the specific language governing permissions and
18+
limitations under the License.import copy
19+
"""
2020

2121
from typing import List
2222

mmf/models/mmf_bert.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,9 @@ def forward(self, sample_list):
382382
seq_relationship_score.contiguous().view(-1, 2),
383383
is_random_next.contiguous().view(-1),
384384
)
385-
output_dict["losses"][
386-
loss_key + "/next_sentence_loss"
387-
] = next_sentence_loss
385+
output_dict["losses"][loss_key + "/next_sentence_loss"] = (
386+
next_sentence_loss
387+
)
388388
return output_dict
389389
elif (
390390
"vqa" in self.config.training_head_type

mmf/models/unit/backbone.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""
66
Backbone modules.
77
"""
8+
89
import math
910
from collections import OrderedDict
1011

0 commit comments

Comments
 (0)