31
31
#
32
32
# -------------------------------------------------------------------------
33
33
from __future__ import annotations
34
- from typing import NoReturn
34
+ from typing import Dict , Generator , List
35
35
import logging
36
36
37
37
# -------------------------------------------------------------------------
@@ -117,25 +117,25 @@ def get_feature(self, feature):
117
117
"""
118
118
return self .__feature .get (feature , None ) # can also be explicitly None
119
119
120
- def set_feature (self , feature , value ):
120
+ def set_feature (self , feature , value ) -> None :
121
121
"""
122
122
Databases can implement certain features.
123
123
"""
124
124
self .__feature [feature ] = value
125
125
126
- def close (self ):
126
+ def close (self ) -> None :
127
127
"""
128
128
Close the specified database.
129
129
"""
130
130
raise NotImplementedError
131
131
132
- def db_has_bm_changes (self ):
132
+ def db_has_bm_changes (self ) -> bool :
133
133
"""
134
134
Return whether there were bookmark changes during the session.
135
135
"""
136
136
raise NotImplementedError
137
137
138
- def find_backlink_handles (self , handle , include_classes = None ):
138
+ def find_backlink_handles (self , handle : AnyHandle , include_classes = None ):
139
139
"""
140
140
Find all objects that hold a reference to the object handle.
141
141
@@ -645,7 +645,9 @@ def get_tag_from_handle(self, handle: TagHandle) -> Tag | None:
645
645
"""
646
646
raise NotImplementedError
647
647
648
- def get_citation_handles (self , sort_handles = False , locale = glocale ):
648
+ def get_citation_handles (
649
+ self , sort_handles : bool = False , locale = glocale
650
+ ) -> List [CitationHandle ]:
649
651
"""
650
652
Return a list of database handles, one handle for each Citation in
651
653
the database.
@@ -657,7 +659,7 @@ def get_citation_handles(self, sort_handles=False, locale=glocale):
657
659
"""
658
660
raise NotImplementedError
659
661
660
- def get_event_handles (self ):
662
+ def get_event_handles (self ) -> List [ EventHandle ] :
661
663
"""
662
664
Return a list of database handles, one handle for each Event in the
663
665
database.
@@ -667,7 +669,9 @@ def get_event_handles(self):
667
669
"""
668
670
raise NotImplementedError
669
671
670
- def get_family_handles (self , sort_handles = False , locale = glocale ):
672
+ def get_family_handles (
673
+ self , sort_handles : bool = False , locale = glocale
674
+ ) -> List [FamilyHandle ]:
671
675
"""
672
676
Return a list of database handles, one handle for each Family in
673
677
the database.
@@ -682,7 +686,9 @@ def get_family_handles(self, sort_handles=False, locale=glocale):
682
686
"""
683
687
raise NotImplementedError
684
688
685
- def get_media_handles (self , sort_handles = False , locale = glocale ):
689
+ def get_media_handles (
690
+ self , sort_handles : bool = False , locale = glocale
691
+ ) -> List [MediaHandle ]:
686
692
"""
687
693
Return a list of database handles, one handle for each Media in
688
694
the database.
@@ -697,7 +703,7 @@ def get_media_handles(self, sort_handles=False, locale=glocale):
697
703
"""
698
704
raise NotImplementedError
699
705
700
- def get_note_handles (self ):
706
+ def get_note_handles (self ) -> List [ NoteHandle ] :
701
707
"""
702
708
Return a list of database handles, one handle for each Note in the
703
709
database.
@@ -707,7 +713,9 @@ def get_note_handles(self):
707
713
"""
708
714
raise NotImplementedError
709
715
710
- def get_person_handles (self , sort_handles = False , locale = glocale ):
716
+ def get_person_handles (
717
+ self , sort_handles : bool = False , locale = glocale
718
+ ) -> List [PersonHandle ]:
711
719
"""
712
720
Return a list of database handles, one handle for each Person in
713
721
the database.
@@ -722,7 +730,9 @@ def get_person_handles(self, sort_handles=False, locale=glocale):
722
730
"""
723
731
raise NotImplementedError
724
732
725
- def get_place_handles (self , sort_handles = False , locale = glocale ):
733
+ def get_place_handles (
734
+ self , sort_handles : bool = False , locale = glocale
735
+ ) -> List [PlaceHandle ]:
726
736
"""
727
737
Return a list of database handles, one handle for each Place in
728
738
the database.
@@ -737,7 +747,7 @@ def get_place_handles(self, sort_handles=False, locale=glocale):
737
747
"""
738
748
raise NotImplementedError
739
749
740
- def get_repository_handles (self ):
750
+ def get_repository_handles (self ) -> List [ RepositoryHandle ] :
741
751
"""
742
752
Return a list of database handles, one handle for each Repository in
743
753
the database.
@@ -747,7 +757,9 @@ def get_repository_handles(self):
747
757
"""
748
758
raise NotImplementedError
749
759
750
- def get_source_handles (self , sort_handles = False , locale = glocale ):
760
+ def get_source_handles (
761
+ self , sort_handles : bool = False , locale = glocale
762
+ ) -> List [SourceHandle ]:
751
763
"""
752
764
Return a list of database handles, one handle for each Source in
753
765
the database.
@@ -762,7 +774,9 @@ def get_source_handles(self, sort_handles=False, locale=glocale):
762
774
"""
763
775
raise NotImplementedError
764
776
765
- def get_tag_handles (self , sort_handles = False , locale = glocale ):
777
+ def get_tag_handles (
778
+ self , sort_handles : bool = False , locale = glocale
779
+ ) -> List [TagHandle ]:
766
780
"""
767
781
Return a list of database handles, one handle for each Tag in
768
782
the database.
@@ -899,7 +913,7 @@ def get_name_group_keys(self):
899
913
"""
900
914
raise NotImplementedError
901
915
902
- def get_name_group_mapping (self , surname ) :
916
+ def get_name_group_mapping (self , surname : str ) -> str :
903
917
"""
904
918
Return the default grouping name for a surname.
905
919
"""
@@ -971,55 +985,55 @@ def get_person_event_types(self):
971
985
"""
972
986
raise NotImplementedError
973
987
974
- def get_raw_citation_data (self , handle : CitationHandle ) -> Citation :
988
+ def get_raw_citation_data (self , handle : CitationHandle ) -> Citation | None :
975
989
"""
976
990
Return raw (serialized and pickled) Citation object from handle
977
991
"""
978
992
raise NotImplementedError
979
993
980
- def get_raw_event_data (self , handle : EventHandle ) -> Event :
994
+ def get_raw_event_data (self , handle : EventHandle ) -> Event | None :
981
995
"""
982
996
Return raw (serialized and pickled) Event object from handle
983
997
"""
984
998
raise NotImplementedError
985
999
986
- def get_raw_family_data (self , handle : FamilyHandle ) -> Family :
1000
+ def get_raw_family_data (self , handle : FamilyHandle ) -> Family | None :
987
1001
"""
988
1002
Return raw (serialized and pickled) Family object from handle
989
1003
"""
990
1004
raise NotImplementedError
991
1005
992
- def get_raw_media_data (self , handle : MediaHandle ) -> Media :
1006
+ def get_raw_media_data (self , handle : MediaHandle ) -> Media | None :
993
1007
"""
994
1008
Return raw (serialized and pickled) Family object from handle
995
1009
"""
996
1010
raise NotImplementedError
997
1011
998
- def get_raw_note_data (self , handle : NoteHandle ) -> Note :
1012
+ def get_raw_note_data (self , handle : NoteHandle ) -> Note | None :
999
1013
"""
1000
1014
Return raw (serialized and pickled) Note object from handle
1001
1015
"""
1002
1016
raise NotImplementedError
1003
1017
1004
- def get_raw_person_data (self , handle : PersonHandle ) -> Person :
1018
+ def get_raw_person_data (self , handle : PersonHandle ) -> Person | None :
1005
1019
"""
1006
1020
Return raw (serialized and pickled) Person object from handle
1007
1021
"""
1008
1022
raise NotImplementedError
1009
1023
1010
- def get_raw_place_data (self , handle : PlaceHandle ) -> Place :
1024
+ def get_raw_place_data (self , handle : PlaceHandle ) -> Place | None :
1011
1025
"""
1012
1026
Return raw (serialized and pickled) Place object from handle
1013
1027
"""
1014
1028
raise NotImplementedError
1015
1029
1016
- def get_raw_repository_data (self , handle : RepositoryHandle ) -> Repository :
1030
+ def get_raw_repository_data (self , handle : RepositoryHandle ) -> Repository | None :
1017
1031
"""
1018
1032
Return raw (serialized and pickled) Repository object from handle
1019
1033
"""
1020
1034
raise NotImplementedError
1021
1035
1022
- def get_raw_source_data (self , handle : SourceHandle ) -> Source :
1036
+ def get_raw_source_data (self , handle : SourceHandle ) -> Source | None :
1023
1037
"""
1024
1038
Return raw (serialized and pickled) Source object from handle
1025
1039
"""
@@ -1184,121 +1198,121 @@ def is_open(self) -> bool:
1184
1198
"""
1185
1199
raise NotImplementedError
1186
1200
1187
- def iter_citations (self ):
1201
+ def iter_citations (self ) -> Generator [ Citation ] :
1188
1202
"""
1189
1203
Return an iterator over objects for Citations in the database
1190
1204
"""
1191
1205
raise NotImplementedError
1192
1206
1193
- def iter_events (self ):
1207
+ def iter_events (self ) -> Generator [ Event ] :
1194
1208
"""
1195
1209
Return an iterator over objects for Events in the database
1196
1210
"""
1197
1211
raise NotImplementedError
1198
1212
1199
- def iter_families (self ):
1213
+ def iter_families (self ) -> Generator [ Family ] :
1200
1214
"""
1201
1215
Return an iterator over objects for Families in the database
1202
1216
"""
1203
1217
raise NotImplementedError
1204
1218
1205
- def iter_media (self ):
1219
+ def iter_media (self ) -> Generator [ Media ] :
1206
1220
"""
1207
1221
Return an iterator over objects for Medias in the database
1208
1222
"""
1209
1223
raise NotImplementedError
1210
1224
1211
- def iter_notes (self ):
1225
+ def iter_notes (self ) -> Generator [ Note ] :
1212
1226
"""
1213
1227
Return an iterator over objects for Notes in the database
1214
1228
"""
1215
1229
raise NotImplementedError
1216
1230
1217
- def iter_people (self ):
1231
+ def iter_people (self ) -> Generator [ Person ] :
1218
1232
"""
1219
1233
Return an iterator over objects for Persons in the database
1220
1234
"""
1221
1235
raise NotImplementedError
1222
1236
1223
- def iter_places (self ):
1237
+ def iter_places (self ) -> Generator [ Place ] :
1224
1238
"""
1225
1239
Return an iterator over objects for Places in the database
1226
1240
"""
1227
1241
raise NotImplementedError
1228
1242
1229
- def iter_repositories (self ):
1243
+ def iter_repositories (self ) -> Generator [ Repository ] :
1230
1244
"""
1231
1245
Return an iterator over objects for Repositories in the database
1232
1246
"""
1233
1247
raise NotImplementedError
1234
1248
1235
- def iter_sources (self ):
1249
+ def iter_sources (self ) -> Generator [ Source ] :
1236
1250
"""
1237
1251
Return an iterator over objects for Sources in the database
1238
1252
"""
1239
1253
raise NotImplementedError
1240
1254
1241
- def iter_tags (self ):
1255
+ def iter_tags (self ) -> Generator [ Tag ] :
1242
1256
"""
1243
1257
Return an iterator over objects for Tags in the database
1244
1258
"""
1245
1259
raise NotImplementedError
1246
1260
1247
- def iter_citation_handles (self ):
1261
+ def iter_citation_handles (self ) -> Generator [ CitationHandle ] :
1248
1262
"""
1249
1263
Return an iterator over handles for Citations in the database
1250
1264
"""
1251
1265
raise NotImplementedError
1252
1266
1253
- def iter_event_handles (self ):
1267
+ def iter_event_handles (self ) -> Generator [ EventHandle ] :
1254
1268
"""
1255
1269
Return an iterator over handles for Events in the database
1256
1270
"""
1257
1271
raise NotImplementedError
1258
1272
1259
- def iter_family_handles (self ):
1273
+ def iter_family_handles (self ) -> Generator [ FamilyHandle ] :
1260
1274
"""
1261
1275
Return an iterator over handles for Families in the database
1262
1276
"""
1263
1277
raise NotImplementedError
1264
1278
1265
- def iter_media_handles (self ):
1279
+ def iter_media_handles (self ) -> Generator [ MediaHandle ] :
1266
1280
"""
1267
1281
Return an iterator over handles for Media in the database
1268
1282
"""
1269
1283
raise NotImplementedError
1270
1284
1271
- def iter_note_handles (self ):
1285
+ def iter_note_handles (self ) -> Generator [ NoteHandle ] :
1272
1286
"""
1273
1287
Return an iterator over handles for Notes in the database
1274
1288
"""
1275
1289
raise NotImplementedError
1276
1290
1277
- def iter_person_handles (self ):
1291
+ def iter_person_handles (self ) -> Generator [ PersonHandle ] :
1278
1292
"""
1279
1293
Return an iterator over handles for Persons in the database
1280
1294
"""
1281
1295
raise NotImplementedError
1282
1296
1283
- def iter_place_handles (self ):
1297
+ def iter_place_handles (self ) -> Generator [ PlaceHandle ] :
1284
1298
"""
1285
1299
Return an iterator over handles for Places in the database
1286
1300
"""
1287
1301
raise NotImplementedError
1288
1302
1289
- def iter_repository_handles (self ):
1303
+ def iter_repository_handles (self ) -> Generator [ RepositoryHandle ] :
1290
1304
"""
1291
1305
Return an iterator over handles for Repositories in the database
1292
1306
"""
1293
1307
raise NotImplementedError
1294
1308
1295
- def iter_source_handles (self ):
1309
+ def iter_source_handles (self ) -> Generator [ SourceHandle ] :
1296
1310
"""
1297
1311
Return an iterator over handles for Sources in the database
1298
1312
"""
1299
1313
raise NotImplementedError
1300
1314
1301
- def iter_tag_handles (self ):
1315
+ def iter_tag_handles (self ) -> Generator [ TagHandle ] :
1302
1316
"""
1303
1317
Return an iterator over handles for Tags in the database
1304
1318
"""
@@ -1317,7 +1331,7 @@ def load(
1317
1331
"""
1318
1332
raise NotImplementedError
1319
1333
1320
- def report_bm_change (self ):
1334
+ def report_bm_change (self ) -> None :
1321
1335
"""
1322
1336
Add 1 to the number of bookmark changes during this session.
1323
1337
"""
@@ -1463,7 +1477,7 @@ def get_dbname(self):
1463
1477
"""
1464
1478
raise NotImplementedError
1465
1479
1466
- def get_summary (self ):
1480
+ def get_summary (self ) -> Dict [ str , int | str ] :
1467
1481
"""
1468
1482
Returns dictionary of summary item.
1469
1483
Should include, if possible:
0 commit comments