这是indexloc提供的服务,不要输入任何密码
Skip to content

Make tainshou PEP 561/mypy compatible #892

@blazejosinski

Description

@blazejosinski
  • I have marked all applicable categories:
    • exception-raising bug
    • RL algorithm bug
    • documentation request (i.e. "X is missing from the documentation.")
    • new feature request
  • I have visited the source website
  • I have searched through the issue tracker for duplicates
  • I have mentioned version numbers, operating system and environment, where applicable:
0.5.0 0.28.1 1.13.1+cu117 1.24.3 3.9.7 (default, Jun 22 2023, 09:11:46) 
[GCC 9.4.0] linux

It seems that it is not possible to verify code using tianshou with mypy (when tianshou is installed as a library with pip)

I think that the reason for this is that tianshou doesn't communicate that it has the type annotations.
I was able to fix/hack it locally by adding a py.typed file, and probably this can be done on the library level as well. It should be very simple.

More details are in the pep 561

How to reproduce:

When I run mypy with a simplest possible tainshou code:

from tianshou.env import DummyVectorEnv

I receive the following error:

$ mypy mypytest.py 
mypytest.py:1: error: Skipping analyzing "tianshou.env": module is installed, but missing library stubs or py.typed marker  [import]
mypytest.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 1 source file)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementFeature that is not a new algorithm or an algorithm enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions