summaryrefslogtreecommitdiff
path: root/test/end-to-end/target-cache
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-06-27 15:35:45 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-08-29 17:19:14 +0200
commit9e4b146941a9a31d952b19cfcf016f248882a826 (patch)
treed5be705912d9e05c7f6b90b3dd4fc0bc319d83ec /test/end-to-end/target-cache
parent0d8aeb4655446d05ecbb3fc3336ebe02741e91bf (diff)
downloadjustbuild-9e4b146941a9a31d952b19cfcf016f248882a826.tar.gz
python: Add type hints and fix style in test scripts
For maximum compatibility, we use the uppercase types from the typing package instead of the built-in types, therefore compliant with PEP 484 and PEP 526.
Diffstat (limited to 'test/end-to-end/target-cache')
-rw-r--r--test/end-to-end/target-cache/data/pydicts/bar.py1
-rwxr-xr-xtest/end-to-end/target-cache/data/pydicts/dict_converter.py10
-rw-r--r--test/end-to-end/target-cache/data/pydicts/foo.py1
3 files changed, 8 insertions, 4 deletions
diff --git a/test/end-to-end/target-cache/data/pydicts/bar.py b/test/end-to-end/target-cache/data/pydicts/bar.py
index 251cbab3..4a85fc0c 100644
--- a/test/end-to-end/target-cache/data/pydicts/bar.py
+++ b/test/end-to-end/target-cache/data/pydicts/bar.py
@@ -12,4 +12,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+# type: ignore
{"foo": "", None: ["bar"]}
diff --git a/test/end-to-end/target-cache/data/pydicts/dict_converter.py b/test/end-to-end/target-cache/data/pydicts/dict_converter.py
index 61cf2e8d..605f7615 100755
--- a/test/end-to-end/target-cache/data/pydicts/dict_converter.py
+++ b/test/end-to-end/target-cache/data/pydicts/dict_converter.py
@@ -16,24 +16,26 @@
import sys
import ast
import json
-import yaml
+import yaml # this package has lax type hints
+
+from typing import Any
if len(sys.argv) < 4:
print(f"usage: {sys.argv[0]} [py|json|yaml] [py|json|yaml] <file>")
sys.exit(1)
with open(sys.argv[3]) as f:
- data = {}
+ data: Any = {}
if sys.argv[1] == "py":
data = ast.literal_eval(f.read())
elif sys.argv[1] == "json":
data = json.load(f)
elif sys.argv[1] == "yaml":
- data = yaml.load(f)
+ data = yaml.load(f, Loader=yaml.Loader) # type: ignore
if (sys.argv[2] == "py"):
print(data)
elif sys.argv[2] == "json":
print(json.dumps(data, indent=2))
elif sys.argv[2] == "yaml":
- print(yaml.dump(data, indent=2))
+ print(yaml.dump(data, indent=2)) # type: ignore
diff --git a/test/end-to-end/target-cache/data/pydicts/foo.py b/test/end-to-end/target-cache/data/pydicts/foo.py
index 3218bb76..854c3a3c 100644
--- a/test/end-to-end/target-cache/data/pydicts/foo.py
+++ b/test/end-to-end/target-cache/data/pydicts/foo.py
@@ -12,4 +12,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+# type: ignore
{"foo": "", 0: 4711}