simplify code / take out user-gen typeerror case

This commit is contained in:
Reagan Lee 2023-08-10 17:43:01 -07:00
parent e938580257
commit b9cb87d862
2 changed files with 3 additions and 7 deletions

View File

@ -132,13 +132,9 @@ def isiterable(obj: Any) -> bool:
try: try:
iter(obj) iter(obj)
return not istext(obj) return not istext(obj)
except TypeError:
return False
except Exception as e: except Exception as e:
if (
isinstance(e, TypeError)
and (len(e.args) == 1)
and "iter() returned non-iterator of type" in str(e.args[0])
):
return False
raise ValueError(f"Unexpected exception {e!r} while testing object {obj!r}") raise ValueError(f"Unexpected exception {e!r} while testing object {obj!r}")

View File

@ -689,7 +689,7 @@ class TestAssertionRewrite:
def f() -> None: def f() -> None:
class A: class A:
def __iter__(self): def __iter__(self):
raise TypeError("user message") raise ValueError()
def __eq__(self, o: object) -> bool: def __eq__(self, o: object) -> bool:
return self is o return self is o