Skip to content

Commit

Permalink
GitHub Action to lint Python code with ruff
Browse files Browse the repository at this point in the history
[Ruff](https://beta.ruff.rs/) supports [over 500 lint rules](https://beta.ruff.rs/docs/rules) including bandit, isort, pylint, pyupgrade, and flake8 plus its plugins and is written in Rust for speed.

The `ruff` Action uses minimal steps to run in ~10 seconds, rapidly providing intuitive GitHub Annotations to contributors.

![image](https://user-images.githubusercontent.com/3709715/223758136-afc386d2-70aa-4eff-953a-2c2d82ceea23.png)
  • Loading branch information
cclauss committed Mar 24, 2023
1 parent 2709ff6 commit b1e8dbf
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: ruff
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: pip install --user ruff
- run: ruff --format=github .
7 changes: 3 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
# caution: testing won't work on windows

test-code:
py.test pydicom
pytest pydicom

test-doc:
pytest doc/*.rst

test-coverage:
rm -rf coverage .coverage
py.test pydicom --cov-report term-missing --cov=pydicom
pytest pydicom --cov-report term-missing --cov=pydicom

test: test-code test-doc

Expand All @@ -30,5 +30,4 @@ clean:
rm -rf examples/.ipynb_checkpoints

code-analysis:
flake8 pydicom | grep -v __init__ | grep -v external
pylint -E -i y pydicom/ -d E1103,E0611,E1101
ruff .
2 changes: 1 addition & 1 deletion pydicom/sr/_snomed_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -15076,4 +15076,4 @@
'R-FFFEA': '716940001',
'R0-0000B': '716941002',
'R-FFFD9': '717027004',
}
}
8 changes: 4 additions & 4 deletions pydicom/tests/test_JPEG_LS_transfer_syntax.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@


try:
import pydicom.pixel_data_handlers.numpy_handler as numpy_handler
from pydicom.pixel_data_handlers import numpy_handler
HAVE_NP = numpy_handler.HAVE_NP
except ImportError:
HAVE_NP = False
numpy_handler = None

try:
import pydicom.pixel_data_handlers.pillow_handler as pillow_handler
from pydicom.pixel_data_handlers import pillow_handler
HAVE_PIL = pillow_handler.HAVE_PIL
HAVE_JPEG = pillow_handler.HAVE_JPEG
HAVE_JPEG2K = pillow_handler.HAVE_JPEG2K
Expand All @@ -36,14 +36,14 @@
HAVE_JPEG2K = False

try:
import pydicom.pixel_data_handlers.jpeg_ls_handler as jpeg_ls_handler
from pydicom.pixel_data_handlers import jpeg_ls_handler
HAVE_JPEGLS = jpeg_ls_handler.HAVE_JPEGLS
except ImportError:
jpeg_ls_handler = None
HAVE_JPEGLS = False

try:
import pydicom.pixel_data_handlers.gdcm_handler as gdcm_handler
from pydicom.pixel_data_handlers import gdcm_handler
HAVE_GDCM = gdcm_handler.HAVE_GDCM
except ImportError:
gdcm_handler = None
Expand Down
1 change: 0 additions & 1 deletion pydicom/util/leanread.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def __exit__(
) -> Optional[bool]:
self.fobj.close()

return None

def __iter__(self) -> Iterator[_ElementType]:
# Need the transfer_syntax later
Expand Down

0 comments on commit b1e8dbf

Please sign in to comment.