We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Add type hints to toilSshCluster.py
Adds type hints to src/toil/utils/toilSshCluster.py so it can be checked under mypy during linting.

Refers to #3568.

┆Issue is synchronized with this [Jira Task](https://ucsc-cgl.atlassian.net/browse/TOIL-912)
┆Issue Number: TOIL-912


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/toil/utils/toilUpdateEC2Instances.py`
Content:
```
1 # Copyright (C) 2015-2021 Regents of the University of California
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 """Updates Toil's internal list of EC2 instance types."""
15 import logging
16 import socket
17 
18 from toil.lib.ec2nodes import updateStaticEC2Instances
19 
20 logger = logging.getLogger(__name__)
21 
22 
23 def internet_connection() -> bool:
24     """Returns True if there is an internet connection present, and False otherwise."""
25     try:
26         socket.create_connection(("www.stackoverflow.com", 80))
27         return True
28     except OSError:
29         return False
30 
31 
32 def main():
33     if not internet_connection():
34         raise RuntimeError('No internet.  Updating the EC2 Instance list requires internet.')
35     updateStaticEC2Instances()
36 
37 
38 if __name__ == "__main__":
39     main()
40
```

Path: `contrib/admin/mypy-with-ignore.py`
Content:
```
1 #!/usr/bin/env python3
2 """
3 Runs mypy and ignores files that do not yet have passing type hints.
4 
5 Does not type check test files (any path including "src/toil/test").
6 """
7 import os
8 import subprocess
9 import sys
10 
11 pkg_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))  # noqa
12 sys.path.insert(0, pkg_root)  # noqa
13 
14 from src.toil.lib.resources import glob  # type: ignore
15 
16 
17 def main():
18     all_files_to_check = []
19     for d in ['dashboard', 'docker', 'docs', 'src']:
20         all_files_to_check += glob(glob_pattern='*.py', directoryname=os.path.join(pkg_root, d))
21 
22     # TODO: Remove these paths as typing is added and mypy conflicts are addressed
23     ignore_paths = [os.path.abspath(f) for f in [
24         'docker/Dockerfile.py',
25         'docs/conf.py',
26         'docs/vendor/sphinxcontrib/fulltoc.py',
27         'docs/vendor/sphinxcontrib/__init__.py',
28         'src/toil/job.py',
29         'src/toil/leader.py',
30         'src/toil/statsAndLogging.py',
31         'src/toil/common.py',
32         'src/toil/realtimeLogger.py',
33         'src/toil/worker.py',
34         'src/toil/serviceManager.py',
35         'src/toil/toilState.py',
36         'src/toil/__init__.py',
37         'src/toil/resource.py',
38         'src/toil/deferred.py',
39         'src/toil/version.py',
40         'src/toil/wdl/utils.py',
41         'src/toil/wdl/wdl_types.py',
42         'src/toil/wdl/wdl_synthesis.py',
43         'src/toil/wdl/wdl_analysis.py',
44         'src/toil/wdl/wdl_functions.py',
45         'src/toil/wdl/toilwdl.py',
46         'src/toil/wdl/versions/draft2.py',
47         'src/toil/wdl/versions/v1.py',
48         'src/toil/wdl/versions/dev.py',
49         'src/toil/provisioners/clusterScaler.py',
50         'src/toil/provisioners/abstractProvisioner.py',
51         'src/toil/provisioners/gceProvisioner.py',
52         'src/toil/provisioners/__init__.py',
53         'src/toil/provisioners/node.py',
54         'src/toil/provisioners/aws/boto2Context.py',
55         'src/toil/provisioners/aws/awsProvisioner.py',
56         'src/toil/provisioners/aws/__init__.py',
57         'src/toil/batchSystems/slurm.py',
58         'src/toil/batchSystems/gridengine.py',
59         'src/toil/batchSystems/singleMachine.py',
60         'src/toil/batchSystems/abstractBatchSystem.py',
61         'src/toil/batchSystems/parasol.py',
62         'src/toil/batchSystems/kubernetes.py',
63         'src/toil/batchSystems/torque.py',
64         'src/toil/batchSystems/options.py',
65         'src/toil/batchSystems/registry.py',
66         'src/toil/batchSystems/lsf.py',
67         'src/toil/batchSystems/__init__.py',
68         'src/toil/batchSystems/abstractGridEngineBatchSystem.py',
69         'src/toil/batchSystems/lsfHelper.py',
70         'src/toil/batchSystems/htcondor.py',
71         'src/toil/batchSystems/mesos/batchSystem.py',
72         'src/toil/batchSystems/mesos/executor.py',
73         'src/toil/batchSystems/mesos/conftest.py',
74         'src/toil/batchSystems/mesos/__init__.py',
75         'src/toil/batchSystems/mesos/test/__init__.py',
76         'src/toil/cwl/conftest.py',
77         'src/toil/cwl/__init__.py',
78         'src/toil/cwl/cwltoil.py',
79         'src/toil/fileStores/cachingFileStore.py',
80         'src/toil/fileStores/abstractFileStore.py',
81         'src/toil/fileStores/nonCachingFileStore.py',
82         'src/toil/fileStores/__init__.py',
83         'src/toil/jobStores/utils.py',
84         'src/toil/jobStores/abstractJobStore.py',
85         'src/toil/jobStores/conftest.py',
86         'src/toil/jobStores/fileJobStore.py',
87         'src/toil/jobStores/__init__.py',
88         'src/toil/jobStores/googleJobStore.py',
89         'src/toil/jobStores/aws/utils.py',
90         'src/toil/jobStores/aws/jobStore.py',
91         'src/toil/jobStores/aws/__init__.py',
92         'src/toil/utils/toilDebugFile.py',
93         'src/toil/utils/toilUpdateEC2Instances.py',
94         'src/toil/utils/toilStatus.py',
95         'src/toil/utils/toilStats.py',
96         'src/toil/utils/toilSshCluster.py',
97         'src/toil/utils/toilMain.py',
98         'src/toil/utils/__init__.py',
99         'src/toil/utils/toilDestroyCluster.py',
100         'src/toil/utils/toilDebugJob.py',
101         'src/toil/utils/toilRsyncCluster.py',
102         'src/toil/utils/toilClean.py',
103         'src/toil/utils/toilLaunchCluster.py',
104         'src/toil/lib/memoize.py',
105         'src/toil/lib/throttle.py',
106         'src/toil/lib/humanize.py',
107         'src/toil/lib/compatibility.py',
108         'src/toil/lib/iterables.py',
109         'src/toil/lib/bioio.py',
110         'src/toil/lib/ec2.py',
111         # 'src/toil/lib/conversions.py',
112         'src/toil/lib/ec2nodes.py',
113         # 'src/toil/lib/misc.py',
114         'src/toil/lib/expando.py',
115         'src/toil/lib/threading.py',
116         'src/toil/lib/exceptions.py',
117         'src/toil/lib/__init__.py',
118         'src/toil/lib/generatedEC2Lists.py',
119         'src/toil/lib/retry.py',
120         'src/toil/lib/objects.py',
121         'src/toil/lib/io.py',
122         'src/toil/lib/docker.py',
123         'src/toil/lib/encryption/_nacl.py',
124         'src/toil/lib/encryption/_dummy.py',
125         'src/toil/lib/encryption/conftest.py',
126         'src/toil/lib/encryption/__init__.py',
127         'src/toil/lib/aws/utils.py',
128         'src/toil/lib/aws/__init__.py'
129     ]]
130 
131     filtered_files_to_check = []
132     for file_path in all_files_to_check:
133         if file_path not in ignore_paths and 'src/toil/test' not in file_path:
134             filtered_files_to_check.append(file_path)
135     # follow-imports type checks pypi projects we don't control, so we skip it; why is this their default?
136     args = ['mypy', '--follow-imports=skip'] + filtered_files_to_check
137     p = subprocess.run(args=args, stdout=subprocess.PIPE)
138     result = p.stdout.decode()
139     print(result)
140     if 'Success: no issues found' not in result:
141         exit(1)
142 
143 
144 if __name__ == '__main__':
145     main()
146
```

Path: `src/toil/utils/toilSshCluster.py`
Content:
```
1 # Copyright (C) 2015-2021 Regents of the University of California
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 """SSH into the toil appliance container running on the leader of the cluster."""
15 import argparse
16 import logging
17 import sys
18 
19 from toil.common import parser_with_common_options
20 from toil.provisioners import cluster_factory
21 from toil.statsAndLogging import set_logging_from_options
22 
23 logger = logging.getLogger(__name__)
24 
25 
26 def main():
27     parser = parser_with_common_options(provisioner_options=True, jobstore_option=False)
28     parser.add_argument("--insecure", action='store_true',
29                         help="Temporarily disable strict host key checking.")
30     parser.add_argument("--sshOption", dest='sshOptions', default=[], action='append',
31                         help="Pass an additional option to the SSH command.")
32     parser.add_argument("--grafana_port", dest='grafana_port', default=3000,
33                         help="Assign a local port to be used for the Grafana dashboard.")
34     parser.add_argument('args', nargs=argparse.REMAINDER)
35     options = parser.parse_args()
36     set_logging_from_options(options)
37 
38     # Since we collect all the remaining arguments at the end for a command to
39     # run, it's easy to lose options.
40     if len(options.args) > 0 and options.args[0].startswith('-'):
41         logger.warning('Argument \'%s\' interpreted as a command to run '
42                        'despite looking like an option.', options.args[0])
43 
44     cluster = cluster_factory(provisioner=options.provisioner,
45                               clusterName=options.clusterName,
46                               zone=options.zone)
47     command = options.args if options.args else ['bash']
48     sshOptions: list = options.sshOptions
49 
50     # Forward ports:
51     # 3000 for Grafana dashboard
52     # 9090 for Prometheus dashboard
53     sshOptions.extend(['-L', f'{options.grafana_port}:localhost:3000',
54                        '-L', '9090:localhost:9090'])
55 
56     cluster.getLeader().sshAppliance(*command, strict=not options.insecure, tty=sys.stdin.isatty(),
57                                      sshOptions=sshOptions)
58
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/contrib/admin/mypy-with-ignore.py b/contrib/admin/mypy-with-ignore.py
--- a/contrib/admin/mypy-with-ignore.py
+++ b/contrib/admin/mypy-with-ignore.py
@@ -90,10 +90,8 @@
         'src/toil/jobStores/aws/jobStore.py',
         'src/toil/jobStores/aws/__init__.py',
         'src/toil/utils/toilDebugFile.py',
-        'src/toil/utils/toilUpdateEC2Instances.py',
         'src/toil/utils/toilStatus.py',
         'src/toil/utils/toilStats.py',
-        'src/toil/utils/toilSshCluster.py',
         'src/toil/utils/toilMain.py',
         'src/toil/utils/__init__.py',
         'src/toil/utils/toilDestroyCluster.py',
diff --git a/src/toil/utils/toilSshCluster.py b/src/toil/utils/toilSshCluster.py
--- a/src/toil/utils/toilSshCluster.py
+++ b/src/toil/utils/toilSshCluster.py
@@ -19,11 +19,12 @@
 from toil.common import parser_with_common_options
 from toil.provisioners import cluster_factory
 from toil.statsAndLogging import set_logging_from_options
+from typing import List
 
 logger = logging.getLogger(__name__)
 
 
-def main():
+def main() -> None:
     parser = parser_with_common_options(provisioner_options=True, jobstore_option=False)
     parser.add_argument("--insecure", action='store_true',
                         help="Temporarily disable strict host key checking.")
@@ -45,7 +46,7 @@
                               clusterName=options.clusterName,
                               zone=options.zone)
     command = options.args if options.args else ['bash']
-    sshOptions: list = options.sshOptions
+    sshOptions: List[str] = options.sshOptions
 
     # Forward ports:
     # 3000 for Grafana dashboard
diff --git a/src/toil/utils/toilUpdateEC2Instances.py b/src/toil/utils/toilUpdateEC2Instances.py
--- a/src/toil/utils/toilUpdateEC2Instances.py
+++ b/src/toil/utils/toilUpdateEC2Instances.py
@@ -29,7 +29,7 @@
         return False
 
 
-def main():
+def main() -> None:
     if not internet_connection():
         raise RuntimeError('No internet.  Updating the EC2 Instance list requires internet.')
     updateStaticEC2Instances()

{"golden_diff": "diff --git a/contrib/admin/mypy-with-ignore.py b/contrib/admin/mypy-with-ignore.py\n--- a/contrib/admin/mypy-with-ignore.py\n+++ b/contrib/admin/mypy-with-ignore.py\n@@ -90,10 +90,8 @@\n         'src/toil/jobStores/aws/jobStore.py',\n         'src/toil/jobStores/aws/__init__.py',\n         'src/toil/utils/toilDebugFile.py',\n-        'src/toil/utils/toilUpdateEC2Instances.py',\n         'src/toil/utils/toilStatus.py',\n         'src/toil/utils/toilStats.py',\n-        'src/toil/utils/toilSshCluster.py',\n         'src/toil/utils/toilMain.py',\n         'src/toil/utils/__init__.py',\n         'src/toil/utils/toilDestroyCluster.py',\ndiff --git a/src/toil/utils/toilSshCluster.py b/src/toil/utils/toilSshCluster.py\n--- a/src/toil/utils/toilSshCluster.py\n+++ b/src/toil/utils/toilSshCluster.py\n@@ -19,11 +19,12 @@\n from toil.common import parser_with_common_options\n from toil.provisioners import cluster_factory\n from toil.statsAndLogging import set_logging_from_options\n+from typing import List\n \n logger = logging.getLogger(__name__)\n \n \n-def main():\n+def main() -> None:\n     parser = parser_with_common_options(provisioner_options=True, jobstore_option=False)\n     parser.add_argument(\"--insecure\", action='store_true',\n                         help=\"Temporarily disable strict host key checking.\")\n@@ -45,7 +46,7 @@\n                               clusterName=options.clusterName,\n                               zone=options.zone)\n     command = options.args if options.args else ['bash']\n-    sshOptions: list = options.sshOptions\n+    sshOptions: List[str] = options.sshOptions\n \n     # Forward ports:\n     # 3000 for Grafana dashboard\ndiff --git a/src/toil/utils/toilUpdateEC2Instances.py b/src/toil/utils/toilUpdateEC2Instances.py\n--- a/src/toil/utils/toilUpdateEC2Instances.py\n+++ b/src/toil/utils/toilUpdateEC2Instances.py\n@@ -29,7 +29,7 @@\n         return False\n \n \n-def main():\n+def main() -> None:\n     if not internet_connection():\n         raise RuntimeError('No internet.  Updating the EC2 Instance list requires internet.')\n     updateStaticEC2Instances()\n", "issue": "Add type hints to toilSshCluster.py\nAdds type hints to src/toil/utils/toilSshCluster.py so it can be checked under mypy during linting.\n\nRefers to #3568.\n\n\u2506Issue is synchronized with this [Jira Task](https://ucsc-cgl.atlassian.net/browse/TOIL-912)\n\u2506Issue Number: TOIL-912\n\n", "before_files": [{"content": "# Copyright (C) 2015-2021 Regents of the University of California\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"Updates Toil's internal list of EC2 instance types.\"\"\"\nimport logging\nimport socket\n\nfrom toil.lib.ec2nodes import updateStaticEC2Instances\n\nlogger = logging.getLogger(__name__)\n\n\ndef internet_connection() -> bool:\n    \"\"\"Returns True if there is an internet connection present, and False otherwise.\"\"\"\n    try:\n        socket.create_connection((\"www.stackoverflow.com\", 80))\n        return True\n    except OSError:\n        return False\n\n\ndef main():\n    if not internet_connection():\n        raise RuntimeError('No internet.  Updating the EC2 Instance list requires internet.')\n    updateStaticEC2Instances()\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "src/toil/utils/toilUpdateEC2Instances.py"}, {"content": "#!/usr/bin/env python3\n\"\"\"\nRuns mypy and ignores files that do not yet have passing type hints.\n\nDoes not type check test files (any path including \"src/toil/test\").\n\"\"\"\nimport os\nimport subprocess\nimport sys\n\npkg_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))  # noqa\nsys.path.insert(0, pkg_root)  # noqa\n\nfrom src.toil.lib.resources import glob  # type: ignore\n\n\ndef main():\n    all_files_to_check = []\n    for d in ['dashboard', 'docker', 'docs', 'src']:\n        all_files_to_check += glob(glob_pattern='*.py', directoryname=os.path.join(pkg_root, d))\n\n    # TODO: Remove these paths as typing is added and mypy conflicts are addressed\n    ignore_paths = [os.path.abspath(f) for f in [\n        'docker/Dockerfile.py',\n        'docs/conf.py',\n        'docs/vendor/sphinxcontrib/fulltoc.py',\n        'docs/vendor/sphinxcontrib/__init__.py',\n        'src/toil/job.py',\n        'src/toil/leader.py',\n        'src/toil/statsAndLogging.py',\n        'src/toil/common.py',\n        'src/toil/realtimeLogger.py',\n        'src/toil/worker.py',\n        'src/toil/serviceManager.py',\n        'src/toil/toilState.py',\n        'src/toil/__init__.py',\n        'src/toil/resource.py',\n        'src/toil/deferred.py',\n        'src/toil/version.py',\n        'src/toil/wdl/utils.py',\n        'src/toil/wdl/wdl_types.py',\n        'src/toil/wdl/wdl_synthesis.py',\n        'src/toil/wdl/wdl_analysis.py',\n        'src/toil/wdl/wdl_functions.py',\n        'src/toil/wdl/toilwdl.py',\n        'src/toil/wdl/versions/draft2.py',\n        'src/toil/wdl/versions/v1.py',\n        'src/toil/wdl/versions/dev.py',\n        'src/toil/provisioners/clusterScaler.py',\n        'src/toil/provisioners/abstractProvisioner.py',\n        'src/toil/provisioners/gceProvisioner.py',\n        'src/toil/provisioners/__init__.py',\n        'src/toil/provisioners/node.py',\n        'src/toil/provisioners/aws/boto2Context.py',\n        'src/toil/provisioners/aws/awsProvisioner.py',\n        'src/toil/provisioners/aws/__init__.py',\n        'src/toil/batchSystems/slurm.py',\n        'src/toil/batchSystems/gridengine.py',\n        'src/toil/batchSystems/singleMachine.py',\n        'src/toil/batchSystems/abstractBatchSystem.py',\n        'src/toil/batchSystems/parasol.py',\n        'src/toil/batchSystems/kubernetes.py',\n        'src/toil/batchSystems/torque.py',\n        'src/toil/batchSystems/options.py',\n        'src/toil/batchSystems/registry.py',\n        'src/toil/batchSystems/lsf.py',\n        'src/toil/batchSystems/__init__.py',\n        'src/toil/batchSystems/abstractGridEngineBatchSystem.py',\n        'src/toil/batchSystems/lsfHelper.py',\n        'src/toil/batchSystems/htcondor.py',\n        'src/toil/batchSystems/mesos/batchSystem.py',\n        'src/toil/batchSystems/mesos/executor.py',\n        'src/toil/batchSystems/mesos/conftest.py',\n        'src/toil/batchSystems/mesos/__init__.py',\n        'src/toil/batchSystems/mesos/test/__init__.py',\n        'src/toil/cwl/conftest.py',\n        'src/toil/cwl/__init__.py',\n        'src/toil/cwl/cwltoil.py',\n        'src/toil/fileStores/cachingFileStore.py',\n        'src/toil/fileStores/abstractFileStore.py',\n        'src/toil/fileStores/nonCachingFileStore.py',\n        'src/toil/fileStores/__init__.py',\n        'src/toil/jobStores/utils.py',\n        'src/toil/jobStores/abstractJobStore.py',\n        'src/toil/jobStores/conftest.py',\n        'src/toil/jobStores/fileJobStore.py',\n        'src/toil/jobStores/__init__.py',\n        'src/toil/jobStores/googleJobStore.py',\n        'src/toil/jobStores/aws/utils.py',\n        'src/toil/jobStores/aws/jobStore.py',\n        'src/toil/jobStores/aws/__init__.py',\n        'src/toil/utils/toilDebugFile.py',\n        'src/toil/utils/toilUpdateEC2Instances.py',\n        'src/toil/utils/toilStatus.py',\n        'src/toil/utils/toilStats.py',\n        'src/toil/utils/toilSshCluster.py',\n        'src/toil/utils/toilMain.py',\n        'src/toil/utils/__init__.py',\n        'src/toil/utils/toilDestroyCluster.py',\n        'src/toil/utils/toilDebugJob.py',\n        'src/toil/utils/toilRsyncCluster.py',\n        'src/toil/utils/toilClean.py',\n        'src/toil/utils/toilLaunchCluster.py',\n        'src/toil/lib/memoize.py',\n        'src/toil/lib/throttle.py',\n        'src/toil/lib/humanize.py',\n        'src/toil/lib/compatibility.py',\n        'src/toil/lib/iterables.py',\n        'src/toil/lib/bioio.py',\n        'src/toil/lib/ec2.py',\n        # 'src/toil/lib/conversions.py',\n        'src/toil/lib/ec2nodes.py',\n        # 'src/toil/lib/misc.py',\n        'src/toil/lib/expando.py',\n        'src/toil/lib/threading.py',\n        'src/toil/lib/exceptions.py',\n        'src/toil/lib/__init__.py',\n        'src/toil/lib/generatedEC2Lists.py',\n        'src/toil/lib/retry.py',\n        'src/toil/lib/objects.py',\n        'src/toil/lib/io.py',\n        'src/toil/lib/docker.py',\n        'src/toil/lib/encryption/_nacl.py',\n        'src/toil/lib/encryption/_dummy.py',\n        'src/toil/lib/encryption/conftest.py',\n        'src/toil/lib/encryption/__init__.py',\n        'src/toil/lib/aws/utils.py',\n        'src/toil/lib/aws/__init__.py'\n    ]]\n\n    filtered_files_to_check = []\n    for file_path in all_files_to_check:\n        if file_path not in ignore_paths and 'src/toil/test' not in file_path:\n            filtered_files_to_check.append(file_path)\n    # follow-imports type checks pypi projects we don't control, so we skip it; why is this their default?\n    args = ['mypy', '--follow-imports=skip'] + filtered_files_to_check\n    p = subprocess.run(args=args, stdout=subprocess.PIPE)\n    result = p.stdout.decode()\n    print(result)\n    if 'Success: no issues found' not in result:\n        exit(1)\n\n\nif __name__ == '__main__':\n    main()\n", "path": "contrib/admin/mypy-with-ignore.py"}, {"content": "# Copyright (C) 2015-2021 Regents of the University of California\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"SSH into the toil appliance container running on the leader of the cluster.\"\"\"\nimport argparse\nimport logging\nimport sys\n\nfrom toil.common import parser_with_common_options\nfrom toil.provisioners import cluster_factory\nfrom toil.statsAndLogging import set_logging_from_options\n\nlogger = logging.getLogger(__name__)\n\n\ndef main():\n    parser = parser_with_common_options(provisioner_options=True, jobstore_option=False)\n    parser.add_argument(\"--insecure\", action='store_true',\n                        help=\"Temporarily disable strict host key checking.\")\n    parser.add_argument(\"--sshOption\", dest='sshOptions', default=[], action='append',\n                        help=\"Pass an additional option to the SSH command.\")\n    parser.add_argument(\"--grafana_port\", dest='grafana_port', default=3000,\n                        help=\"Assign a local port to be used for the Grafana dashboard.\")\n    parser.add_argument('args', nargs=argparse.REMAINDER)\n    options = parser.parse_args()\n    set_logging_from_options(options)\n\n    # Since we collect all the remaining arguments at the end for a command to\n    # run, it's easy to lose options.\n    if len(options.args) > 0 and options.args[0].startswith('-'):\n        logger.warning('Argument \\'%s\\' interpreted as a command to run '\n                       'despite looking like an option.', options.args[0])\n\n    cluster = cluster_factory(provisioner=options.provisioner,\n                              clusterName=options.clusterName,\n                              zone=options.zone)\n    command = options.args if options.args else ['bash']\n    sshOptions: list = options.sshOptions\n\n    # Forward ports:\n    # 3000 for Grafana dashboard\n    # 9090 for Prometheus dashboard\n    sshOptions.extend(['-L', f'{options.grafana_port}:localhost:3000',\n                       '-L', '9090:localhost:9090'])\n\n    cluster.getLeader().sshAppliance(*command, strict=not options.insecure, tty=sys.stdin.isatty(),\n                                     sshOptions=sshOptions)\n", "path": "src/toil/utils/toilSshCluster.py"}], "after_files": [{"content": "# Copyright (C) 2015-2021 Regents of the University of California\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"Updates Toil's internal list of EC2 instance types.\"\"\"\nimport logging\nimport socket\n\nfrom toil.lib.ec2nodes import updateStaticEC2Instances\n\nlogger = logging.getLogger(__name__)\n\n\ndef internet_connection() -> bool:\n    \"\"\"Returns True if there is an internet connection present, and False otherwise.\"\"\"\n    try:\n        socket.create_connection((\"www.stackoverflow.com\", 80))\n        return True\n    except OSError:\n        return False\n\n\ndef main() -> None:\n    if not internet_connection():\n        raise RuntimeError('No internet.  Updating the EC2 Instance list requires internet.')\n    updateStaticEC2Instances()\n\n\nif __name__ == \"__main__\":\n    main()\n", "path": "src/toil/utils/toilUpdateEC2Instances.py"}, {"content": "#!/usr/bin/env python3\n\"\"\"\nRuns mypy and ignores files that do not yet have passing type hints.\n\nDoes not type check test files (any path including \"src/toil/test\").\n\"\"\"\nimport os\nimport subprocess\nimport sys\n\npkg_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))  # noqa\nsys.path.insert(0, pkg_root)  # noqa\n\nfrom src.toil.lib.resources import glob  # type: ignore\n\n\ndef main():\n    all_files_to_check = []\n    for d in ['dashboard', 'docker', 'docs', 'src']:\n        all_files_to_check += glob(glob_pattern='*.py', directoryname=os.path.join(pkg_root, d))\n\n    # TODO: Remove these paths as typing is added and mypy conflicts are addressed\n    ignore_paths = [os.path.abspath(f) for f in [\n        'docker/Dockerfile.py',\n        'docs/conf.py',\n        'docs/vendor/sphinxcontrib/fulltoc.py',\n        'docs/vendor/sphinxcontrib/__init__.py',\n        'src/toil/job.py',\n        'src/toil/leader.py',\n        'src/toil/statsAndLogging.py',\n        'src/toil/common.py',\n        'src/toil/realtimeLogger.py',\n        'src/toil/worker.py',\n        'src/toil/serviceManager.py',\n        'src/toil/toilState.py',\n        'src/toil/__init__.py',\n        'src/toil/resource.py',\n        'src/toil/deferred.py',\n        'src/toil/version.py',\n        'src/toil/wdl/utils.py',\n        'src/toil/wdl/wdl_types.py',\n        'src/toil/wdl/wdl_synthesis.py',\n        'src/toil/wdl/wdl_analysis.py',\n        'src/toil/wdl/wdl_functions.py',\n        'src/toil/wdl/toilwdl.py',\n        'src/toil/wdl/versions/draft2.py',\n        'src/toil/wdl/versions/v1.py',\n        'src/toil/wdl/versions/dev.py',\n        'src/toil/provisioners/clusterScaler.py',\n        'src/toil/provisioners/abstractProvisioner.py',\n        'src/toil/provisioners/gceProvisioner.py',\n        'src/toil/provisioners/__init__.py',\n        'src/toil/provisioners/node.py',\n        'src/toil/provisioners/aws/boto2Context.py',\n        'src/toil/provisioners/aws/awsProvisioner.py',\n        'src/toil/provisioners/aws/__init__.py',\n        'src/toil/batchSystems/slurm.py',\n        'src/toil/batchSystems/gridengine.py',\n        'src/toil/batchSystems/singleMachine.py',\n        'src/toil/batchSystems/abstractBatchSystem.py',\n        'src/toil/batchSystems/parasol.py',\n        'src/toil/batchSystems/kubernetes.py',\n        'src/toil/batchSystems/torque.py',\n        'src/toil/batchSystems/options.py',\n        'src/toil/batchSystems/registry.py',\n        'src/toil/batchSystems/lsf.py',\n        'src/toil/batchSystems/__init__.py',\n        'src/toil/batchSystems/abstractGridEngineBatchSystem.py',\n        'src/toil/batchSystems/lsfHelper.py',\n        'src/toil/batchSystems/htcondor.py',\n        'src/toil/batchSystems/mesos/batchSystem.py',\n        'src/toil/batchSystems/mesos/executor.py',\n        'src/toil/batchSystems/mesos/conftest.py',\n        'src/toil/batchSystems/mesos/__init__.py',\n        'src/toil/batchSystems/mesos/test/__init__.py',\n        'src/toil/cwl/conftest.py',\n        'src/toil/cwl/__init__.py',\n        'src/toil/cwl/cwltoil.py',\n        'src/toil/fileStores/cachingFileStore.py',\n        'src/toil/fileStores/abstractFileStore.py',\n        'src/toil/fileStores/nonCachingFileStore.py',\n        'src/toil/fileStores/__init__.py',\n        'src/toil/jobStores/utils.py',\n        'src/toil/jobStores/abstractJobStore.py',\n        'src/toil/jobStores/conftest.py',\n        'src/toil/jobStores/fileJobStore.py',\n        'src/toil/jobStores/__init__.py',\n        'src/toil/jobStores/googleJobStore.py',\n        'src/toil/jobStores/aws/utils.py',\n        'src/toil/jobStores/aws/jobStore.py',\n        'src/toil/jobStores/aws/__init__.py',\n        'src/toil/utils/toilDebugFile.py',\n        'src/toil/utils/toilStatus.py',\n        'src/toil/utils/toilStats.py',\n        'src/toil/utils/toilMain.py',\n        'src/toil/utils/__init__.py',\n        'src/toil/utils/toilDestroyCluster.py',\n        'src/toil/utils/toilDebugJob.py',\n        'src/toil/utils/toilRsyncCluster.py',\n        'src/toil/utils/toilClean.py',\n        'src/toil/utils/toilLaunchCluster.py',\n        'src/toil/lib/memoize.py',\n        'src/toil/lib/throttle.py',\n        'src/toil/lib/humanize.py',\n        'src/toil/lib/compatibility.py',\n        'src/toil/lib/iterables.py',\n        'src/toil/lib/bioio.py',\n        'src/toil/lib/ec2.py',\n        # 'src/toil/lib/conversions.py',\n        'src/toil/lib/ec2nodes.py',\n        # 'src/toil/lib/misc.py',\n        'src/toil/lib/expando.py',\n        'src/toil/lib/threading.py',\n        'src/toil/lib/exceptions.py',\n        'src/toil/lib/__init__.py',\n        'src/toil/lib/generatedEC2Lists.py',\n        'src/toil/lib/retry.py',\n        'src/toil/lib/objects.py',\n        'src/toil/lib/io.py',\n        'src/toil/lib/docker.py',\n        'src/toil/lib/encryption/_nacl.py',\n        'src/toil/lib/encryption/_dummy.py',\n        'src/toil/lib/encryption/conftest.py',\n        'src/toil/lib/encryption/__init__.py',\n        'src/toil/lib/aws/utils.py',\n        'src/toil/lib/aws/__init__.py'\n    ]]\n\n    filtered_files_to_check = []\n    for file_path in all_files_to_check:\n        if file_path not in ignore_paths and 'src/toil/test' not in file_path:\n            filtered_files_to_check.append(file_path)\n    # follow-imports type checks pypi projects we don't control, so we skip it; why is this their default?\n    args = ['mypy', '--follow-imports=skip'] + filtered_files_to_check\n    p = subprocess.run(args=args, stdout=subprocess.PIPE)\n    result = p.stdout.decode()\n    print(result)\n    if 'Success: no issues found' not in result:\n        exit(1)\n\n\nif __name__ == '__main__':\n    main()\n", "path": "contrib/admin/mypy-with-ignore.py"}, {"content": "# Copyright (C) 2015-2021 Regents of the University of California\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"SSH into the toil appliance container running on the leader of the cluster.\"\"\"\nimport argparse\nimport logging\nimport sys\n\nfrom toil.common import parser_with_common_options\nfrom toil.provisioners import cluster_factory\nfrom toil.statsAndLogging import set_logging_from_options\nfrom typing import List\n\nlogger = logging.getLogger(__name__)\n\n\ndef main() -> None:\n    parser = parser_with_common_options(provisioner_options=True, jobstore_option=False)\n    parser.add_argument(\"--insecure\", action='store_true',\n                        help=\"Temporarily disable strict host key checking.\")\n    parser.add_argument(\"--sshOption\", dest='sshOptions', default=[], action='append',\n                        help=\"Pass an additional option to the SSH command.\")\n    parser.add_argument(\"--grafana_port\", dest='grafana_port', default=3000,\n                        help=\"Assign a local port to be used for the Grafana dashboard.\")\n    parser.add_argument('args', nargs=argparse.REMAINDER)\n    options = parser.parse_args()\n    set_logging_from_options(options)\n\n    # Since we collect all the remaining arguments at the end for a command to\n    # run, it's easy to lose options.\n    if len(options.args) > 0 and options.args[0].startswith('-'):\n        logger.warning('Argument \\'%s\\' interpreted as a command to run '\n                       'despite looking like an option.', options.args[0])\n\n    cluster = cluster_factory(provisioner=options.provisioner,\n                              clusterName=options.clusterName,\n                              zone=options.zone)\n    command = options.args if options.args else ['bash']\n    sshOptions: List[str] = options.sshOptions\n\n    # Forward ports:\n    # 3000 for Grafana dashboard\n    # 9090 for Prometheus dashboard\n    sshOptions.extend(['-L', f'{options.grafana_port}:localhost:3000',\n                       '-L', '9090:localhost:9090'])\n\n    cluster.getLeader().sshAppliance(*command, strict=not options.insecure, tty=sys.stdin.isatty(),\n                                     sshOptions=sshOptions)\n", "path": "src/toil/utils/toilSshCluster.py"}]}