Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ repos:
name: Lint python code with flake8
additional_dependencies: [flake8-bugbear, Flake8-pyproject]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.2
hooks:
- id: mypy
name: Check Python types
additional_dependencies: [openslide-bin, pillow, types-setuptools]
exclude: "^(doc/.*|openslide/(__init__|deepzoom)\\.py|tests/.*|examples/deepzoom/.*)$"

- repo: https://github.com/rstcheck/rstcheck
rev: v6.2.4
hooks:
Expand Down
14 changes: 9 additions & 5 deletions openslide/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@

from openslide import lowlevel

# For the benefit of library users
from openslide._version import __version__ # noqa: F401 module-imported-but-unused
# Re-exports for the benefit of library users
from openslide._version import ( # noqa: F401 module-imported-but-unused
__version__ as __version__,
)
from openslide.lowlevel import (
OpenSlideUnsupportedFormatError as OpenSlideUnsupportedFormatError,
)
from openslide.lowlevel import ( # noqa: F401 module-imported-but-unused
OpenSlideError,
OpenSlideUnsupportedFormatError,
OpenSlideVersionError,
OpenSlideVersionError as OpenSlideVersionError,
)
from openslide.lowlevel import OpenSlideError as OpenSlideError

__library_version__ = lowlevel.get_version()

Expand Down
26 changes: 26 additions & 0 deletions openslide/_convert.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# openslide-python - Python bindings for the OpenSlide library
#
# Copyright (c) 2024 Benjamin Gilbert
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of version 2.1 of the GNU Lesser General Public License
# as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
# License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#

from typing import Protocol

class _Buffer(Protocol):
# Python 3.12+ has collections.abc.Buffer
def __buffer__(self, flags: int) -> memoryview: ...

def argb2rgba(buf: _Buffer) -> None: ...
Loading
Loading