Skip to content

Commit cac2c95

Browse files
committed
Autofix and reformat with Ruff
Signed-off-by: Benjamin Gilbert <bgilbert@cs.cmu.edu>
1 parent e84d671 commit cac2c95

9 files changed

Lines changed: 18 additions & 25 deletions

File tree

doc/jekyll_fix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
}
3939
FILES = {
4040
# Added in Sphinx 5.0.0, scheduled to be removed in Sphinx 6
41-
'static/_sphinx_javascript_frameworks_compat.js': 'static/sphinx_javascript_frameworks_compat.js', # noqa: E501
41+
'static/_sphinx_javascript_frameworks_compat.js': 'static/sphinx_javascript_frameworks_compat.js',
4242
}
4343
REWRITE_EXTENSIONS = {'.html', '.js'}
4444

examples/deepzoom/deepzoom_multiserver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
from typing import TYPE_CHECKING, Any, Literal
3232
import zlib
3333

34-
from PIL import Image, ImageCms
3534
from flask import Flask, Response, abort, make_response, render_template, url_for
35+
from PIL import Image, ImageCms
3636

3737
if TYPE_CHECKING:
3838
# Python 3.10+
@@ -41,7 +41,7 @@
4141
if os.name == 'nt':
4242
_dll_path = os.getenv('OPENSLIDE_PATH')
4343
if _dll_path is not None:
44-
with os.add_dll_directory(_dll_path): # type: ignore[attr-defined,unused-ignore] # noqa: E501
44+
with os.add_dll_directory(_dll_path): # type: ignore[attr-defined,unused-ignore]
4545
import openslide
4646
else:
4747
import openslide

examples/deepzoom/deepzoom_server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
from unicodedata import normalize
3232
import zlib
3333

34-
from PIL import Image, ImageCms
3534
from flask import Flask, Response, abort, make_response, render_template, url_for
35+
from PIL import Image, ImageCms
3636

3737
if TYPE_CHECKING:
3838
# Python 3.10+
@@ -41,7 +41,7 @@
4141
if os.name == 'nt':
4242
_dll_path = os.getenv('OPENSLIDE_PATH')
4343
if _dll_path is not None:
44-
with os.add_dll_directory(_dll_path): # type: ignore[attr-defined,unused-ignore] # noqa: E501
44+
with os.add_dll_directory(_dll_path): # type: ignore[attr-defined,unused-ignore]
4545
import openslide
4646
else:
4747
import openslide

examples/deepzoom/deepzoom_tile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
if os.name == 'nt':
4848
_dll_path = os.getenv('OPENSLIDE_PATH')
4949
if _dll_path is not None:
50-
with os.add_dll_directory(_dll_path): # type: ignore[attr-defined,unused-ignore] # noqa: E501
50+
with os.add_dll_directory(_dll_path): # type: ignore[attr-defined,unused-ignore]
5151
import openslide
5252
else:
5353
import openslide

openslide/__init__.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,12 @@
3535
from openslide import lowlevel
3636

3737
# Re-exports for the benefit of library users
38-
from openslide._version import ( # noqa: F401 module-imported-but-unused
39-
__version__ as __version__,
40-
)
38+
from openslide._version import __version__ as __version__
39+
from openslide.lowlevel import OpenSlideError as OpenSlideError
4140
from openslide.lowlevel import (
4241
OpenSlideUnsupportedFormatError as OpenSlideUnsupportedFormatError,
4342
)
44-
from openslide.lowlevel import ( # noqa: F401 module-imported-but-unused
45-
OpenSlideVersionError as OpenSlideVersionError,
46-
)
47-
from openslide.lowlevel import OpenSlideError as OpenSlideError
43+
from openslide.lowlevel import OpenSlideVersionError as OpenSlideVersionError
4844

4945
__library_version__ = lowlevel.get_version()
5046

openslide/deepzoom.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,7 @@ def tiles(z_lim: int) -> int:
147147
)
148148

149149
def __repr__(self) -> str:
150-
return '{}({!r}, tile_size={!r}, overlap={!r}, limit_bounds={!r})'.format(
151-
self.__class__.__name__,
152-
self._osr,
153-
self._z_t_downsample,
154-
self._z_overlap,
155-
self._limit_bounds,
156-
)
150+
return f'{self.__class__.__name__}({self._osr!r}, tile_size={self._z_t_downsample!r}, overlap={self._z_overlap!r}, limit_bounds={self._limit_bounds!r})'
157151

158152
@property
159153
def level_count(self) -> int:

tests/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
# environment.
3030
_dll_path = os.getenv('OPENSLIDE_PATH')
3131
if _dll_path is not None:
32-
with os.add_dll_directory(_dll_path): # type: ignore[attr-defined,unused-ignore] # noqa: E501
32+
with os.add_dll_directory(_dll_path): # type: ignore[attr-defined,unused-ignore]
3333
import openslide # noqa: F401 module-imported-but-unused
3434

3535

tests/test_imageslide.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
import sys
2222
import unittest
2323

24-
from PIL import Image
2524
from common import file_path
25+
from PIL import Image
2626

2727
from openslide import ImageSlide, OpenSlideCache, OpenSlideError, lowlevel
2828

tests/test_openslide.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def test_create_cache(self) -> None:
4343
OpenSlideCache(4 << 20)
4444
self.assertRaises(ArgumentError, lambda: OpenSlideCache(-1))
4545
self.assertRaises(
46-
ArgumentError, lambda: OpenSlideCache(1.3) # type: ignore[arg-type]
46+
ArgumentError,
47+
lambda: OpenSlideCache(1.3), # type: ignore[arg-type]
4748
)
4849

4950

@@ -197,10 +198,12 @@ def test_set_cache(self) -> None:
197198
self.osr.set_cache(OpenSlideCache(64 << 10))
198199
self.assertEqual(self.osr.read_region((0, 0), 0, (400, 400)).size, (400, 400))
199200
self.assertRaises(
200-
TypeError, lambda: self.osr.set_cache(None) # type: ignore[arg-type]
201+
TypeError,
202+
lambda: self.osr.set_cache(None), # type: ignore[arg-type]
201203
)
202204
self.assertRaises(
203-
TypeError, lambda: self.osr.set_cache(3) # type: ignore[arg-type]
205+
TypeError,
206+
lambda: self.osr.set_cache(3), # type: ignore[arg-type]
204207
)
205208

206209

0 commit comments

Comments
 (0)