Skip to content

Commit ba421f9

Browse files
committed
Fix the fallout of the mypy 0.790 release
1 parent 793899e commit ba421f9

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

ipfshttpclient/filescanner.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import os
66
import re
77
import sys
8+
import types
89
import typing as ty
910

1011
from . import utils
@@ -511,7 +512,7 @@ def __init__(
511512
#
512513
# Note: `os.fwalk` support for binary paths was only added in 3.7+.
513514
directory_str_or_fd = directory_str # type: ty.Union[ty.AnyStr, int]
514-
if HAVE_FWALK and (not isinstance(directory_str, bytes) or HAVE_FWALK_BYTES):
515+
if HAVE_FWALK and (not isinstance(directory_str, bytes) or HAVE_FWALK_BYTES): # type: ignore[unreachable] # noqa: E501
515516
self._close_fd = directory_str_or_fd = os.open(directory_str, os.O_RDONLY | O_DIRECTORY)
516517

517518
self._generator = self._walk(
@@ -533,10 +534,24 @@ def __exit__(self, *a: ty.Any) -> None:
533534
def send(self, value: ty.Any) -> FSNodeEntry:
534535
return self._generator.send(value)
535536

536-
def throw(self, typ: ty.Type[BaseException], val: ty.Optional[BaseException] = None,
537-
tb: ty.Any = None) -> FSNodeEntry:
537+
@ty.overload
538+
def throw(self, typ: ty.Type[BaseException], # noqa: E704
539+
val: ty.Union[BaseException, object] = ...,
540+
tb: ty.Optional[types.TracebackType] = ...) -> FSNodeEntry: ...
541+
542+
@ty.overload
543+
def throw(self, typ: BaseException, val: None = ..., # noqa: E704
544+
tb: ty.Optional[types.TracebackType] = ...) -> FSNodeEntry: ...
545+
546+
def throw(self, typ: ty.Union[ty.Type[BaseException], BaseException],
547+
val: ty.Union[BaseException, object] = None,
548+
tb: ty.Optional[types.TracebackType] = None) -> FSNodeEntry:
538549
try:
539-
return self._generator.throw(typ, val, tb)
550+
if isinstance(typ, type):
551+
return self._generator.throw(typ, val, tb)
552+
else:
553+
assert val is None
554+
return self._generator.throw(typ, val, tb)
540555
except:
541556
if self._close_fd is not None:
542557
os.close(self._close_fd)

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ commands =
7070
[testenv:typeck]
7171
skip_install = true
7272
deps =
73-
mypy ~= 0.782
73+
mypy ~= 0.790
7474
pytest ~= 5.0
7575
{[testenv:py3-httpx]deps-exclusive}
7676
commands =

0 commit comments

Comments
 (0)