Skip to content

Commit d5d6395

Browse files
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 <[email protected]> Change-Id: Ice9703afbf104e3529f2c1b29ba8ba680eb07d94
1 parent 617a3f2 commit d5d6395

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

scripts/format-code.sh

+1
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ function get_file_type()
208208
*JSON\ data*) echo "json" && return ;;
209209
*POSIX\ shell*) echo "sh" && return ;;
210210
*Python\ script*) echo "python" && return ;;
211+
*python3\ script*) echo "python" && return ;;
211212
*zsh\ shell*) echo "zsh" && return ;;
212213
esac
213214

tools/owners

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
#!/bin/env python3
1+
#!/usr/bin/env python3
22
import argparse
33
import json
44
import os
55
import re
6-
import yaml
6+
from typing import Dict, List, Optional, Set, TypedDict
77

8+
import yaml
89
from sh import git # type: ignore
9-
from typing import Dict, List, Set, TypedDict, Optional
1010
from yaml.loader import SafeLoader
1111

1212
# A list of Gerrit users (email addresses).
1313
# Some OWNERS files have empty lists for 'owners' or 'reviewers', which
1414
# results in a None type for the value.
1515
UsersList = Optional[List[str]]
1616

17+
1718
# A YAML node with an extra line number.
1819
class NumberedNode(TypedDict):
1920
line_number: int
@@ -67,8 +68,6 @@ class CommitMatch:
6768
.splitlines()
6869
)
6970

70-
root_owners = owners[""]
71-
7271
self.owners: Set[str] = set()
7372
self.reviewers: Set[str] = set()
7473

0 commit comments

Comments
 (0)