@@ -93,7 +93,7 @@ OpenSlide objects
9393
9494.. module :: openslide
9595
96- .. class :: OpenSlide(filename)
96+ .. class :: OpenSlide(filename: str | bytes | ~os.PathLike[typing.Any] )
9797
9898 An open whole-slide image.
9999
@@ -106,20 +106,20 @@ OpenSlide objects
106106 The object may be used as a context manager, in which case it will be
107107 closed upon exiting the context.
108108
109- :param str filename: the file to open
109+ :param filename: the file to open
110110 :raises OpenSlideUnsupportedFormatError: if the file is not recognized by
111111 OpenSlide
112112 :raises OpenSlideError: if the file is recognized but an error occurred
113113
114- .. classmethod :: detect_format(filename)
114+ .. classmethod :: detect_format(filename: str | bytes | ~os.PathLike[typing.Any]) -> str | None
115115
116116 Return a string describing the format vendor of the specified file.
117117 This string is also accessible via the :data: `PROPERTY_NAME_VENDOR `
118118 property.
119119
120120 If the file is not recognized, return :obj: `None `.
121121
122- :param str filename: the file to examine
122+ :param filename: the file to examine
123123
124124 .. attribute :: level_count
125125
@@ -174,42 +174,42 @@ OpenSlide objects
174174
175175 :type: ~PIL.ImageCms.ImageCmsProfile | None
176176
177- .. method :: read_region(location, level, size)
177+ .. method :: read_region(location: tuple[int, int], level: int , size: tuple[int, int]) -> ~PIL.Image.Image
178178
179179 Return an RGBA :class: `Image <PIL.Image.Image> ` containing the
180180 contents of the specified region.
181181
182182 Unlike in the C interface, the image data is not premultiplied.
183183
184- :param tuple location: ``(x, y) `` tuple giving the top left pixel in
185- the level 0 reference frame
186- :param int level: the level number
187- :param tuple size: ``(width, height) `` tuple giving the region size
184+ :param location: ``(x, y) `` tuple giving the top left pixel in the
185+ level 0 reference frame
186+ :param level: the level number
187+ :param size: ``(width, height) `` tuple giving the region size
188188
189- .. method :: get_best_level_for_downsample(downsample)
189+ .. method :: get_best_level_for_downsample(downsample: float) -> int
190190
191191 Return the best level for displaying the given downsample.
192192
193- :param float downsample: the desired downsample factor
193+ :param downsample: the desired downsample factor
194194
195- .. method :: get_thumbnail(size)
195+ .. method :: get_thumbnail(size: tuple[int, int]) -> ~PIL.Image.Image
196196
197197 Return an :class: `Image <PIL.Image.Image> ` containing an RGB thumbnail
198198 of the slide.
199199
200- :param tuple size: the maximum size of the thumbnail as a
201- `` (width, height) `` tuple
200+ :param size: the maximum size of the thumbnail as a `` (width, height) ``
201+ tuple
202202
203- .. method :: set_cache(cache)
203+ .. method :: set_cache(cache: OpenSlideCache) -> None
204204
205205 Use the specified :class: `OpenSlideCache ` to store recently decoded
206206 slide tiles. By default, the :class: `OpenSlide ` has a private cache
207207 with a default size.
208208
209- :param OpenSlideCache cache: a cache object
209+ :param cache: a cache object
210210 :raises OpenSlideVersionError: if OpenSlide is older than version 4.0.0
211211
212- .. method :: close()
212+ .. method :: close() -> None
213213
214214 Close the OpenSlide object.
215215
@@ -266,15 +266,15 @@ reusing it for multiple slide regions::
266266Caching
267267-------
268268
269- .. class :: OpenSlideCache(capacity)
269+ .. class :: OpenSlideCache(capacity: int )
270270
271271 An in-memory tile cache.
272272
273273 Tile caches can be attached to one or more :class: `OpenSlide ` objects
274274 with :meth: `OpenSlide.set_cache ` to cache recently-decoded tiles. By
275275 default, each :class: `OpenSlide ` has its own cache with a default size.
276276
277- :param int capacity: the cache capacity in bytes
277+ :param capacity: the cache capacity in bytes
278278 :raises OpenSlideVersionError: if OpenSlide is older than version 4.0.0
279279
280280
@@ -366,20 +366,20 @@ Exceptions
366366Wrapping a Pillow Image
367367=======================
368368
369- .. class :: ImageSlide(file)
369+ .. class :: ImageSlide(file: str | bytes | ~os.PathLike[typing.Any] | ~PIL.Image.Image )
370370
371371 A wrapper around an :class: `Image <PIL.Image.Image> ` object that
372372 provides an :class: `OpenSlide `-compatible API.
373373
374374 :param file: a filename or :class: `Image <PIL.Image.Image> ` object
375375 :raises OSError: if the file cannot be opened
376376
377- .. function :: open_slide(filename)
377+ .. function :: open_slide(filename: str | bytes | ~os.PathLike[typing.Any]) -> OpenSlide | ImageSlide
378378
379379 Return an :class: `OpenSlide ` for whole-slide images and an
380380 :class: `ImageSlide ` for other types of images.
381381
382- :param str filename: the file to open
382+ :param filename: the file to open
383383 :raises OpenSlideError: if the file is recognized by OpenSlide but an
384384 error occurred
385385 :raises OSError: if the file is not recognized at all
@@ -397,19 +397,18 @@ Deep Zoom or a similar format.
397397
398398.. _`Deep Zoom` : https://docs.microsoft.com/en-us/previous-versions/windows/silverlight/dotnet-windows-silverlight/cc645050(v=vs.95)
399399
400- .. class :: DeepZoomGenerator(osr, tile_size= 254, overlap= 1, limit_bounds= False)
400+ .. class :: DeepZoomGenerator(osr: AbstractSlide , tile_size: int = 254, overlap: int = 1, limit_bounds: bool = False)
401401
402402 A Deep Zoom generator that wraps an
403403 :class: `OpenSlide <openslide.OpenSlide> ` or
404404 :class: `ImageSlide <openslide.ImageSlide> ` object.
405405
406406 :param osr: the slide object
407- :param int tile_size: the width and height of a single tile. For best
408- viewer performance, ``tile_size + 2 * overlap `` should be a power of two.
409- :param int overlap: the number of extra pixels to add to each interior edge
410- of a tile
411- :param bool limit_bounds: ``True `` to render only the non-empty slide
412- region
407+ :param tile_size: the width and height of a single tile. For best viewer
408+ performance, ``tile_size + 2 * overlap `` should be a power of two.
409+ :param overlap: the number of extra pixels to add to each interior edge of a
410+ tile
411+ :param limit_bounds: ``True `` to render only the non-empty slide region
413412
414413 .. attribute :: level_count
415414
@@ -437,40 +436,40 @@ Deep Zoom or a similar format.
437436
438437 :type: tuple[tuple[int, int], ...]
439438
440- .. method :: get_dzi(format)
439+ .. method :: get_dzi(format: str) -> str
441440
442441 Return a string containing the XML metadata for the Deep Zoom ``.dzi ``
443442 file.
444443
445- :param str format: the delivery format of the individual tiles
446- (`` png `` or ``jpeg ``)
444+ :param format: the delivery format of the individual tiles (`` png `` or
445+ ``jpeg ``)
447446
448- .. method :: get_tile(level, address)
447+ .. method :: get_tile(level: int , address: tuple[int, int]) -> ~PIL.Image.Image
449448
450449 Return an RGB :class: `Image <PIL.Image.Image> ` for a tile.
451450
452- :param int level: the Deep Zoom level
453- :param tuple address: the address of the tile within the level as a
451+ :param level: the Deep Zoom level
452+ :param address: the address of the tile within the level as a
454453 ``(column, row) `` tuple
455454
456- .. method :: get_tile_coordinates(level, address)
455+ .. method :: get_tile_coordinates(level: int , address: tuple[int, int]) -> tuple[tuple[int, int], int, tuple[int, int]]
457456
458457 Return the :meth: `OpenSlide.read_region()
459458 <openslide.OpenSlide.read_region> ` arguments corresponding to the
460459 specified tile.
461460
462461 Most applications should use :meth: `get_tile() ` instead.
463462
464- :param int level: the Deep Zoom level
465- :param tuple address: the address of the tile within the level as a
463+ :param level: the Deep Zoom level
464+ :param address: the address of the tile within the level as a
466465 ``(column, row) `` tuple
467466
468- .. method :: get_tile_dimensions(level, address)
467+ .. method :: get_tile_dimensions(level: int , address: tuple[int, int]) -> tuple[int, int]
469468
470469 Return a ``(pixels_x, pixels_y) `` tuple for the specified tile.
471470
472- :param int level: the Deep Zoom level
473- :param tuple address: the address of the tile within the level as a
471+ :param level: the Deep Zoom level
472+ :param address: the address of the tile within the level as a
474473 ``(column, row) `` tuple
475474
476475
0 commit comments