mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
[Reland] Update mypy to 1.4.1 (#105227)
This PR re-lands - [Typing] Fix PEP 484 Violation (#105022) - Update mypy to 1.4.1 (#91983) That were reverted due to the conflict with internal source repo. Mostly fixes for PEP-484 violation (i.e. when default arg is set to None, but type is not annotated as optional) Plus few real fixes: - Add missing `_get_upgraders_entry_map` to `torch/_C/__init__.pyi` - Add missing return statement to `torch._export. deserialize_graph` - Fix error message in `torch.ao.ns.fx.weight_utils.get_lstm_mod_weights` - Add assert it `torch/optim/optimizer.py` that Optional list is not None TODO (in followup PR): - Fix erroneous `isinstance` check in `torch/ao/quantization/_pt2e/qat_utils.py` Pull Request resolved: https://github.com/pytorch/pytorch/pull/105227 Approved by: https://github.com/atalman, https://github.com/albanD, https://github.com/Skylion007
This commit is contained in:
committed by
PyTorch MergeBot
parent
1518d5eec4
commit
c9c4f8efc3
@ -21,7 +21,7 @@ class TestFuture(TestCase):
|
||||
error_msg = "Intentional Value Error"
|
||||
value_error = ValueError(error_msg)
|
||||
|
||||
f = Future[T]()
|
||||
f = Future[T]() # type: ignore[valid-type]
|
||||
# Set exception
|
||||
f.set_exception(value_error)
|
||||
# Exception should throw on wait
|
||||
@ -29,7 +29,7 @@ class TestFuture(TestCase):
|
||||
f.wait()
|
||||
|
||||
# Exception should also throw on value
|
||||
f = Future[T]()
|
||||
f = Future[T]() # type: ignore[valid-type]
|
||||
f.set_exception(value_error)
|
||||
with self.assertRaisesRegex(ValueError, "Intentional"):
|
||||
f.value()
|
||||
@ -37,7 +37,7 @@ class TestFuture(TestCase):
|
||||
def cb(fut):
|
||||
fut.value()
|
||||
|
||||
f = Future[T]()
|
||||
f = Future[T]() # type: ignore[valid-type]
|
||||
f.set_exception(value_error)
|
||||
|
||||
with self.assertRaisesRegex(RuntimeError, "Got the following error"):
|
||||
@ -54,7 +54,7 @@ class TestFuture(TestCase):
|
||||
with self.assertRaisesRegex(ValueError, "Intentional"):
|
||||
f.wait()
|
||||
|
||||
f = Future[T]()
|
||||
f = Future[T]() # type: ignore[valid-type]
|
||||
t = threading.Thread(target=wait_future, args=(f, ))
|
||||
t.start()
|
||||
f.set_exception(value_error)
|
||||
@ -68,7 +68,7 @@ class TestFuture(TestCase):
|
||||
with self.assertRaisesRegex(RuntimeError, "Got the following error"):
|
||||
fut.wait()
|
||||
|
||||
f = Future[T]()
|
||||
f = Future[T]() # type: ignore[valid-type]
|
||||
t = threading.Thread(target=then_future, args=(f, ))
|
||||
t.start()
|
||||
f.set_exception(value_error)
|
||||
|
Reference in New Issue
Block a user