Skip to content

Commit

Permalink
mypy: unconditionally ignore os.add_dll_directory()
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
bgilbert committed Oct 28, 2024
1 parent 9ded242 commit 803b409
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/deepzoom/deepzoom_multiserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
if os.name == 'nt':
_dll_path = os.getenv('OPENSLIDE_PATH')
if _dll_path is not None:
with os.add_dll_directory(_dll_path): # type: ignore[attr-defined]
with os.add_dll_directory(_dll_path): # type: ignore[attr-defined,unused-ignore] # noqa: E501
import openslide
else:
import openslide
Expand Down
2 changes: 1 addition & 1 deletion examples/deepzoom/deepzoom_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
if os.name == 'nt':
_dll_path = os.getenv('OPENSLIDE_PATH')
if _dll_path is not None:
with os.add_dll_directory(_dll_path): # type: ignore[attr-defined]
with os.add_dll_directory(_dll_path): # type: ignore[attr-defined,unused-ignore] # noqa: E501
import openslide
else:
import openslide
Expand Down
2 changes: 1 addition & 1 deletion examples/deepzoom/deepzoom_tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
if os.name == 'nt':
_dll_path = os.getenv('OPENSLIDE_PATH')
if _dll_path is not None:
with os.add_dll_directory(_dll_path): # type: ignore[attr-defined]
with os.add_dll_directory(_dll_path): # type: ignore[attr-defined,unused-ignore] # noqa: E501
import openslide
else:
import openslide
Expand Down
2 changes: 1 addition & 1 deletion tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# environment.
_dll_path = os.getenv('OPENSLIDE_PATH')
if _dll_path is not None:
with os.add_dll_directory(_dll_path): # type: ignore[attr-defined]
with os.add_dll_directory(_dll_path): # type: ignore[attr-defined,unused-ignore] # noqa: E501
import openslide # noqa: F401 module-imported-but-unused


Expand Down

0 comments on commit 803b409

Please sign in to comment.