Fix test-before-setup IQS check (#133467)

This commit is contained in:
epenet
2024-12-18 10:44:19 +01:00
committed by GitHub
parent a2be5a383c
commit 8b8c409916

View File

@@ -17,13 +17,20 @@ _VALID_EXCEPTIONS = {
def _get_exception_name(expression: ast.expr) -> str: def _get_exception_name(expression: ast.expr) -> str:
"""Get the name of the exception being raised.""" """Get the name of the exception being raised."""
if expression is None:
# Bare raise
return None
if isinstance(expression, ast.Name): if isinstance(expression, ast.Name):
# Raise Exception
return expression.id return expression.id
if isinstance(expression, ast.Call): if isinstance(expression, ast.Call):
# Raise Exception()
return _get_exception_name(expression.func) return _get_exception_name(expression.func)
if isinstance(expression, ast.Attribute): if isinstance(expression, ast.Attribute):
# Raise namespace.???
return _get_exception_name(expression.value) return _get_exception_name(expression.value)
raise AssertionError( raise AssertionError(