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

code quality: investigate Python type hints checkers #557

Open
VMois opened this issue Oct 21, 2021 · 4 comments
Open

code quality: investigate Python type hints checkers #557

VMois opened this issue Oct 21, 2021 · 4 comments
Assignees

Comments

@VMois
Copy link

VMois commented Oct 21, 2021

List of type checkers to investigate:

  1. Pyright, developed by Microsoft, detects types if no type annotations are present, is used in Pylance VS Code extension, which comes with the official Python extension.
  2. Mypy, the oldest type checker for Python, uses type annotations;
  3. Pytype, developed by Google, detects types if no type annotations are present;
  4. Pyre, developed by FB and Instagram, detects types, both type checker and static code analysis tool.

Criteria:

  1. support in the code editors: VS Code, PyCharm, ...;
  2. completeness of checks, what standards checker supports, how strict is checker;
  3. usage in GitHub actions.
@VMois VMois self-assigned this Oct 21, 2021
@tiborsimko
Copy link
Member

There are also other tools, for example pyanalyze.

@VMois
Copy link
Author

VMois commented Nov 17, 2021

Pyright has a nice getting started page. It follows several PEP conventions listed in the README.

Strictness can be controlled, some rules can be disabled, etc. similar to flake.

Support for VS Code, no direct support for PyCharm (but can be added as command-line tool).

Can be used in GitHub Actions in a similar way we use flake or pydocstyle.

@mvidalgarcia
Copy link
Member

The circular import I faced some time ago: https://stackoverflow.com/questions/39740632/python-type-hinting-without-cyclic-imports

I think it was happening when trying to use Model type hints in the utils module of reana-db, thus causing circular imports as models.py does some imports from utils.py.

@VMois
Copy link
Author

VMois commented Apr 7, 2022

As an addition to the list, we can also try - https://sonarsource.com/open-source-editions/ for both personal uses and, as an integration, with GitHub for reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants