Skip to content

Commit a1ab77d

Browse files
authored
↪️ Merge pull request #472 from js-truework/patch-1
[#471] Safely get line_number from PotentialSecret
2 parents b206dc2 + 64aee10 commit a1ab77d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

detect_secrets/core/secrets_collection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ def __iter__(self) -> Generator[Tuple[str, PotentialSecret], None, None]:
213213
for filename in sorted(self.files):
214214
secrets = self[filename]
215215

216-
# NOTE: If line numbers aren't supplied, they will default to 0.
217-
for secret in sorted(secrets, key=lambda x: (x.line_number, x.secret_hash, x.type)):
216+
# NOTE: If line numbers aren't supplied, they are supposed to default to 0.
217+
for secret in sorted(secrets, key=lambda x: (x.get(line_number, 0), x.secret_hash, x.type)):
218218
yield filename, secret
219219

220220
def __bool__(self) -> bool:

0 commit comments

Comments
 (0)