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 and flake8 #34

Merged
merged 22 commits into from
Jan 13, 2022
Merged

mypy and flake8 #34

merged 22 commits into from
Jan 13, 2022

Conversation

eggplants
Copy link
Contributor

@eggplants eggplants commented Jan 11, 2022

I followed flake8 and mypy --strict and fixed their errors. And also I introduced CI of flake8 and mypy.


$ git checkout main
$ mypy --strict tests scripts budoux
Found 87 errors in 11 files (checked 15 source files)
$ flake8 | wc -l
331
$ git checkout mypy
$ mypy --strict tests scripts budoux
Success: no issues found in 14 source files
$ flake8 | wc -l
0
$ grep -r 'type: ignore' | grep -v .git
tests/test_train.py:from scripts import train  # type: ignore # noqa (module hack)
$ grep -r noqa | grep -v .git
tests/test_parser.py:from budoux import parser  # noqa (module hack)
tests/test_feature_extractor.py:from budoux import feature_extractor, utils  # noqa (module hack)
tests/test_train.py:from scripts import train  # type: ignore # noqa (module hack)
tests/test_main.py:from budoux import main  # noqa (module hack)
scripts/context.py:from budoux import Parser, feature_extractor, utils  # noqa (unused)
scripts/train.py:           == True) - 1  # noqa (cannot replace `==` with `is`)

@eggplants
Copy link
Contributor Author

eggplants commented Jan 11, 2022

Type subscription in numpy (like np.floating[typing.Any]) is available on Python >=3.9.
https://github.com/numpy/numpy/blob/bb95cf015165bcf85f99ba0d28a7a6e727ca955b/numpy/core/src/multiarray/scalartypes.c.src#L1843-L1868
It is avoidable with replacement to inline type comment.

@tushuhei tushuhei self-requested a review January 13, 2022 01:53
Copy link
Member

@tushuhei tushuhei left a comment

Choose a reason for hiding this comment

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

Thank you for a lot of improvements to make our code typed! Let me ask some minor fixes.

.github/workflows/style-check.yml Outdated Show resolved Hide resolved
.github/workflows/style-check.yml Outdated Show resolved Hide resolved
.github/workflows/style-check.yml Outdated Show resolved Hide resolved
budoux/feature_extractor.py Outdated Show resolved Hide resolved
budoux/feature_extractor.py Outdated Show resolved Hide resolved
scripts/train.py Outdated Show resolved Hide resolved
@eggplants eggplants requested a review from tushuhei January 13, 2022 09:22
budoux/feature_extractor.py Outdated Show resolved Hide resolved
@eggplants eggplants requested a review from tushuhei January 13, 2022 09:36
Copy link
Member

@tushuhei tushuhei left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you so much!

@tushuhei tushuhei merged commit 46ea894 into google:main Jan 13, 2022
@eggplants eggplants deleted the mypy branch January 13, 2022 09:41
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