summaryrefslogtreecommitdiff
path: root/testsuite/driver
diff options
context:
space:
mode:
authorCheng Shao <terrorjack@type.dance>2023-03-30 03:29:35 +0000
committerCheng Shao <terrorjack@type.dance>2023-03-30 18:43:53 +0000
commit8fe8b65390bdbd6b51af42a227300c46cca89b3b (patch)
tree0f9ef2443ea1f0f30eb7ae6965854f5294915be4 /testsuite/driver
parentf7478d9543293cd78ce81c1aa730cc3025cffe9e (diff)
downloadhaskell-8fe8b65390bdbd6b51af42a227300c46cca89b3b.tar.gz
testsuite: mypy typing error fixes
This patch fixes some mypy typing errors which weren't caught in previous linting jobs.
Diffstat (limited to 'testsuite/driver')
-rw-r--r--testsuite/driver/my_typing.py18
-rw-r--r--testsuite/driver/runtests.py8
-rw-r--r--testsuite/driver/testglobals.py3
-rw-r--r--testsuite/driver/testutil.py8
-rw-r--r--testsuite/driver/typing_stubs.py23
5 files changed, 10 insertions, 50 deletions
diff --git a/testsuite/driver/my_typing.py b/testsuite/driver/my_typing.py
index 1bc5e6d578..c7cc1640e5 100644
--- a/testsuite/driver/my_typing.py
+++ b/testsuite/driver/my_typing.py
@@ -8,13 +8,8 @@ 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
+from typing import *
+import typing
####################################################
@@ -23,14 +18,7 @@ except:
# 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' not in globals():
- try:
- from typing import TextIO
- except ImportError:
- TextIO = None # type: ignore
-else:
- TextIO = None # type: ignore
+from typing import TextIO
####################################################
diff --git a/testsuite/driver/runtests.py b/testsuite/driver/runtests.py
index 73c832031d..7f8c7ffff1 100644
--- a/testsuite/driver/runtests.py
+++ b/testsuite/driver/runtests.py
@@ -29,7 +29,7 @@ import subprocess
from concurrent.futures import ThreadPoolExecutor
from testutil import getStdout, str_warn, str_info, print_table, shorten_metric_name
-from testglobals import getConfig, ghc_env, getTestRun, TestConfig, \
+from testglobals import getConfig, ghc_env, TestConfig, t, \
TestOptions, brokens, PerfMetric
from my_typing import TestName
from perf_notes import MetricChange, GitRef, inside_git_repo, is_worktree_dirty, format_perf_stat, get_abbrev_hash_length, is_commit_hash
@@ -339,8 +339,6 @@ t_files = list(findTFiles(config.rootdirs))
print('Found', len(t_files), '.T files...')
-t = getTestRun() # type: TestRun
-
# Avoid cmd.exe built-in 'date' command on Windows
t.start_time = datetime.datetime.now()
@@ -525,13 +523,13 @@ else:
groups[m.stat.metric].append(m)
- for metric_name, stats in groups.items():
+ for metric_name, stats in groups.items(): # type: ignore
heading = 'Metrics: %s' % metric_name
print()
print(heading)
print('-' * len(heading))
print()
- tabulate_metrics(stats)
+ tabulate_metrics(stats) # type: ignore
else:
print("\nNone collected.")
print("")
diff --git a/testsuite/driver/testglobals.py b/testsuite/driver/testglobals.py
index eb72e5e202..732b71b1ad 100644
--- a/testsuite/driver/testglobals.py
+++ b/testsuite/driver/testglobals.py
@@ -309,9 +309,6 @@ class TestRun:
global t
t = TestRun()
-def getTestRun() -> TestRun:
- return t
-
# -----------------------------------------------------------------------------
# Information about the current test
diff --git a/testsuite/driver/testutil.py b/testsuite/driver/testutil.py
index f2c63c5a2d..220c1f7554 100644
--- a/testsuite/driver/testutil.py
+++ b/testsuite/driver/testutil.py
@@ -29,9 +29,9 @@ def passed(hc_opts=None) -> PassFail:
hc_opts=hc_opts)
def failBecause(reason: str,
- tag: str=None,
- stderr: str=None,
- stdout: str=None
+ tag: Optional[str]=None,
+ stderr: Optional[str]=None,
+ stdout: Optional[str]=None
) -> PassFail:
return PassFail(passed=False, reason=reason, tag=tag,
stderr=stderr, stdout=stdout, hc_opts=None)
@@ -57,7 +57,7 @@ def getStdout(cmd_and_args: List[str]):
if r != 0:
raise Exception("Command failed: " + str(cmd_and_args))
if stderr:
- raise Exception("stderr from command: %s\nStdOut(%s):\n%s\n%s\nOutput(%s):\n%s\n%s\n" % (cmd_and_args,str(len(stdout)), stdout, stdout.decode('utf-8'), str(len(stderr)), stderr, stderr.decode('utf-8')))
+ raise Exception("stderr from command: %s\nStdOut(%s):\n%r\n%s\nOutput(%s):\n%r\n%s\n" % (cmd_and_args,str(len(stdout)), stdout, stdout.decode('utf-8'), str(len(stderr)), stderr, stderr.decode('utf-8')))
return stdout.decode('utf-8')
def lndir(srcdir: Path, dstdir: Path, force_copy=False):
diff --git a/testsuite/driver/typing_stubs.py b/testsuite/driver/typing_stubs.py
deleted file mode 100644
index 5c3cd813fa..0000000000
--- a/testsuite/driver/typing_stubs.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# Stub definitions for things provided by the `typing` package for use by older
-# Python versions which don't ship with `typing`.
-
-import collections
-
-class Dummy:
- def __getitem__(self, *args):
- return None
-
-List = Dummy()
-Tuple = Dummy()
-Set = Dummy()
-TextIO = Dummy()
-Iterator = Dummy()
-Callable = Dummy()
-Optional = Dummy()
-Dict = Dummy()
-Union = Dummy()
-Any = Dummy()
-
-NewType = lambda name, ty: ty
-def NamedTuple(name, fields):
- return collections.namedtuple(name, [field[0] for field in fields])