Skip to content

Commit

Permalink
🐛Fix .get to be getattr
Browse files Browse the repository at this point in the history
PotentialSecret is not a dictionary, so do getattr and not .get
Fixes #472
  • Loading branch information
KevinHock committed Aug 1, 2021
1 parent f0a8fb1 commit 7e14cda
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion detect_secrets/core/secrets_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,14 @@ def __iter__(self) -> Generator[Tuple[str, PotentialSecret], None, None]:
secrets = self[filename]

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

def __bool__(self) -> bool:
Expand Down

0 comments on commit 7e14cda

Please sign in to comment.