Skip to content

Commit

Permalink
check black version; lint codebase (fix #322, fix #323)
Browse files Browse the repository at this point in the history
Summary: Pull Request resolved: fairinternal/detectron2#330

Differential Revision: D18525378

Pulled By: ppwwyyxx

fbshipit-source-id: 5b25d0a214cf41bac63157104d5dae5e7923b81d
  • Loading branch information
ppwwyyxx authored and facebook-github-bot committed Nov 15, 2019
1 parent 2ba15a1 commit dd5926a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
4 changes: 3 additions & 1 deletion detectron2/data/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def register(name, func):
func (callable): a callable which takes no arguments and returns a list of dicts.
"""
assert callable(func), "You must register a function with `DatasetCatalog.register`!"
assert name not in DatasetCatalog._REGISTERED, "Dataset '{}' is already registered!".format(name)
assert name not in DatasetCatalog._REGISTERED, "Dataset '{}' is already registered!".format(
name
)
DatasetCatalog._REGISTERED[name] = func

@staticmethod
Expand Down
6 changes: 4 additions & 2 deletions detectron2/engine/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,10 @@ def test(cls, cfg, model, evaluators=None):
try:
evaluator = cls.build_evaluator(cfg, dataset_name)
except NotImplementedError:
logger.warn("No evaluator found. Use `DefaultTrainer.test(evaluators=)`, "
"or implement its `build_evaluator` method.")
logger.warn(
"No evaluator found. Use `DefaultTrainer.test(evaluators=)`, "
"or implement its `build_evaluator` method."
)
results[dataset_name] = {}
continue
results_i = inference_on_dataset(model, data_loader, evaluator)
Expand Down
11 changes: 10 additions & 1 deletion dev/linter.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
#!/bin/bash -ev
#!/bin/bash -e
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved

# Run this script at project root by "./dev/linter.sh" before you commit

{
black --version | grep "19.3b0" > /dev/null
} || {
echo "Linter requires black==19.3b0 !"
exit 1
}

set -v

echo "Running isort ..."
isort -y --multi-line 3 --trailing-comma -sp . --skip datasets --skip docs --skip-glob '*/__init__.py' --atomic

Expand Down

0 comments on commit dd5926a

Please sign in to comment.