Skip to content

Commit

Permalink
Replace newer type hint syntax with older syntax supported by Python 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
eecavanna committed Oct 15, 2024
1 parent 6c47cf4 commit 7f9510d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions refscan/lib/ReferenceList.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Dict
from typing import List, Dict, Union
from pathlib import Path
from dataclasses import fields, astuple
from collections import UserList
Expand Down Expand Up @@ -88,7 +88,7 @@ def make_group_key(reference: Reference) -> tuple:
groups = groupby(sorted(self.data), key=make_group_key)
return groups

def dump_to_tsv_file(self, file_path: str | Path) -> None:
def dump_to_tsv_file(self, file_path: Union[str, Path]) -> None:
r"""
Helper function that dumps the references to a TSV file at the specified path.
"""
Expand Down
3 changes: 2 additions & 1 deletion refscan/lib/ViolationList.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from typing import Union
from pathlib import Path
from dataclasses import fields, astuple
from collections import UserList
Expand All @@ -12,7 +13,7 @@ class ViolationList(UserList):
"""

def dump_to_tsv_file(
self, file_path: str | Path, include_name_of_collection_containing_target: bool = True
self, file_path: Union[str, Path], include_name_of_collection_containing_target: bool = True
) -> None:
"""
Helper function that dumps the violations to a TSV file at the specified path.
Expand Down
4 changes: 2 additions & 2 deletions refscan/refgraph.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from enum import Enum
from pathlib import Path
from typing import Optional
from typing import Optional, Union
from typing_extensions import Annotated
import json
import base64
Expand Down Expand Up @@ -47,7 +47,7 @@ def load_template(resource_path: str) -> str:
return resources.files(package_name).joinpath(resource_path).read_text(encoding="utf-8")


def encode_json_value_as_base64_str(json_value: dict | list) -> str:
def encode_json_value_as_base64_str(json_value: Union[dict, list]) -> str:
r"""Helper function that encodes the specified JSON value as a base64 string."""

value_as_string = json.dumps(json_value)
Expand Down

0 comments on commit 7f9510d

Please sign in to comment.