Skip to content

Commit

Permalink
Add pre-commit hook to ban blanket noqa (facebookresearch#746)
Browse files Browse the repository at this point in the history
  • Loading branch information
Skylion007 authored Oct 7, 2021
1 parent a0838cc commit 548f844
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ repos:
- id: pretty-format-toml
args: [--autofix]

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0 # Use the ref you want to point at
hooks:
- id: python-check-blanket-noqa
# TODO: Add blanket type ignore check as well

- repo: https://github.com/timothycrosley/isort
rev: 5.8.0
hooks:
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorials/colabs/Habitat_Lab.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"# Change to do something like this maybe: https://stackoverflow.com/a/41432704\n",
"def display_sample(\n",
" rgb_obs, semantic_obs=np.array([]), depth_obs=np.array([])\n",
"): # noqa B006\n",
"): # noqa: B006\n",
" from habitat_sim.utils.common import d3_40_colors_rgb\n",
"\n",
" rgb_img = Image.fromarray(rgb_obs, mode=\"RGB\")\n",
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorials/nb_python/Habitat_Lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
# Change to do something like this maybe: https://stackoverflow.com/a/41432704
def display_sample(
rgb_obs, semantic_obs=np.array([]), depth_obs=np.array([])
): # noqa B006
): # noqa: B006
from habitat_sim.utils.common import d3_40_colors_rgb

rgb_img = Image.fromarray(rgb_obs, mode="RGB")
Expand Down
4 changes: 2 additions & 2 deletions habitat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
from habitat.core.embodied_task import EmbodiedTask, Measure, Measurements
from habitat.core.env import Env, RLEnv
from habitat.core.logging import logger
from habitat.core.registry import registry # noqa : F401
from habitat.core.registry import registry # noqa: F401
from habitat.core.simulator import Sensor, SensorSuite, SensorTypes, Simulator
from habitat.core.vector_env import ThreadedVectorEnv, VectorEnv
from habitat.datasets import make_dataset
from habitat.version import VERSION as __version__ # noqa
from habitat.version import VERSION as __version__ # noqa: F401

__all__ = [
"Agent",
Expand Down
2 changes: 1 addition & 1 deletion habitat/core/vector_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def __init__(
(
self._connection_read_fns,
self._connection_write_fns,
) = self._spawn_workers( # noqa
) = self._spawn_workers(
env_fn_args,
make_env_fn,
workers_ignore_signals=workers_ignore_signals,
Expand Down
2 changes: 1 addition & 1 deletion habitat/tasks/nav/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

def _try_register_nav_task():
try:
from habitat.tasks.nav.nav import NavigationTask # noqa
from habitat.tasks.nav.nav import NavigationTask # noqa: F401
except ImportError as e:
navtask_import_error = e

Expand Down
2 changes: 1 addition & 1 deletion habitat/tasks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# LICENSE file in the root directory of this source tree.

import numpy as np
import quaternion # noqa # pylint: disable=unused-import
import quaternion # noqa: F401 # pylint: disable=unused-import


def quaternion_to_rotation(q_r, q_i, q_j, q_k):
Expand Down
2 changes: 1 addition & 1 deletion habitat_baselines/il/data/nav_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ def map_dataset_sample(self, x: Dict) -> Tuple:
and (
self.max_controller_actions == 1
or controller_out[
i - self.max_controller_actions + 1 : i # noqa
i - self.max_controller_actions + 1 : i
].sum()
== self.max_controller_actions - 1
)
Expand Down

0 comments on commit 548f844

Please sign in to comment.