Skip to content

Commit 5c31f6c

Browse files
committed
Made code more Pythonic
1 parent 7723610 commit 5c31f6c

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

bugbug/bug_features.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,19 +1106,26 @@ def extract_valid_file_path(self, word: str) -> str:
11061106
return ""
11071107

11081108
def __call__(self, bug: bugzilla.BugDict, **kwargs) -> list[str]:
1109-
text = bug.get("summary", "") + " " + bug["comments"][0]["text"]
1110-
text = self.remove_urls(text)
1109+
text = self.remove_urls(
1110+
bug.get("summary", "") + " " + bug["comments"][0]["text"]
1111+
)
11111112

1112-
words = text.split()
1113-
file_paths = [self.extract_valid_file_path(word) for word in words]
1114-
file_paths = [path for path in file_paths if path]
1113+
file_paths = [
1114+
path
1115+
for word in text.split()
1116+
if (path := self.extract_valid_file_path(word))
1117+
]
11151118

11161119
all_paths: list[str] = []
11171120

11181121
for path in file_paths:
11191122
parts = path.split("/")
11201123
all_paths.extend(part for part in parts if part)
1121-
all_paths.extend(
1122-
subpath for i in range(len(parts)) if (subpath := "/".join(parts[i:]))
1123-
)
1124+
if len(parts) > 1:
1125+
all_paths.extend(
1126+
subpath
1127+
for i in range(len(parts))
1128+
if (subpath := "/".join(parts[i:]))
1129+
)
1130+
11241131
return all_paths

0 commit comments

Comments
 (0)