Skip to content

Commit

Permalink
Fix some typing
Browse files Browse the repository at this point in the history
  • Loading branch information
dragon-dxw committed Dec 12, 2024
1 parent 32ac4e7 commit 2a31354
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ repos:
rev: v1.13.0
hooks:
- id: mypy
additional_dependencies:
- ds-caselaw-marklogic-api-client
files: ^ds-caselaw-ingester/

- repo: https://github.com/pre-commit/mirrors-prettier
Expand Down
12 changes: 6 additions & 6 deletions ds-caselaw-ingester/lambda_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
rollbar.init(os.getenv("ROLLBAR_TOKEN"), environment=os.getenv("ROLLBAR_ENV"))

api_client = MarklogicApiClient(
host=os.getenv("MARKLOGIC_HOST", default=None),
username=os.getenv("MARKLOGIC_USER", default=None),
password=os.getenv("MARKLOGIC_PASSWORD", default=None),
use_https=os.getenv("MARKLOGIC_USE_HTTPS", default=False),
host=os.getenv("MARKLOGIC_HOST", default=""),
username=os.getenv("MARKLOGIC_USER", default=""),
password=os.getenv("MARKLOGIC_PASSWORD", default=""),
use_https=bool(os.getenv("MARKLOGIC_USE_HTTPS", default=False)),
user_agent=f"ds-caselaw-ingester/unknown {DEFAULT_USER_AGENT}",
)

Expand Down Expand Up @@ -229,7 +229,7 @@ def extract_metadata(tar: tarfile.TarFile, consignment_reference: str):
return decoder.decode(te_metadata_file.read().decode("utf-8"))


def extract_uri(metadata: dict, consignment_reference: str) -> str:
def extract_uri(metadata: dict, consignment_reference: str) -> DocumentURIString:
uri = metadata["parameters"]["PARSER"].get("uri", "")

if uri:
Expand All @@ -238,7 +238,7 @@ def extract_uri(metadata: dict, consignment_reference: str) -> str:
if not uri:
uri = f"failures/{consignment_reference}"

return uri
return DocumentURIString(uri)


# called by tests
Expand Down
2 changes: 1 addition & 1 deletion ds-caselaw-ingester/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def test_handler_messages_v2(
)
assert annotation.call_count == 2
doc.identifiers.add.assert_not_called()
doc.identifiers.save.assert_not_called()
doc.save_identifiers.assert_not_called()

@patch("lambda_function.api_client", autospec=True)
@patch("lambda_function.boto3.session.Session")
Expand Down

0 comments on commit 2a31354

Please sign in to comment.