neulab / ExplainaBoard

Interpretable Evaluation for AI Systems
MIT License
360 stars 36 forks source link

Lint missing '__future__ import annotations' via pre-commit and CI #570

Closed tetsuok closed 1 year ago

tetsuok commented 1 year ago

Overview

This PR introduces a flake8 plugin, flake8-future-import to automatically check missing __future__ import annotations.

Details

Currently, some code requires __future__ import annotations to use type annotation (e.g., PEP 604 available in Python 3.10) across Python 3.8, 3.9, and 3.10. It's more consistent to add the import for every Python file except third party, but it's easy to forget to add it without CI. That's where flake8-future-import comes in.

flake8-future-import enables flake8 to check the import automatically. This PR adds a new pre-commit hook dedicated to the plugin to exclude third-party code from the check. I added error codes to the config file to silence flake8 so that flake8 doesn't check features other than annotations, because the plugin is designed to lint all the features by default. Note that this PR bumps flake8 version to use the latest version of the plugin.

References

Blocked by