forked from NationalGenomicsInfrastructure/scilifelab_epps
-
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.
Update GHA and pyproject to run more tools via ruff
- Loading branch information
Showing
2 changed files
with
27 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +1,58 @@ | ||
name: lint-code | ||
on: [push] | ||
jobs: | ||
# Use ruff to check for code style violations | ||
ruff-check: | ||
# Use ruff to check for code style violations | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.7" | ||
python-version: "3.10" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install ruff | ||
- name: ruff --> Check for style violations | ||
# The following style violations will be ignored | ||
# ============================================== | ||
# E402: Module level import not at top of file | ||
# E722: Do not use bare 'except' | ||
# E741: Ambiguous variable name | ||
run: ruff check --ignore E402,E722,E741 --unsafe-fixes . | ||
|
||
isort-check: | ||
# Use isort to check that imports are ordered according to best practice | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.7" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install isort | ||
- name: isort --> Check for best-practice sorting of imports | ||
run: isort --check . | ||
# Configured in pyproject.toml | ||
run: ruff check . | ||
|
||
# Use ruff to check code formatting | ||
ruff-format: | ||
# Use ruff to check code formatting | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.7" | ||
python-version: "3.10" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install ruff | ||
- name: ruff --> Check code formatting | ||
run: ruff format --check . | ||
|
||
# Use mypy for static type checking | ||
mypy-check: | ||
# Use mypy for static type checking | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.7" | ||
python-version: "3.10" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install mypy | ||
# Start by installing type stubs | ||
- name: mypy --> Install stubs | ||
run: echo -e "y" | mypy --install-types --ignore-missing-imports --follow-imports=skip --exclude build . || exit 0 | ||
run: echo -e "y" | mypy --install-types || exit 0 | ||
- name: mypy --> Static type checking | ||
run: mypy --ignore-missing-imports --follow-imports=skip --exclude build . | ||
|
||
pyupgrade-check: | ||
# Use pyupgrade to check for outdated syntax | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.7" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pyupgrade | ||
- name: pyupgrade --> Check for outdated syntax | ||
run: pyupgrade **/*.py | ||
# Configured in pyprojet.toml | ||
run: mypy **/*.py |
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 |
---|---|---|
@@ -1,21 +1,27 @@ | ||
title = "scilifelab_epps" | ||
|
||
[tool.ruff.lint] | ||
|
||
[tool.ruff.lint] | ||
select =[ | ||
# === Ruff defaults === | ||
# Ruff default rules | ||
# ------------------------------ | ||
"E4", # pycodestyle Imports | ||
"E7", # pycodestyle Statement | ||
"E9", # pycodestyle Runstyle | ||
"E7", # pycodestyle Statements | ||
"E9", # pycodestyle Runtime | ||
"F", # Pyflakes | ||
# === Additional === | ||
"I", # isort | ||
"UP", # pyupgrade | ||
] | ||
|
||
# Additional Comment | ||
# ------------------------------------------------------ | ||
"I", # isort Best-practice sorting of imports | ||
"UP", # pyupgrade Make sure syntax is up-to-date | ||
] | ||
ignore = [ | ||
"E402", # Module level import not at top of file | ||
"E722", # Do not use bare 'except' | ||
"E741", # Ambiguous variable name | ||
] | ||
] | ||
|
||
|
||
[tool.mypy] | ||
ignore_missing_imports = true | ||
follow_imports = 'skip' |