forked from hedyorg/hedy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add
pylint
validation (hedyorg#440)
Add `pylint` into the standard set of tests. `pylint` is a style checker for Python. There are currently many style issues with the code base, so the suite of generic style checking has been disabled. Instead, we just check for obvious errors (misspellings of variables, etc) and throw an error if we find any. `pylint` found 3 in the current code base: - Two functions in a testing class that had the same name (so the 2nd function definition would overwrite the first). Removed the first test, since it was trying forms that were illegal at level 2 anyway, so could never work. - Illegal access of `.line`, `.column`, `.allowed` on an instance of something that's declared as `Exception`. Some investigation teaches that the only Lark exception that has all 3 of these attributes is `UnexpectedCharacters`, so changed to catching only that exception. - Some issues where we were assigning to fields of `g` (`g.prefix = ...`), which is allowed by pylint couldn't determine that from available declarations. Upgrading Flask from `1.1.1` -> `1.1.4` fixed that. Added scripts to do all of the validations we check: ``` build-tools/validate-python build-tools/validate-tests build-tools/validate-yaml ``` And a single script: ``` build-tools/validate ``` To run all validations. All validations are now run (individually) in the PR validation workflow script as well. Changing the workflow version of python to 3.9, since that's the version we're using on Heroku.
- Loading branch information
Showing
7 changed files
with
40 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
# Run all validation scripts | ||
set -eu | ||
scriptdir=$(cd $(dirname $0) && pwd) | ||
|
||
|
||
$scriptdir/validate-python | ||
$scriptdir/validate-tests | ||
$scriptdir/validate-yaml | ||
|
||
echo "Everything is great! 🍰" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
# Run pylint against all Python code | ||
set -eu | ||
scriptdir=$(cd $(dirname $0) && pwd) | ||
cd $scriptdir/.. | ||
|
||
# There are MANY pep8 style violations in the code base currently. | ||
# Let's just check for definite errors. | ||
pylint -j 0 \ | ||
--errors-only \ | ||
*.py tests |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
# Helper script to run unit tests | ||
set -eu | ||
scriptdir=$(cd $(dirname $0) && pwd) | ||
cd $scriptdir/.. | ||
|
||
# This is expected to run from the repo root | ||
python -m unittest discover -s tests |
This file contains 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
This file contains 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
This file contains 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