-
Notifications
You must be signed in to change notification settings - Fork 24
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
github: switch the python checker CI to use something that is maintained #14
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,24 +5,43 @@ name: Python | |
|
||
on: [push, pull_request] | ||
|
||
env: | ||
PYTHON_MIN: '3.7' | ||
# Reusable list of files to check -- parsed by bash, so does not support | ||
# whitespace. | ||
CHECK_FILES: lddtree.py pylint | ||
|
||
jobs: | ||
python: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
# NB: v1.4.0 covers Python 3.8. | ||
- uses: ricardochaves/python-lint@v1.4.0 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.x' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if we have control over versions, then we'd want to test a range of versions, starting with 3.6 if possible There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lint tools are usually python version agnostic: they'll provide the same style violation reports regardless of which python version the linter tool is installed for. The linter tools will, in some cases, implement different checks depending on version that you want to be compatible with. For example:
will tell mypy to type check against the 3.11 version of the standard library type checking stubs.
will tell pylint to not e.g. suggest using an f-string. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if that's reliable, that's fine, but it's also something we need in here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So to be clear, do you want:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for black/isort, we just need to tell them the min version to use as the syntax, so setting it to py3.6 alone is OK for pylint/mypy, yes, we'd want to check multiple versions. ideally it'd be 3.6 as the min, but if that's onerous, i'd be OK raising this to py3.8. but not beyond that atm. i guess i'd be OK with a min/max version, but seems like if we could do multiple versions, then it'd be easy to list them all inclusive. i.e. use github actions matrix settings. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i updated the requirement to python 3.8 now i also added requirements.txt files to test here |
||
- uses: actions/cache@v3 | ||
with: | ||
python-root-list: lddtree.py pylint | ||
eli-schwartz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
use-pylint: true | ||
use-pycodestyle: false | ||
use-flake8: false | ||
use-black: true | ||
use-mypy: true | ||
use-isort: true | ||
extra-pylint-options: "" | ||
extra-pycodestyle-options: "" | ||
extra-flake8-options: "" | ||
extra-black-options: "" | ||
extra-mypy-options: "" | ||
extra-isort-options: "" | ||
path: ~/.cache/pip | ||
key: lint-pip-${{ github.run_number }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. doesn't tying this to the run_number defeat the cache ? wouldn't we want to cache based on the python version and hash of the relevant inputs ? in this case, requirements*.txt ? |
||
restore-keys: lint-pip- | ||
- name: install dependencies | ||
run: | | ||
pkgs=( | ||
pylint mypy black 'isort[colors]' | ||
# mypy dependencies for following imported types. | ||
argcomplete | ||
) | ||
python -m pip install "${pkgs[@]}" | ||
- run: pylint --py-version=$PYTHON_MIN --output-format colorized $CHECK_FILES | ||
- run: | | ||
mypy $CHECK_FILES | ||
# Also check against the oldest supported python | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: period at the end |
||
mypy --python-version=$PYTHON_MIN $CHECK_FILES | ||
if: success() || failure() | ||
env: | ||
TERM: xterm-color | ||
MYPY_FORCE_COLOR: 1 | ||
- run: black --check --diff --color $CHECK_FILES | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's add |
||
if: success() || failure() | ||
- run: isort --check --diff --color $CHECK_FILES | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's add |
||
if: success() || failure() |
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 added a pyproject.toml file and moved tool versioning info to that, so i think we can drop this now