From a9bb4a7122df6d9d4a764de52244c6ec75789ead Mon Sep 17 00:00:00 2001 From: Paolo Melchiorre Date: Mon, 5 Dec 2022 18:38:37 +0100 Subject: Add pyupgrade with --py310-plus in pre-commit (#103) --- core/ld.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'core/ld.py') diff --git a/core/ld.py b/core/ld.py index f70642a..4b01e71 100644 --- a/core/ld.py +++ b/core/ld.py @@ -1,7 +1,6 @@ import datetime import os import urllib.parse as urllib_parse -from typing import Dict, List, Optional, Union from pyld import jsonld from pyld.jsonld import JsonLdError @@ -396,7 +395,7 @@ def builtin_document_loader(url: str, options={}): ) -def canonicalise(json_data: Dict, include_security: bool = False) -> Dict: +def canonicalise(json_data: dict, include_security: bool = False) -> dict: """ Given an ActivityPub JSON-LD document, round-trips it through the LD systems to end up in a canonicalised, compacted format. @@ -408,7 +407,7 @@ def canonicalise(json_data: Dict, include_security: bool = False) -> Dict: """ if not isinstance(json_data, dict): raise ValueError("Pass decoded JSON data into LDDocument") - context: Union[str, List[str]] + context: str | list[str] if include_security: context = [ "https://www.w3.org/ns/activitystreams", @@ -422,7 +421,7 @@ def canonicalise(json_data: Dict, include_security: bool = False) -> Dict: return jsonld.compact(jsonld.expand(json_data), context) -def get_list(container, key) -> List: +def get_list(container, key) -> list: """ Given a JSON-LD value (that can be either a list, or a dict if it's just one item), always returns a list""" @@ -438,7 +437,7 @@ def format_ld_date(value: datetime.datetime) -> str: return value.strftime(DATETIME_FORMAT) -def parse_ld_date(value: Optional[str]) -> Optional[datetime.datetime]: +def parse_ld_date(value: str | None) -> datetime.datetime | None: if value is None: return None try: -- cgit v1.2.3