summaryrefslogtreecommitdiff
path: root/testsuite/driver/my_typing.py
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-06-19 13:25:07 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-06-25 08:37:46 -0400
commitc346585b5f5054a85e48dc546e198c5be124340f (patch)
tree7a3d30e456c2811baf64010f059cb8ff6c7dac84 /testsuite/driver/my_typing.py
parentebd63e8de30470ccf8b65c11f0fc82705960b5cf (diff)
downloadhaskell-c346585b5f5054a85e48dc546e198c5be124340f.tar.gz
testsuite: A major revamp of the driver
This tries to put the testsuite driver into a slightly more maintainable condition: * Add type annotations where easily done * Use pathlib.Path instead of str paths * Make it pass the mypy typechecker
Diffstat (limited to 'testsuite/driver/my_typing.py')
-rw-r--r--testsuite/driver/my_typing.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/testsuite/driver/my_typing.py b/testsuite/driver/my_typing.py
new file mode 100644
index 0000000000..8347e84b5a
--- /dev/null
+++ b/testsuite/driver/my_typing.py
@@ -0,0 +1,43 @@
+"""
+This module provides some type definitions and backwards compatibility shims
+for use in the testsuite driver.
+
+The testsuite driver can be typechecked using mypy [1].
+
+
+[1] http://mypy-lang.org/
+"""
+
+try:
+ from typing import *
+ import typing
+except:
+ # The backwards compatibility stubs must live in another module lest
+ # mypy complains.
+ from typing_stubs import * # type: ignore
+
+
+####################################################
+# Backwards compatibility shims
+#
+# N.B. mypy appears to typecheck as though the "then" clause of if structures
+# is taken. We exploit this below.
+
+# TextIO is missing on some older Pythons.
+if 'TextIO' in globals():
+ TextIO = typing.TextIO
+else:
+ TextIO = None # type: ignore
+
+
+####################################################
+# Testsuite-specific types
+
+WayName = NewType("WayName", str)
+TestName = NewType("TestName", str)
+OutputNormalizer = Callable[[str], str]
+IssueNumber = NewType("IssueNumber", int)
+
+# Used by perf_notes
+GitHash = NewType("GitHash", str)
+GitRef = NewType("GitRef", str)