mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2025-02-07 10:40:09 +00:00
typecheck: add support for typing.Any
This commit is contained in:
parent
e32efcae49
commit
2b500f234f
@ -68,5 +68,7 @@ def check_type(name: str, value: typing.Any, typeinfo: typing.Any) -> None:
|
|||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
raise e
|
raise e
|
||||||
|
elif typename.startswith("typing.Any"):
|
||||||
|
return
|
||||||
elif not isinstance(value, typeinfo):
|
elif not isinstance(value, typeinfo):
|
||||||
raise e
|
raise e
|
||||||
|
@ -79,3 +79,9 @@ def test_check_io():
|
|||||||
typecheck.check_type("foo", io.StringIO(), typing.IO[str])
|
typecheck.check_type("foo", io.StringIO(), typing.IO[str])
|
||||||
with pytest.raises(TypeError):
|
with pytest.raises(TypeError):
|
||||||
typecheck.check_type("foo", "foo", typing.IO[str])
|
typecheck.check_type("foo", "foo", typing.IO[str])
|
||||||
|
|
||||||
|
|
||||||
|
def test_check_any():
|
||||||
|
typecheck.check_type("foo", 42, typing.Any)
|
||||||
|
typecheck.check_type("foo", object(), typing.Any)
|
||||||
|
typecheck.check_type("foo", None, typing.Any)
|
||||||
|
Loading…
Reference in New Issue
Block a user