From 5dfdec92887c90f2cb9213a7dada046a5291c33e Mon Sep 17 00:00:00 2001 From: Adil Zouitine Date: Wed, 1 Oct 2025 13:19:51 +0200 Subject: [PATCH] feat(mypy): enable type checking for envs module and configure mypy settings in pyproject.toml (#2099) * feat(mypy): enable type checking for envs module and configure mypy settings in pyproject.toml * Add mypy configuration to check only the envs module. * Exclude examples, benchmarks, and tests from type checking. * Set ignore_missing_imports to true and follow_imports to skip. * chore: comment out mypy configuration in pyproject.toml and pre-commit-config.yaml * Comment out mypy settings to disable type checking for the envs module. * Update pre-commit configuration to reflect changes in mypy settings. --- .pre-commit-config.yaml | 3 ++- pyproject.toml | 45 +++++++++++++++++++++++++---------------- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f0901799..d15ecb8c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -90,7 +90,8 @@ repos: # rev: v1.16.0 # hooks: # - id: mypy - # args: [--python-version=3.10] + # args: [--config-file=pyproject.toml] + # exclude: ^(examples|benchmarks|tests)/ ##### Docstring Checks ##### # - repo: https://github.com/akaihola/darglint2 diff --git a/pyproject.toml b/pyproject.toml index 8bbd998a..e9655560 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -272,9 +272,19 @@ default.extend-ignore-identifiers-re = [ # [tool.mypy] # python_version = "3.10" +# Exclude examples, benchmarks, and tests from type checking +# exclude = [ +# "examples/", +# "benchmarks/", +# "tests/", +# ] +# Ignore missing imports for third-party libraries without stubs +# ignore_missing_imports = true +# Don't follow imports - only check files explicitly passed to mypy +# follow_imports = "skip" +# Gradual typing - start lenient, enable these as code improves: # warn_return_any = true # warn_unused_configs = true -# ignore_missing_imports = false # strict = true # disallow_untyped_defs = true # disallow_incomplete_defs = true @@ -282,68 +292,69 @@ default.extend-ignore-identifiers-re = [ # [[tool.mypy.overrides]] # module = "lerobot.utils.*" -# # include = "src/lerobot/utils/**/*.py" +# follow_imports = "normal" # [[tool.mypy.overrides]] # module = "lerobot.configs.*" -# # include = "src/lerobot/configs/**/*.py" +# follow_imports = "normal" # # Data processing modules # [[tool.mypy.overrides]] # module = "lerobot.processor.*" -# # include = "src/lerobot/processor/**/*.py" +# follow_imports = "normal" # [[tool.mypy.overrides]] # module = "lerobot.datasets.*" -# # include = "src/lerobot/datasets/**/*.py" +# follow_imports = "normal" # # Core machine learning modules # [[tool.mypy.overrides]] # module = "lerobot.optim.*" -# # include = "src/lerobot/optim/**/*.py" +# follow_imports = "normal" # [[tool.mypy.overrides]] # module = "lerobot.model.*" -# # include = "src/lerobot/model/**/*.py" +# follow_imports = "normal" # # Hardware interfaces # [[tool.mypy.overrides]] # module = "lerobot.cameras.*" -# # include = "src/lerobot/cameras/**/*.py" +# follow_imports = "normal" # [[tool.mypy.overrides]] # module = "lerobot.motors.*" -# # include = "src/lerobot/motors/**/*.py" +# follow_imports = "normal" # [[tool.mypy.overrides]] # module = "lerobot.robots.*" -# # include = "src/lerobot/robots/**/*.py" +# follow_imports = "normal" # [[tool.mypy.overrides]] # module = "lerobot.teleoperators.*" -# # include = "src/lerobot/teleoperators/**/*.py" +# follow_imports = "normal" # # Complex modules (enable these last) # [[tool.mypy.overrides]] # module = "lerobot.policies.*" -# # include = "src/lerobot/policies/**/*.py" +# follow_imports = "normal" # [[tool.mypy.overrides]] # module = "lerobot.rl.*" -# # include = "src/lerobot/rl/**/*.py" +# follow_imports = "normal" +# Currently checking only the envs module # [[tool.mypy.overrides]] # module = "lerobot.envs.*" -# # include = "src/lerobot/envs/**/*.py" +# follow_imports = "normal" # [[tool.mypy.overrides]] # module = "lerobot.async_inference.*" -# # include = "src/lerobot/async_inference/**/*.py" +# follow_imports = "normal" # [[tool.mypy.overrides]] # module = "lerobot.transport.*" -# # include = "src/lerobot/transport/**/*.py" +# follow_imports = "normal" # [[tool.mypy.overrides]] # module = "lerobot.scripts.*" -# # include = "src/lerobot/scripts/**/*.py" +# follow_imports = "normal"