Skip to content

Commit 3123a35

Browse files
committed
Type-annotate mix_utils directory
With these changes, `/mix_utils` passes `mypy --strict`. Disclaimer: Participation by NIST in the creation of the documentation of mentioned software is not intended to imply a recommendation or endorsement by the National Institute of Standards and Technology, nor is it intended to imply that any specific software is necessarily the best available for the purpose. Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
1 parent 947307d commit 3123a35

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

mix_utils/test_duplicate.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import utils
55

66

7-
def check_app_name(app_name, app_names, app_objects, uuid):
7+
def check_app_name(
8+
app_name: str, app_names: list[str], app_objects: list[dict[str, Any]], uuid: str
9+
) -> dict[str, Any]:
810
# c_check = utils.CheckDuplicate()
911
observable_app = utils.check_value(
1012
app_name,
@@ -17,7 +19,13 @@ def check_app_name(app_name, app_names, app_objects, uuid):
1719
return observable_app
1820

1921

20-
def check_geo_coordinates(latitude, longitude, geo_coordinates, geo_objects, uuid):
22+
def check_geo_coordinates(
23+
latitude: float,
24+
longitude: float,
25+
geo_coordinates: list[str],
26+
geo_objects: list[dict[str, Any]],
27+
uuid: str,
28+
) -> dict[str, Any]:
2129
# c_check = utils.CheckDuplicate()
2230
observable_app = utils.check_value(
2331
latitude,
@@ -31,7 +39,7 @@ def check_geo_coordinates(latitude, longitude, geo_coordinates, geo_objects, uui
3139
return observable_app
3240

3341

34-
def generateTraceAppName(app_name, uuid):
42+
def generateTraceAppName(app_name: str, uuid: str) -> dict[str, Any]:
3543
observable = {
3644
"@type": "uco-observable:ApplicationFacet",
3745
"@id": uuid,
@@ -52,9 +60,9 @@ def generateTraceLocationCoordinate(
5260
return observable
5361

5462

55-
def test_app_name():
56-
app_names = list()
57-
app_objects = list()
63+
def test_app_name() -> None:
64+
app_names: list[str] = list()
65+
app_objects: list[dict[str, Any]] = list()
5866
app_1 = "Safari"
5967
uuid_1 = "kb:" + str(uuid.uuid4())
6068
check_app_name(app_1, app_names, app_objects, uuid_1)
@@ -85,9 +93,9 @@ def test_app_name():
8593
]
8694

8795

88-
def test_geo_coordinates():
89-
geo_coordinates = list()
90-
geo_objects = list()
96+
def test_geo_coordinates() -> None:
97+
geo_coordinates: list[str] = list()
98+
geo_objects: list[dict[str, Any]] = list()
9199
(lat_1, long_1, uuid_1) = (56.47267913, -71.17069244, "kb:" + str(uuid.uuid4()))
92100
check_geo_coordinates(lat_1, long_1, geo_coordinates, geo_objects, uuid_1)
93101
# print(f"\n 1) FT geo_coordinates={geo_coordinates}")

mix_utils/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ def check_value(
55
*args: Any,
66
value: str,
77
list_values: list[str],
8-
list_objects: list[dict],
9-
observable_generating_f: Callable[..., dict]
10-
) -> dict:
8+
list_objects: list[dict[str, Any]],
9+
observable_generating_f: Callable[..., dict[str, Any]]
10+
) -> dict[str, Any]:
1111
"""It checks if a specific value has been already generated related to an ObservableObject relying on
1212
the list of its values. This is meant to avoid duplication in the JSON/CASE file generated by the
1313
parsers (UFED, AXIOM etc.).

0 commit comments

Comments
 (0)