-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add lint GH action, switch ruff, require py3.9.
- Loading branch information
Showing
2 changed files
with
101 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Linting | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: [main, dev] | ||
workflow_dispatch: | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
pre-commit: | ||
name: ruff and hooks. | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.9' | ||
- uses: pre-commit/[email protected] | ||
with: | ||
extra_args: --all-files --show-diff-on-failure | ||
|
||
pyright: | ||
name: Check types | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
lfs: false | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.9' | ||
|
||
- name: Cache dependency | ||
id: cache-dependencies | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.cache/pip | ||
key: ubuntu-latest-pip-3.9 | ||
restore-keys: | | ||
ubuntu-latest-pip- | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install torch --extra-index-url https://download.pytorch.org/whl/cpu | ||
pip install -e .[dev] | ||
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 |
---|---|---|
|
@@ -11,7 +11,7 @@ authors = [ | |
{ name = "Jan-Matthis Lueckmann", email = "[email protected]" }, | ||
{ name = "Jan Boelts", email = "[email protected]" } | ||
] | ||
requires-python = ">=3.7" | ||
requires-python = ">=3.9" | ||
license = { text = "MIT" } | ||
classifiers = [ | ||
"License :: OSI Approved :: MIT License", | ||
|
@@ -47,10 +47,12 @@ dependencies = [ | |
|
||
[project.optional-dependencies] | ||
dev = [ | ||
"autoflake", | ||
"black", | ||
"flake8", | ||
"isort>5.0.0", | ||
# Lint | ||
"pre-commit == 4.0.1", | ||
"pyyaml", | ||
"pyright", | ||
"ruff==0.9.0", | ||
# Test | ||
"ipdb", | ||
"pytest", | ||
"pytest-plt", | ||
|
@@ -69,14 +71,41 @@ exclude = ["tests", "tests.*"] | |
[tool.setuptools.dynamic] | ||
version = {attr = "sbibm.__version__.__version__"} | ||
|
||
[tool.flake8] | ||
exclude = ["docs", "build", "dist", ".ipynb_checkpoints", ".git", "third_party"] | ||
max-line-length = 119 | ||
extend-ignore = ["W503", "E203"] | ||
# ruff configs | ||
[tool.ruff] | ||
extend-include = ["*.ipynb"] | ||
line-length = 88 | ||
|
||
[tool.isort] | ||
profile = "black" | ||
[tool.ruff.lint] | ||
# pycodestyle, Pyflakes, pyupgrade, flake8-bugbear, flake8-simplify, isort | ||
select = ["E", "F", "W", "B", "SIM", "I"] | ||
ignore = [ | ||
"E731", # allow naming lambda functions. | ||
"B008", # allow function calls in default args. | ||
] | ||
|
||
[tool.ruff.lint.extend-per-file-ignores] | ||
"__init__.py" = ["E402", "F401", "F403"] # allow unused imports and undefined names | ||
"test_*.py" = ["F403", "F405"] | ||
"tutorials/*.ipynb" = ["E501"] # allow long lines in notebooks | ||
|
||
[tool.ruff.lint.isort] | ||
case-sensitive = true | ||
lines-between-types = 0 # like isort default. | ||
relative-imports-order = "furthest-to-closest" # like isort default. | ||
known-first-party = ["sbibm", "tests"] | ||
|
||
[tool.ruff.format] | ||
exclude = ["*.ipynb"] | ||
preview = true | ||
quote-style = "preserve" | ||
|
||
# Pytest configuration | ||
[tool.pytest.ini_options] | ||
addopts = "--ignore=src/" | ||
plt_filename_drop = ["^--"] | ||
minversion = "6.0" | ||
addopts = "-ra -q" | ||
filterwarnings = [ | ||
"ignore::DeprecationWarning", | ||
"ignore::PendingDeprecationWarning" | ||
] | ||
testpaths = ["tests"] |