-
Notifications
You must be signed in to change notification settings - Fork 388
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
Use ruff #1994
Use ruff #1994
Changes from 17 commits
1178d77
e3256e0
da80104
4730e0c
4262342
d397f2a
b529a16
57db8c9
92848ed
6be2348
479725a
b104d32
9cc5051
bcbd3fa
372d06e
4737c84
f82d06f
717d39f
3b48fd6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,81 +9,6 @@ on: | |
- main | ||
- release** | ||
jobs: | ||
black: | ||
name: black | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone repo | ||
uses: actions/[email protected] | ||
- name: Set up python | ||
uses: actions/[email protected] | ||
with: | ||
python-version: '3.12' | ||
- name: Cache dependencies | ||
uses: actions/[email protected] | ||
id: cache | ||
with: | ||
path: ${{ env.pythonLocation }} | ||
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements/style.txt') }} | ||
- name: Install pip dependencies | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: | | ||
pip install -r requirements/style.txt | ||
pip cache purge | ||
- name: List pip dependencies | ||
run: pip list | ||
- name: Run black checks | ||
run: black . --check --diff | ||
flake8: | ||
name: flake8 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone repo | ||
uses: actions/[email protected] | ||
- name: Set up python | ||
uses: actions/[email protected] | ||
with: | ||
python-version: '3.12' | ||
- name: Cache dependencies | ||
uses: actions/[email protected] | ||
id: cache | ||
with: | ||
path: ${{ env.pythonLocation }} | ||
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements/style.txt') }} | ||
- name: Install pip dependencies | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: | | ||
pip install -r requirements/style.txt | ||
pip cache purge | ||
- name: List pip dependencies | ||
run: pip list | ||
- name: Run flake8 checks | ||
run: flake8 | ||
isort: | ||
name: isort | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone repo | ||
uses: actions/[email protected] | ||
- name: Set up python | ||
uses: actions/[email protected] | ||
with: | ||
python-version: '3.12' | ||
- name: Cache dependencies | ||
uses: actions/[email protected] | ||
id: cache | ||
with: | ||
path: ${{ env.pythonLocation }} | ||
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements/style.txt') }} | ||
- name: Install pip dependencies | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: | | ||
pip install -r requirements/style.txt | ||
pip cache purge | ||
- name: List pip dependencies | ||
run: pip list | ||
- name: Run isort checks | ||
run: isort . --check --diff | ||
mypy: | ||
name: mypy | ||
runs-on: ubuntu-latest | ||
|
@@ -99,18 +24,18 @@ jobs: | |
id: cache | ||
with: | ||
path: ${{ env.pythonLocation }} | ||
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements/required.txt') }}-${{ hashFiles('requirements/datasets.txt') }}-${{ hashFiles('requirements/tests.txt') }} | ||
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements/required.txt') }}-${{ hashFiles('requirements/datasets.txt') }}-${{ hashFiles('requirements/style.txt') }} | ||
- name: Install pip dependencies | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: | | ||
pip install -r requirements/required.txt -r requirements/datasets.txt -r requirements/tests.txt | ||
pip install -r requirements/required.txt -r requirements/datasets.txt -r requirements/style.txt | ||
pip cache purge | ||
- name: List pip dependencies | ||
run: pip list | ||
- name: Run mypy checks | ||
run: mypy . | ||
pydocstyle: | ||
name: pydocstyle | ||
ruff: | ||
name: ruff | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone repo | ||
|
@@ -132,33 +57,10 @@ jobs: | |
pip cache purge | ||
- name: List pip dependencies | ||
run: pip list | ||
- name: Run pydocstyle checks | ||
run: pydocstyle | ||
pyupgrade: | ||
name: pyupgrade | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clone repo | ||
uses: actions/[email protected] | ||
- name: Set up python | ||
uses: actions/[email protected] | ||
with: | ||
python-version: '3.12' | ||
- name: Cache dependencies | ||
uses: actions/[email protected] | ||
id: cache | ||
with: | ||
path: ${{ env.pythonLocation }} | ||
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements/style.txt') }} | ||
- name: Install pip dependencies | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
- name: Run ruff checks | ||
run: | | ||
pip install -r requirements/style.txt | ||
pip cache purge | ||
- name: List pip dependencies | ||
run: pip list | ||
- name: Run pyupgrade checks | ||
run: pyupgrade --py310-plus $(find . -path ./docs/src -prune -o -name "*.py" -print) | ||
ruff check --output-format=github --no-fix . | ||
isaaccorley marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ruff format --diff | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event.pull_request.head.label || github.head_ref || github.ref }} | ||
cancel-in-progress: true |
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. @ashnair1 can you test this? I'm wondering if we should remove mypy from pre-commit since it's so slow. We could also add the pre-commit action so that fixes are automatically applied to PRs. 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. Tested the file and it works fine. The slowness observed in the mypy hook occurs when there is a change in the additional dependencies as the isolated environment (where pre-commit runs the hooks) needs to be recreated. Once it's done, subsequent runs will be faster. Incorporating the On the flip side, having the mypy hook in the pre-commit config is useful for testing mypy when you don't have the latest versions of the libraries installed locally :) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,35 @@ | ||
repos: | ||
- repo: https://github.com/asottile/pyupgrade | ||
rev: v3.15.2 | ||
hooks: | ||
- id: pyupgrade | ||
args: [--py310-plus] | ||
|
||
- repo: https://github.com/pycqa/isort | ||
rev: 5.13.2 | ||
hooks: | ||
- id: isort | ||
additional_dependencies: ['.[colors]'] | ||
|
||
- repo: https://github.com/psf/black | ||
rev: 24.3.0 | ||
hooks: | ||
- id: black | ||
args: [--skip-magic-trailing-comma] | ||
|
||
- repo: https://github.com/pycqa/flake8.git | ||
rev: 7.0.0 | ||
hooks: | ||
- id: flake8 | ||
|
||
- repo: https://github.com/pycqa/pydocstyle | ||
rev: 6.3.0 | ||
hooks: | ||
- id: pydocstyle | ||
exclude: (tests|docs|experiments) | ||
additional_dependencies: ['.[toml]'] | ||
|
||
- repo: https://github.com/pre-commit/mirrors-mypy | ||
rev: v1.9.0 | ||
hooks: | ||
- id: mypy | ||
args: [--strict, --ignore-missing-imports, --show-error-codes] | ||
additional_dependencies: [einops>=0.6.0, kornia>=0.6.9, lightning>=2.0.9, matplotlib>=3.8.1, numpy>=1.22, pillow>=10.3.0, pytest>=6.1.2, pyvista>=0.34.2, scikit-image>=0.18.0, torch>=2.2, torchmetrics>=0.10] | ||
exclude: (build|data|dist|logo|logs|output)/ | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.3.7 | ||
hooks: | ||
- id: ruff | ||
types_or: | ||
- python | ||
- jupyter | ||
args: | ||
- --fix | ||
- id: ruff-format | ||
types_or: | ||
- python | ||
- jupyter | ||
- repo: https://github.com/pre-commit/mirrors-mypy | ||
rev: v1.9.0 | ||
hooks: | ||
- id: mypy | ||
args: | ||
- --strict | ||
- --ignore-missing-imports | ||
- --show-error-codes | ||
additional_dependencies: | ||
- einops>=0.6.0 | ||
- kornia>=0.6.9 | ||
- lightning>=2.0.9 | ||
- matplotlib>=3.8.1 | ||
- numpy>=1.22 | ||
- pillow>=10.3.0 | ||
- pytest>=6.1.2 | ||
- pyvista>=0.34.2 | ||
- scikit-image>=0.18.0 | ||
- torch>=2.2 | ||
- torchmetrics>=0.10 | ||
exclude: (build|data|dist|logo|logs|output)/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,8 +79,8 @@ | |
"from lightning.pytorch import Trainer\n", | ||
"\n", | ||
"from torchgeo.datamodules import EuroSAT100DataModule\n", | ||
"from torchgeo.trainers import ClassificationTask\n", | ||
"from torchgeo.models import ResNet18_Weights" | ||
"from torchgeo.models import ResNet18_Weights\n", | ||
"from torchgeo.trainers import ClassificationTask" | ||
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. Seems like isort and pyupgrade did not have Jupyter notebook support |
||
] | ||
}, | ||
{ | ||
|
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.
Got rid of pylance since we aren't currently using it anywhere else. Also, haven't tested this file since I don't know how to use it.