Skip to content

Commit

Permalink
Favor human readers over mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
exarkun committed Sep 27, 2022
1 parent 5ab99ae commit e5bb8f9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/twisted/trial/runner.py
Expand Up @@ -286,13 +286,19 @@ def name(thing: _Loadable) -> str:
"""
if isinstance(thing, pyunit.TestCase):
return thing.id()
elif isinstance(thing, (modules.PythonAttribute, modules.PythonModule)):

if isinstance(thing, (modules.PythonAttribute, modules.PythonModule)):
return thing.name
elif isTestCase(thing):

if isTestCase(thing):
# TestCase subclass
return reflect.qual(thing)
else:
assert False

# Based on the type of thing, this is unreachable. Maybe someone calls
# this from un-type-checked code though. Also, even with the type
# information, mypy fails to determine this is unreachable and complains
# about a missing return without _something_ here.
raise TypeError(f"Cannot name {thing!r}")


def isTestCase(obj: type) -> TypeGuard[Type[pyunit.TestCase]]:
Expand Down

0 comments on commit e5bb8f9

Please sign in to comment.