Skip to content

Commit 803b409

Browse files
committed
mypy: unconditionally ignore os.add_dll_directory()
If OpenSlide Python is type-checked on Windows, os.add_dll_directory() will exist and mypy will complain. Add an extra ignore to fix this. Mypy understands conditionalizing on sys.platform but not on os.name, and we want the latter because it exactly corresponds to whether the function exists. Signed-off-by: Benjamin Gilbert <[email protected]>
1 parent 9ded242 commit 803b409

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

examples/deepzoom/deepzoom_multiserver.py

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

examples/deepzoom/deepzoom_server.py

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

examples/deepzoom/deepzoom_tile.py

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

tests/common.py

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

3636

0 commit comments

Comments
 (0)