Conversation
…ore important issues first.
…uild distribution
- Add AntiPendulumObs type alias (tuple[int, ...] | np.ndarray) - Parameterize AntiPendulumEnv as gym.Env[AntiPendulumObs, int] - Parameterize ControlledCraneEnv as gym.Env[CraneObs, int] - Type crane parameter as Callable[..., Crane], wire as Wire - Replace MappingProxyType metadata with ClassVar[dict[str, object]] - Add TYPE_CHECKING imports for Callable, Crane, Wire, Line2D - Suppress py_crane stub gaps (cm_v, damping_time) with type: ignore
- Add type arguments to RewardWrapper, ActionWrapper, ObservationWrapper, Wrapper - Suppress gymnasium invariant type parameter errors with type: ignore[type-arg] - Suppress env arg-type and observation_space assignment errors
- Use AntiPendulumEnv for env parameter types instead of bare gym.Env - Add TYPE_CHECKING imports for AntiPendulumEnv, Callable, Sequence - Narrow obs to tuple[int, ...] with assert in q_agent call sites - Cast obs to np.asarray in ppo_agent and reinforce_agent for predict/sample - Fix variable shadowing in reinforce_agent (state -> state_tensor) - Remove unnecessary type: ignore comments on q_agent
- Type crane fixture as Callable[..., Crane] across all test modules - Add TYPE_CHECKING imports for Crane in test files - Cast np_random.integers to int in test_environment - Remove unnecessary type: ignore in test_ppo
- Add plans/add-type-hints/plan.md with phased execution plan - Update CHANGELOG.md Unreleased section with type-annotation entry - Pyright: 54 errors -> 0, 188 warnings -> 106
Provide minimal .pyi stubs for torch, torch.cuda, torch.nn, torch.optim, and torch.distributions.normal covering every symbol used by this project. stubPath stubs completely shadow inline package types, so all used submodules are explicitly re-exported. Pyright warnings: 106 -> 101 (-5 reportUnknownMemberType)
Provide minimal .pyi stubs for matplotlib.pyplot, matplotlib.axes, matplotlib._axes, matplotlib.figure, matplotlib.lines, and matplotlib.text. The _axes submodule is required because seaborn's return types resolve to matplotlib.axes._axes.Axes (the private submodule). Pyright warnings: 101 -> 79 (-22 reportUnknownMemberType)
Provide minimal .pyi stubs for PPO (load, learn, save, predict), make_vec_env, evaluate_policy, BaseCallback, and VecEnv. Pyright warnings: 79 -> 77 (-2 reportUnknownMemberType)
Remove 7 '# type: ignore' comments that became unnecessary after adding type stubs for torch, matplotlib, and stable-baselines3. Pyright informations: 15 -> 8 (-7 reportUnnecessaryTypeIgnoreComment)
Document the addition of type stubs and stale type-ignore removal. Include the implementation plan under plans/add-type-stubs/.
Add a `slow` pytest marker and apply it to `test_algorithm_strategies`. Both `_test.yml` and `_test_future.yml` workflows now pass `-m "not slow"` to pytest, deselecting slow tests in CI while keeping them available for local runs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…anup) into setup-and-maintenance-update branch Conflicts resolved by keeping setup-and-maintenance-update improvements (type annotations, numpy-style docstrings, logging, ruff compliance) and integrating the functional changes from main: - src/crane_controller/envs/controlled_crane_pendulum.py: apply dtype=np.float64 fix to continuous observation space (PR #3) - src/crane_controller/ppo_agent.py: integrate VecNormalize wrapping, fix dead-code bug in __init__ (inference_only flag), add _stats_path helper, save vecnorm stats in do_training, normalize obs in do_one_episode (PR #3) - scripts/train_ppo.py: add VecNormalize stats path log after training (PR #3) - tests/test_environment.py: add test_observation_space_dtype and test_observations_are_float (PR #3) - tests/test_ppo.py: add test_ppo_saves_vecnorm and test_ppo_vecnorm_updates (PR #3) - tests/conftest.py: change fixture scope from "session" to "package" for chdir and test_dir (PR #4) - tests/test_algorithm.py: accept auto-merged improvements from PR #4 - 8 stale test data files removed: anti-pendulum*.json, pendulum*.json, antipendulum.zip, ppo_AntiPendulumEnv.zip, interval.json (PR #4) Co-authored-by: ClaasRostock <48752696+ClaasRostock@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dnv-opensource/crane-controller/sessions/cf1c9c2f-6f40-4803-bb0f-4d566da48ded Co-authored-by: ClaasRostock <48752696+ClaasRostock@users.noreply.github.com>
Add plan.md files for: - fix-ruff-check - add-type-stubs - add-type-hints - fix-pyright - fix-mypy - reformat-existing-docstrings - add-missing-docstrings Agent-Logs-Url: https://github.com/dnv-opensource/crane-controller/sessions/163e9664-1e2f-468c-ac5f-6c97fb375c29 Co-authored-by: ClaasRostock <48752696+ClaasRostock@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dnv-opensource/crane-controller/sessions/eec0572e-8b3a-4e59-9e9b-5a6970e22a76 Co-authored-by: ClaasRostock <48752696+ClaasRostock@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dnv-opensource/crane-controller/sessions/1b943306-b02f-416a-b887-1f3abd36dd4f Co-authored-by: ClaasRostock <48752696+ClaasRostock@users.noreply.github.com>
Add isinstance(obs, np.ndarray) assertion in test_observations_are_float to narrow the AntiPendulumObs union type for pyright. Also removes extraneous blank lines in vec_env.pyi stub (ruff format).
Add isinstance assertion to narrow obs_rms from the union type dict[str, RunningMeanStd] | RunningMeanStd to RunningMeanStd.
Remove 13 # type: ignore comments that mypy no longer needs. Where pyright still requires suppression, convert to # pyright: ignore[rule]. Trim multi-code comments to keep only the still-needed error codes for mypy.
… learnings - fix-mypy/plan-draft: add --warn-unused-ignores to baseline, add pyright/mypy divergence guidance - fix-pyright/plan-draft: add mypy compat check when modifying ignores - add-type-stubs/plan-draft: add py.typed check constraint - .instructions.md: clarify # type: ignore vs # pyright: ignore semantics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changed
test_algorithm_strategiestest in GitHub workflow runs by adding aslowpytest marker and passing-m "not slow"in_test.ymland_test_future.ymltorch,matplotlib, andstable-baselines3ruff,pyright, andmypyFixed