Skip to content

[Feature Request] Enable type annotation checker #47

@XuehaiPan

Description

@XuehaiPan

Required prerequisites

Motivation

I found many wrong type annotations in the codebase after a quick glance.

https://github.com/OmniSafeAI/safety-gymnasium/blob/c1c598ea45f23535405f9941695800bae41d3a4a/safety_gymnasium/utils/random_generator.py#L170-L173

-def constrain_placement(self, placement: dict, keepout: float) -> tuple[float]:
+def constrain_placement(self, placement: list[float], keepout: float) -> tuple[float, float, float, float]:

Also, mypy reports:

-Found 129 errors in 13 files (checked 82 source files)

We should enable a CI workflow to check type annotations are correct.

Solution

Update type annotations and enable mypy in the CI workflow. And remove:

https://github.com/OmniSafeAI/safety-gymnasium/blob/c1c598ea45f23535405f9941695800bae41d3a4a/pyproject.toml#L150-L156

Alternatives

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions