Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type checking with mypy #331

Merged
merged 8 commits into from
Jan 2, 2023
Merged

Add type checking with mypy #331

merged 8 commits into from
Jan 2, 2023

Conversation

araffin
Copy link
Member

@araffin araffin commented Dec 23, 2022

Description

Counterpart of DLR-RM/stable-baselines3#1143

Motivation and Context

  • I have raised an issue to propose this change (required for new features and bug fixes)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (update in the documentation)

Checklist:

  • I've read the CONTRIBUTION guide (required)
  • I have updated the changelog accordingly (required).
  • My change requires a change to the documentation.
  • I have updated the tests accordingly (required for a bug fix or a new feature).
  • I have updated the documentation accordingly.
  • I have reformatted the code using make format (required)
  • I have checked the codestyle using make check-codestyle and make lint (required)
  • I have ensured make pytest and make type both pass. (required)

Note: we are using a maximum length of 127 characters per line

pytype -j auto ${LINT_PATHS} -d import-error

mypy:
mypy ${LINT_PATHS} --install-types --non-interactive
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also add --install-types --non-interactive in sb3 and sb3-contrib?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would only if it was needed.

@qgallouedec
Copy link
Collaborator

de67905: python/mypy#2427

qgallouedec
qgallouedec previously approved these changes Dec 24, 2022
@araffin
Copy link
Member Author

araffin commented Dec 24, 2022

It's weird, mypy check passes locally, I guess it has something to do with the way we package SB3 / SB3 contrib, maybe the stubs are missing? (locally I have them installed in editable mode)

@qgallouedec
Copy link
Collaborator

Same here

@araffin
Copy link
Member Author

araffin commented Dec 24, 2022

I can reproduce some errorr locally: pip install . vs pip install -e . (for sb3-contrib) with python 3.8 and latest mypy version.

and surprisingly, I've got more errors on my laptop that on the PC I used to do the PR.

@qgallouedec
Copy link
Collaborator

I can reproduce some errorr locally: pip install . vs pip install -e . (for sb3-contrib) with python 3.8 and latest mypy version.

and surprisingly, I've got more errors on my laptop that on the PC I used to do the PR.

Have you checked that the sb3/sb3-contrib versions match?

@araffin
Copy link
Member Author

araffin commented Dec 24, 2022

Have you checked that the sb3/sb3-contrib versions match?

yes, I'm using master version of both

@qgallouedec
Copy link
Collaborator

Same here

Actually, no, I just forgot to stage setup.cfg in my last commit.

@araffin araffin merged commit 1aa0644 into master Jan 2, 2023
@araffin araffin deleted the feat/mypy branch January 2, 2023 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants