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

Mypy type checking #81

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Mypy type checking #81

wants to merge 3 commits into from

Conversation

JohnGiorgi
Copy link
Contributor

@JohnGiorgi JohnGiorgi commented Nov 3, 2020

Overview

This PR sets up static type checking with MyPy as part of the CI/CD.

We still have 13 errors to solve:

geneeval/data.py:27: error: Incompatible return type for "__new__" (returns "PreprocessedData", but must return a subtype of "DatasetReader")
geneeval/classifiers/auto_classifier.py:9: error: Incompatible return type for "__new__" (returns "SupervisedClassifier", but must return a subtype of "AutoClassifier")
geneeval/engine.py:28: error: Incompatible types in assignment (expression has type "DatasetReader", variable has type "PreprocessedData")
geneeval/engine.py:30: error: Incompatible types in assignment (expression has type "AutoClassifier", variable has type "SupervisedClassifier")
tests/test_data.py:25: error: "DatasetReader" has no attribute "X_train"
tests/test_data.py:29: error: "DatasetReader" has no attribute "lb"
tests/test_data.py:29: error: "DatasetReader" has no attribute "y_train"
tests/test_data.py:36: error: "DatasetReader" has no attribute "X_test"
tests/test_data.py:37: error: "DatasetReader" has no attribute "lb"
tests/test_data.py:37: error: "DatasetReader" has no attribute "y_test"
tests/test_data.py:38: error: "DatasetReader" has no attribute "splits"
geneeval/fetcher/auto_fetcher.py:17: error: Incompatible return type for "__new__" (returns "Fetcher", but must return a subtype of "AutoFetcher")
geneeval/main.py:29: error: "AutoFetcher" has no attribute "fetch"
Found 13 errors in 6 files (checked 25 source files)

Most of these stem from our use of __new__, which appears to confuse mypy (see python/mypy#1021, python/mypy#794). I think it is because __new__ is supposed to return an instance of the class it is called from (or a subclass).

@JohnGiorgi JohnGiorgi marked this pull request as draft November 3, 2020 14:53
@JohnGiorgi JohnGiorgi self-assigned this Nov 3, 2020
@JohnGiorgi JohnGiorgi added enhancement New feature or request github_actions Pull requests that update Github_actions code labels Nov 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request github_actions Pull requests that update Github_actions code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant