From 43a6e27c920c9d39c69015d6d49e583187fe2e59 Mon Sep 17 00:00:00 2001 From: Amit Parekh <7276308+amitkparekh@users.noreply.github.com> Date: Mon, 26 Aug 2024 11:39:29 +0100 Subject: [PATCH] ci: fix basedpyright lint errors --- pyproject.toml | 3 +++ src/cogelot/data/transforms/reword.py | 3 +-- src/cogelot/entrypoints/generate_training_data.py | 4 ++-- src/cogelot/environment/vima.py | 4 ++-- tests/conftest.py | 5 +++-- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f09665f1..0814f89d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -120,12 +120,15 @@ reportUnusedCallResult = false reportIncompatibleMethodOverride = false reportInvalidCast = false reportPrivateLocalImportUsage = false +reportUnsafeMultipleInheritance = false # Covered by ruff +reportUnusedParameter = false reportPrivateUsage = false reportUnusedImport = false reportPrivateImportUsage = false reportImplicitStringConcatenation = false reportDeprecated = false +reportMissingParameterType = false [tool.pytest.ini_options] testpaths = ["tests"] diff --git a/src/cogelot/data/transforms/reword.py b/src/cogelot/data/transforms/reword.py index a42d9c36..3683e379 100644 --- a/src/cogelot/data/transforms/reword.py +++ b/src/cogelot/data/transforms/reword.py @@ -101,8 +101,7 @@ def _consecutive_subsets(iterable: list[str]) -> list[str]: """Get all consecutive subsets of an iterable.""" subsets: list[tuple[str, ...]] = [ - beginning - for beginning, _, _ in more_itertools.windowed_complete(iterable, 1) # pyright: ignore[reportAssignmentType] + beginning for beginning, _, _ in more_itertools.windowed_complete(iterable, 1) ] # Add the full list onto the end subsets.append(tuple(iterable)) diff --git a/src/cogelot/entrypoints/generate_training_data.py b/src/cogelot/entrypoints/generate_training_data.py index 9c57ae79..d6be5dfd 100644 --- a/src/cogelot/entrypoints/generate_training_data.py +++ b/src/cogelot/entrypoints/generate_training_data.py @@ -85,7 +85,7 @@ def try_generate_episode(env: VIMAEnvBase, *, seed: int, only_keep_success: bool # Clip action to space oracle_action = { - k: np.clip(v, env.action_space[k].low, env.action_space[k].high) # type: ignore[reportIndexIssue] + k: np.clip(v, env.action_space[k].low, env.action_space[k].high) # pyright: ignore[reportIndexIssue] for k, v in oracle_action.items() } @@ -140,7 +140,7 @@ def save_episode(episode: EpisodeOutput, task_output_dir: Path, episode_idx: int # Save RGB images logger.debug(f"{output_dir}: Save RGB images") - rgb = obs.pop("rgb") # type: ignore[reportAttributeAccessError] + rgb = obs.pop("rgb") # pyright: ignore[reportAttributeAccessIssue,reportArgumentType] views = sorted(rgb.keys()) for view in views: frames = rgb[view] diff --git a/src/cogelot/environment/vima.py b/src/cogelot/environment/vima.py index f6bb8f9f..e8f8a763 100644 --- a/src/cogelot/environment/vima.py +++ b/src/cogelot/environment/vima.py @@ -38,7 +38,7 @@ def _find_prompt_renderer(env: Env[Any, Any]) -> PromptRenderer | None: if isinstance(env, PromptRenderer): return env if getattr(env, "env", None) is not None: - return _find_prompt_renderer(env.env) # type: ignore[attr-defined] + return _find_prompt_renderer(env.env) # pyright: ignore[reportAttributeAccessIssue] return None @@ -49,7 +49,7 @@ def get_task_kwargs(partition: Partition, task: Task) -> dict[str, Any] | None: return task_kwargs -class VIMAEnvironment(Wrapper): # type: ignore[type-arg] +class VIMAEnvironment(Wrapper): # pyright: ignore[reportMissingTypeArgument] """Environment wrapper for VIMA.""" env: VIMAEnvBase diff --git a/tests/conftest.py b/tests/conftest.py index dd58a1bc..bde8b2eb 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,16 +1,17 @@ import os from pathlib import Path +from typing import Never import pytest if os.getenv("_PYTEST_RAISE", "0") != "0": @pytest.hookimpl(tryfirst=True) - def pytest_exception_interact(call): # type: ignore[no-untyped-def] # noqa: ANN201, ANN001 + def pytest_exception_interact(call) -> Never: # noqa: ANN001 raise call.excinfo.value @pytest.hookimpl(tryfirst=True) - def pytest_internalerror(excinfo): # type: ignore[no-untyped-def] # noqa: ANN201, ANN001 + def pytest_internalerror(excinfo) -> Never: # noqa: ANN001 raise excinfo.value