Skip to content

Commit 33f0844

Browse files
committed
Add type signatures in support of strict type-review on example.py
This patch does not take the last step of adding the `--strict` flag in type review. This patch satisfies a run of the type checker in strict mode against the script `/example.py` and all of the library functions that script depends on. Additionally, all touched `__init__` methods observed to not have `*args` & `**kwargs` catch-alls had those added and incorporated into `super()` calls (which will assist with tying to, e.g., knowledge base namespace helpers available in the ultimate parent class `UcoThing`). One effect reflected back into the example script is that the EXIF dictionary incorporation logic needed its own keyword parameter, because the `**kwargs` catch-all parameter being used was an atypical usage versus the pass-through-to-superclass functionality of `**kwargs`. This patch also adjusted one class position, moving `MessageThread` under `ObservableObject` instead of `UcoObject`. A follow-on patch will do the same for `CaseInvestigation`. Signed-off-by: Alex Nelson <[email protected]>
1 parent 1331422 commit 33f0844

File tree

6 files changed

+78
-49
lines changed

6 files changed

+78
-49
lines changed

case_mapping/case/investigation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ def __init__(
4747

4848

4949
class CaseInvestigation(UcoObject):
50-
def __init__(self, name=None, focus=None, description=None, core_objects=None):
50+
def __init__(
51+
self, *args: Any, focus=None, core_objects=None, **kwargs: Any
52+
) -> None:
5153
"""
5254
An investigative action is a CASE object that represents the who, where, when of investigation
5355
:param name: The name of an investigation (e.g., Murder of Suspect B,.)
@@ -57,13 +59,11 @@ def __init__(self, name=None, focus=None, description=None, core_objects=None):
5759
object e.g., Persons involved in investigation, Investigation into a Murder, object refrences a
5860
case-object for a phone investigative action
5961
"""
60-
super().__init__()
62+
super().__init__(*args, **kwargs)
6163
self["@type"] = "case-investigation:Investigation"
6264
self._str_vars(
6365
**{
64-
"uco-core:name": name,
6566
"case-investigation:focus": focus,
66-
"uco-core:description": description,
6767
}
6868
)
6969
self.append_core_objects(core_objects)

case_mapping/drafting/entities.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Any
2+
13
from ..base import Facet, UcoObject, unpack_args_array
24

35

@@ -175,6 +177,7 @@ def __init__(
175177
class SocialMediaActivityFacet(Facet):
176178
def __init__(
177179
self,
180+
*args: Any,
178181
body=None,
179182
page_title=None,
180183
author_identifier=None,
@@ -187,7 +190,8 @@ def __init__(
187190
created_time=None,
188191
application=None,
189192
url=None,
190-
):
193+
**kwargs: Any,
194+
) -> None:
191195
"""
192196
Used to represent activity on social platfomrs
193197
:param body: The text of the post/message
@@ -203,7 +207,7 @@ def __init__(
203207
:param application: the application used for creating the post
204208
:param application: the URL of the post
205209
"""
206-
super().__init__()
210+
super().__init__(*args, **kwargs)
207211

208212
self["@type"] = ["drafting:SocialMediaActivityFacet", "uco-core:Facet"]
209213

case_mapping/uco/identity.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
from typing import Dict, Optional
1+
from typing import Any, Dict, Optional
22

33
from ..base import Facet, IdentityAbstraction, UcoObject
44

55

66
class BirthInformationFacet(Facet):
7-
def __init__(self, birthdate=None):
7+
def __init__(self, *args: Any, birthdate=None, **kwargs: Any) -> None:
88
"""
99
:param birthdate: the date of birth of an identity
1010
"""
11-
super().__init__()
11+
super().__init__(*args, **kwargs)
1212
self["@type"] = "uco-identity:BirthInformationFacet"
1313
self._datetime_vars(**{"uco-identity:birthdate": birthdate})
1414

@@ -31,12 +31,14 @@ def __init__(self, name: Optional[str] = None, facets=None):
3131

3232

3333
class SimpleNameFacet(Facet):
34-
def __init__(self, given_name=None, family_name=None):
34+
def __init__(
35+
self, *args: Any, given_name=None, family_name=None, **kwargs: Any
36+
) -> None:
3537
"""
3638
:param given_name: Full name of the identity of person
3739
:param family_name: Family name of identity of person
3840
"""
39-
super().__init__()
41+
super().__init__(*args, **kwargs)
4042
self["@type"] = "uco-identity:SimpleNameFacet"
4143
self._str_vars(
4244
**{

case_mapping/uco/location.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
from typing import Optional
1+
from typing import Any, Optional
22

33
from ..base import Facet, UcoObject
44

55

66
class Location(UcoObject):
7-
def __init__(self, facets=None):
8-
super().__init__()
7+
def __init__(self, *args: Any, **kwargs: Any) -> None:
8+
super().__init__(*args, **kwargs)
99
self["@type"] = "uco-location:Location"
10-
self.append_facets(facets)
1110

1211

1312
class LatLongCoordinatesFacet(Facet):

0 commit comments

Comments
 (0)