feat(check-builtin-literals): implement builtin hook#890
Closed
lmmx wants to merge 1 commit intoj178:masterfrom
Closed
feat(check-builtin-literals): implement builtin hook#890lmmx wants to merge 1 commit intoj178:masterfrom
lmmx wants to merge 1 commit intoj178:masterfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #890 +/- ##
==========================================
- Coverage 90.02% 90.00% -0.02%
==========================================
Files 64 65 +1
Lines 11999 12222 +223
==========================================
+ Hits 10802 11001 +199
- Misses 1197 1221 +24 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
640b596 to
02dd3ed
Compare
34 tasks
6fcfb6e to
0b88169
Compare
2 tasks
5e43fa7 to
7eb1764
Compare
7eb1764 to
7a953dc
Compare
Owner
|
Similar to #884 (comment), I’m gonna close this one too. Thanks for your effort though! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
I picked this from the checklist of builtin hooks to support in #880 because Apache Airflow is using it, and it's the slowest unported running one of their hooks now.
This hook catches unnecessary builtin type constructor calls and suggests replacing them with their literal equivalents (
list()to[]etc.).Binary Size Change
+9.38% (.text: 16.0 MiB → 17.5 MiB)
Demo
Running this on
apache/airflow(who use prek!) takes quite a long time for a hook:louis 🌟 ~/tmp/airflow $ prek run -a --config .pre-commit-config.yaml --verbose Require literal syntax when initializing builtins........................Passed - hook id: check-builtin-literals - duration: 0.70spre-commit is about the same speed (4% faster)
louis 🌟 ~/tmp/airflow $ pre-commit run -a --config .pre-commit-config.yaml --verbose [WARNING] Unexpected key(s) present at root: minimum_prek_version Check that merge conflicts are not being committed.......................Passed - hook id: check-merge-conflict - duration: 0.08s Detect accidentally committed debug statements...........................Passed - hook id: debug-statements - duration: 0.79s Require literal syntax when initializing builtins........................Passed - hook id: check-builtin-literals - duration: 0.67sWith prek installed from this feature branch, it runs in exactly the same amount of time! And also fails!
I was confused why this gives different results, but they don't look wrong. In fact they seem to have just been missed by the Python version!
These are all valid hits:
As well as finding more hits, the Rust version finishes 15% faster, in just 0.60s 🎉