-
Notifications
You must be signed in to change notification settings - Fork 397
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
feat: Add mypy type checking #4863
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Skipped Deployments
|
Docker builds report
|
Uffizzi Ephemeral Environment
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4863 +/- ##
========================================
Coverage 97.38% 97.39%
========================================
Files 1189 1191 +2
Lines 41420 41526 +106
========================================
+ Hits 40338 40444 +106
Misses 1082 1082 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a decent enough solution to me but I have some general questions:
-
What happens if we (perhaps inadvertently) resolve an existing issue. Based on the logic in your script, I guess we wouldn't know about it, right? Because we're just seeing what's left after we subtract the original errors from the new ones which wouldn't tell us anything about any that we've solved. It would obviously be great to incentivise resolving existing issues where we can.
-
This approach works fine I guess, but another solution would have been to just add all of the distinct files into the exclude. Then every new file would need to conform to mypy, but changes to existing files wouldn't. I'm not sure how we could incentivise fixing the existing errors. (Note: I'm certainly not suggesting this is a better option, I'm just playing devil's advocate).
.pre-commit-config.yaml
Outdated
hooks: | ||
- id: mypy-check | ||
name: mypy check | ||
entry: bash -c "cd api && poetry run python scripts/mypy_check.py" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I was looking at similar functionality yesterday (see here) , I am somewhat intrigued by this.
My understanding of pre-commit is that it passes the modified files into the command specified in entry
, so the resulting command would look something like:
bash -c "cd api && poetry run python scripts/mypy_check.py" file1.py file2.py
... which I would expect to just not work at all, or at least throw some sort of error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zachaysan I'm not sure the latest changes make any reference to this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've altered the script to run the files one at a time. I had to use git diff
to list the target files of the commit because no matter what I tried to pass into the bash script it just wouldn't run with the automatic listed files. The good news is that we are now doing a mypy
check on only the committed files.
c9b44d4
to
c3e7907
Compare
…b.com:Flagsmith/flagsmith into feat/add_mypy_type_checking
Changes
This adds mypy type checking. Existing failures have been grandfathered in and a helper script is run to compare failures against the predefined list. Mypy was also added into the
pre-commit
config and will run on any commits to python code.How did you test this code?
I altered the predefined mypy list and saw a failure crop up when running
pre-commit
.