format-code: handle incorrect 'env python3'
I noticed the `tools/owners` file was not getting the linters ran
correctly and upon investigation I found that it had the wrong path
for env, which caused `file` to give incorrect results.
Fix the path in tools/owners, reformat and fix linter issues, and
ensure the scripts can handle python3 scripts with the wrong env
path.
I checked the codebase and there was only one other script, which
happens to reside in openbmc/openbmc, which used this incorrect
path. Therefore this change should have no effect on existing
repositories.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ice9703afbf104e3529f2c1b29ba8ba680eb07d94
diff --git a/scripts/format-code.sh b/scripts/format-code.sh
index 2eab096..fefbae3 100755
--- a/scripts/format-code.sh
+++ b/scripts/format-code.sh
@@ -208,6 +208,7 @@
*JSON\ data*) echo "json" && return ;;
*POSIX\ shell*) echo "sh" && return ;;
*Python\ script*) echo "python" && return ;;
+ *python3\ script*) echo "python" && return ;;
*zsh\ shell*) echo "zsh" && return ;;
esac
diff --git a/tools/owners b/tools/owners
index 249ea5a..752967b 100755
--- a/tools/owners
+++ b/tools/owners
@@ -1,12 +1,12 @@
-#!/bin/env python3
+#!/usr/bin/env python3
import argparse
import json
import os
import re
-import yaml
+from typing import Dict, List, Optional, Set, TypedDict
+import yaml
from sh import git # type: ignore
-from typing import Dict, List, Set, TypedDict, Optional
from yaml.loader import SafeLoader
# A list of Gerrit users (email addresses).
@@ -14,6 +14,7 @@
# results in a None type for the value.
UsersList = Optional[List[str]]
+
# A YAML node with an extra line number.
class NumberedNode(TypedDict):
line_number: int
@@ -67,8 +68,6 @@
.splitlines()
)
- root_owners = owners[""]
-
self.owners: Set[str] = set()
self.reviewers: Set[str] = set()