Skip to content

Commit

Permalink
fix redact typing
Browse files Browse the repository at this point in the history
  • Loading branch information
llimllib committed Jan 25, 2024
1 parent 5f533d0 commit 1389528
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/python/readme_metrics/PayloadBuilder.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from collections.abc import Mapping
import importlib
import json
from json import JSONDecodeError
Expand Down Expand Up @@ -366,13 +365,16 @@ def _process_body(self, content_type, body):

return {"mimeType": content_type, "text": body}

def redact_dict(self, mapping: Mapping):
def redact_dict(self, mapping: dict) -> dict:
def _redact_value(val):
if isinstance(val, str):
return f"[REDACTED {len(val)}]"

return "[REDACTED]"

if not self.allowlist and not self.denylist:
return mapping

result = {}
for key, value in mapping.items():
if self.denylist and key in self.denylist:
Expand Down

0 comments on commit 1389528

Please sign in to comment.