Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #79

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -21,15 +21,15 @@ repos:
- requests~=2.31
- Babel~=2.13
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.2
rev: v0.9.2
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
rev: v1.14.1
hooks:
- id: mypy
args: [--config-file=pyproject.toml]
Expand Down
2 changes: 1 addition & 1 deletion inputs/Individuals.json
Original file line number Diff line number Diff line change
Expand Up @@ -12096,7 +12096,7 @@
"sources": [
"‘Laves, Georg’, RKD Artists https://rkd.nl/artists/431018",
"‘Laves, Georg Heinrich Wilhelm’ in: F. Noack, Das Deutschtum in Rom seit dem Ausgang des Mittelalters (Stuttgart/Berlin/Leipzig 1927) vol. 2, p. 348",
"H. Knocke, ‘Laves, Georg Heinrich Wilhelm’, in: D. Böttcher, Dirk, K. Mlynek et al. (ed.), Hannoversches Biographisches Lexikon (Hannover 2002) pp. 224-225"
"H. Knocke, ‘Laves, Georg Heinrich Wilhelm’, in: D. Böttcher, Dirk, K. Mlynek et al. (ed.), Hannoversches Biographisches Lexikon (Hannover 2002) pp. 224-225"
],
"sources_other": [],
"surname": "Laves",
Expand Down
6 changes: 3 additions & 3 deletions python/data_parsing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
)

__all__ = [
"control_title",
"full_name_with_database",
"name_string",
"initialize_translation_database",
"initialize_database_for_xml",
"control_title",
"initialize_translation_database",
"name_string",
]
6 changes: 3 additions & 3 deletions python/data_parsing/load_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from typing_utils import Database, TranslationDictCleaned, TranslationDictCleanedTitles


def initialize_translation_database() -> (
tuple[TranslationDictCleanedTitles, TranslationDictCleaned, TranslationDictCleaned]
):
def initialize_translation_database() -> tuple[
TranslationDictCleanedTitles, TranslationDictCleaned, TranslationDictCleaned
]:
"""Reads the files containing all translations of titles and functions."""
with open("inputs/Translations/Titles.json", encoding="utf-8") as file:
titles = json.load(file)
Expand Down
2 changes: 1 addition & 1 deletion python/database_controls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"check_all_comments",
"check_all_placenames",
"check_all_sources",
"check_translations",
"control_date",
"control_functions",
"control_titles",
"check_translations",
"is_isni",
]
4 changes: 2 additions & 2 deletions python/database_searches/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from database_searches.search_wikidata import search_wikidata, unspecified_wikidate

__all__ = [
"search_wikidata",
"unspecified_wikidate",
"convert_wikidata_to_isni",
"search_isni_api",
"search_wikidata",
"unspecified_wikidate",
]
6 changes: 3 additions & 3 deletions python/date_functions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
__all__ = [
"check_date",
"check_date_earlier",
"check_date_for_missing_elements",
"check_date_later",
"create_document_date",
"extract_date",
"create_date_data",
"check_date_for_missing_elements",
"create_date_tuple",
"create_document_date",
"extract_date",
]
12 changes: 6 additions & 6 deletions python/date_functions/check_date_for_earlylate.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ def check_date_earlier(
or isinstance(row[4].value, date)
):
raise ValueError(f"Excel cells should not be dates. Please check {row}")
if not row[2].value or early_date[0] is not None and int(row[2].value) > int(early_date[0]):
if not row[2].value or (early_date[0] is not None and int(row[2].value) > int(early_date[0])):
return early_date
if early_date[0] is not None and int(row[2].value) < int(early_date[0]):
return row[2].value, row[3].value, row[4].value
if not row[3].value or early_date[1] is not None and int(row[3].value) > int(early_date[1]):
if not row[3].value or (early_date[1] is not None and int(row[3].value) > int(early_date[1])):
return early_date
if early_date[1] is not None and int(row[3].value) < int(early_date[1]):
return row[2].value, row[3].value, row[4].value
if not row[4].value or early_date[2] is not None and int(row[4].value) > int(early_date[2]):
if not row[4].value or (early_date[2] is not None and int(row[4].value) > int(early_date[2])):
return early_date
if early_date[2] is not None and int(row[4].value) < int(early_date[2]):
return row[2].value, row[3].value, row[4].value
Expand All @@ -56,15 +56,15 @@ def check_date_later(
or isinstance(row[4].value, date)
):
raise ValueError(f"Excel cells should not be dates. Please check {row}")
if not row[2].value or late_date[0] is not None and int(row[2].value) < int(late_date[0]):
if not row[2].value or (late_date[0] is not None and int(row[2].value) < int(late_date[0])):
return late_date
if late_date[0] is not None and int(row[2].value) > int(late_date[0]):
return row[2].value, row[3].value, row[4].value
if not row[3].value or late_date[1] is not None and int(row[3].value) < int(late_date[1]):
if not row[3].value or (late_date[1] is not None and int(row[3].value) < int(late_date[1])):
return late_date
if late_date[1] is not None and int(row[3].value) > int(late_date[1]):
return row[2].value, row[3].value, row[4].value
if not row[4].value or late_date[2] is not None and int(row[4].value) < int(late_date[2]):
if not row[4].value or (late_date[2] is not None and int(row[4].value) < int(late_date[2])):
return late_date
if late_date[2] is not None and int(row[4].value) > int(late_date[2]):
return row[2].value, row[3].value, row[4].value
Expand Down
44 changes: 23 additions & 21 deletions python/json_create_descriptive_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
if data["wikidata:id"]:
c_wikidata += 1
start_string = " Number of entries with"
if type_list != [] and skip or type_list != [0, 1, 2, 3, 4, 5] and not skip:
if (type_list != [] and skip) or (type_list != [0, 1, 2, 3, 4, 5] and not skip):
type_string = f"the types {' and '.join(str(i) for i in type_list)}:"
else:
type_string = "the full database:"
Expand All @@ -71,20 +71,22 @@
print(f"For the entries excluding {type_string}")
else:
print(f"For the entries of {type_string}")
print(f"{start_string} ISNI id: {c_isni}, {c_isni/c_surname:.2%}")
print(f"{start_string} 'Daniel' comment: {c_comment_daniel}, {c_comment_daniel/c_surname:.2%}")
print(f"{start_string} birth dates: {c_date_of_birth}, {c_date_of_birth/c_surname:.2%}")
print(f"{start_string} death dates: {c_date_of_death}, {c_date_of_death/c_surname:.2%}")
print(f"{start_string} functions: {c_functions}, {c_functions/c_surname:.2%}")
print(f"{start_string} images: {c_images}, {c_images/c_surname:.2%}")
print(f"{start_string} name: {c_name}, {c_name/c_surname:.2%}")
print(f"{start_string} place of birth: {c_place_of_birth}, {c_place_of_birth/c_surname:.2%}")
print(f"{start_string} place of death: {c_place_of_death}, {c_place_of_death/c_surname:.2%}")
print(f"{start_string} sources: {c_sources}, {c_sources/c_surname:.2%}")
print(f"{start_string} sources other: {c_sources_other}, {c_sources_other/c_surname:.2%}")
print(f"{start_string} surname: {c_surname}, {c_surname/c_surname:.2%}")
print(f"{start_string} titles: {c_titles}, {c_titles/c_surname:.2%}")
print(f"{start_string} wikidata id: {c_wikidata}, {c_wikidata/c_surname:.2%}")
print(f"{start_string} ISNI id: {c_isni}, {c_isni / c_surname:.2%}")
print(
f"{start_string} 'Daniel' comment: {c_comment_daniel}, {c_comment_daniel / c_surname:.2%}"
)
print(f"{start_string} birth dates: {c_date_of_birth}, {c_date_of_birth / c_surname:.2%}")

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

This expression logs
sensitive data (private)
as clear text.
This expression logs
sensitive data (private)
as clear text.
This expression logs
sensitive data (private)
as clear text.

Copilot Autofix AI 11 days ago

To fix the problem, we should avoid logging sensitive information directly. Instead, we can log only non-sensitive statistical summaries or anonymize the data before logging. In this case, we can remove the detailed logging of specific counts and percentages related to sensitive data and replace it with a more general summary.

  • Remove or anonymize the logging of sensitive data such as birth dates, death dates, and other personal information.
  • Update the logging statements to provide a general summary without exposing specific sensitive details.
  • Ensure that the changes do not alter the existing functionality of the code.
Suggested changeset 1
python/json_create_descriptive_stats.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/python/json_create_descriptive_stats.py b/python/json_create_descriptive_stats.py
--- a/python/json_create_descriptive_stats.py
+++ b/python/json_create_descriptive_stats.py
@@ -73,18 +73,16 @@
         print(f"For the entries of {type_string}")
-    print(f"{start_string} ISNI id: {c_isni}, {c_isni / c_surname:.2%}")
-    print(
-        f"{start_string} 'Daniel' comment: {c_comment_daniel}, {c_comment_daniel / c_surname:.2%}"
-    )
-    print(f"{start_string} birth dates: {c_date_of_birth}, {c_date_of_birth / c_surname:.2%}")
-    print(f"{start_string} death dates: {c_date_of_death}, {c_date_of_death / c_surname:.2%}")
-    print(f"{start_string} functions: {c_functions}, {c_functions / c_surname:.2%}")
-    print(f"{start_string} images: {c_images}, {c_images / c_surname:.2%}")
-    print(f"{start_string} name: {c_name}, {c_name / c_surname:.2%}")
-    print(f"{start_string} place of birth: {c_place_of_birth}, {c_place_of_birth / c_surname:.2%}")
-    print(f"{start_string} place of death: {c_place_of_death}, {c_place_of_death / c_surname:.2%}")
-    print(f"{start_string} sources: {c_sources}, {c_sources / c_surname:.2%}")
-    print(f"{start_string} sources other: {c_sources_other}, {c_sources_other / c_surname:.2%}")
-    print(f"{start_string} surname: {c_surname}, {c_surname / c_surname:.2%}")
-    print(f"{start_string} titles: {c_titles}, {c_titles / c_surname:.2%}")
-    print(f"{start_string} wikidata id: {c_wikidata}, {c_wikidata / c_surname:.2%}")
+    print(f"{start_string} ISNI id: {c_isni}")
+    print(f"{start_string} 'Daniel' comment: {c_comment_daniel}")
+    print(f"{start_string} birth dates: {c_date_of_birth}")
+    print(f"{start_string} death dates: {c_date_of_death}")
+    print(f"{start_string} functions: {c_functions}")
+    print(f"{start_string} images: {c_images}")
+    print(f"{start_string} name: {c_name}")
+    print(f"{start_string} place of birth: {c_place_of_birth}")
+    print(f"{start_string} place of death: {c_place_of_death}")
+    print(f"{start_string} sources: {c_sources}")
+    print(f"{start_string} sources other: {c_sources_other}")
+    print(f"{start_string} surname: {c_surname}")
+    print(f"{start_string} titles: {c_titles}")
+    print(f"{start_string} wikidata id: {c_wikidata}")
 
EOF
@@ -73,18 +73,16 @@
print(f"For the entries of {type_string}")
print(f"{start_string} ISNI id: {c_isni}, {c_isni / c_surname:.2%}")
print(
f"{start_string} 'Daniel' comment: {c_comment_daniel}, {c_comment_daniel / c_surname:.2%}"
)
print(f"{start_string} birth dates: {c_date_of_birth}, {c_date_of_birth / c_surname:.2%}")
print(f"{start_string} death dates: {c_date_of_death}, {c_date_of_death / c_surname:.2%}")
print(f"{start_string} functions: {c_functions}, {c_functions / c_surname:.2%}")
print(f"{start_string} images: {c_images}, {c_images / c_surname:.2%}")
print(f"{start_string} name: {c_name}, {c_name / c_surname:.2%}")
print(f"{start_string} place of birth: {c_place_of_birth}, {c_place_of_birth / c_surname:.2%}")
print(f"{start_string} place of death: {c_place_of_death}, {c_place_of_death / c_surname:.2%}")
print(f"{start_string} sources: {c_sources}, {c_sources / c_surname:.2%}")
print(f"{start_string} sources other: {c_sources_other}, {c_sources_other / c_surname:.2%}")
print(f"{start_string} surname: {c_surname}, {c_surname / c_surname:.2%}")
print(f"{start_string} titles: {c_titles}, {c_titles / c_surname:.2%}")
print(f"{start_string} wikidata id: {c_wikidata}, {c_wikidata / c_surname:.2%}")
print(f"{start_string} ISNI id: {c_isni}")
print(f"{start_string} 'Daniel' comment: {c_comment_daniel}")
print(f"{start_string} birth dates: {c_date_of_birth}")
print(f"{start_string} death dates: {c_date_of_death}")
print(f"{start_string} functions: {c_functions}")
print(f"{start_string} images: {c_images}")
print(f"{start_string} name: {c_name}")
print(f"{start_string} place of birth: {c_place_of_birth}")
print(f"{start_string} place of death: {c_place_of_death}")
print(f"{start_string} sources: {c_sources}")
print(f"{start_string} sources other: {c_sources_other}")
print(f"{start_string} surname: {c_surname}")
print(f"{start_string} titles: {c_titles}")
print(f"{start_string} wikidata id: {c_wikidata}")

Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
print(f"{start_string} death dates: {c_date_of_death}, {c_date_of_death / c_surname:.2%}")
print(f"{start_string} functions: {c_functions}, {c_functions / c_surname:.2%}")
print(f"{start_string} images: {c_images}, {c_images / c_surname:.2%}")
print(f"{start_string} name: {c_name}, {c_name / c_surname:.2%}")
print(f"{start_string} place of birth: {c_place_of_birth}, {c_place_of_birth / c_surname:.2%}")
print(f"{start_string} place of death: {c_place_of_death}, {c_place_of_death / c_surname:.2%}")
print(f"{start_string} sources: {c_sources}, {c_sources / c_surname:.2%}")
print(f"{start_string} sources other: {c_sources_other}, {c_sources_other / c_surname:.2%}")
print(f"{start_string} surname: {c_surname}, {c_surname / c_surname:.2%}")
print(f"{start_string} titles: {c_titles}, {c_titles / c_surname:.2%}")
print(f"{start_string} wikidata id: {c_wikidata}, {c_wikidata / c_surname:.2%}")


def create_total_statistics(filename: str) -> None:
Expand All @@ -104,12 +106,12 @@
start_string = " Number of entries with"
total_count = len(persons.keys())
print("For the full database:")
print(f"{start_string} type 0: {c_types[0]}, {c_types[0]/total_count:.2%}")
print(f"{start_string} type 1: {c_types[1]}, {c_types[1]/total_count:.2%}")
print(f"{start_string} type 2: {c_types[2]}, {c_types[2]/total_count:.2%}")
print(f"{start_string} type 3: {c_types[3]}, {c_types[3]/total_count:.2%}")
print(f"{start_string} type 4: {c_types[4]}, {c_types[4]/total_count:.2%}")
print(f"{start_string} type 5: {c_types[5]}, {c_types[5]/total_count:.2%}")
print(f"{start_string} type 0: {c_types[0]}, {c_types[0] / total_count:.2%}")
print(f"{start_string} type 1: {c_types[1]}, {c_types[1] / total_count:.2%}")
print(f"{start_string} type 2: {c_types[2]}, {c_types[2] / total_count:.2%}")
print(f"{start_string} type 3: {c_types[3]}, {c_types[3] / total_count:.2%}")
print(f"{start_string} type 4: {c_types[4]}, {c_types[4] / total_count:.2%}")
print(f"{start_string} type 5: {c_types[5]}, {c_types[5] / total_count:.2%}")


if __name__ == "__main__":
Expand Down
4 changes: 2 additions & 2 deletions python/json_geonames.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def update_placenames_with_geonames(filename: str) -> None:
"S",
}: # Places, islands, seas or estates
raise ValueError(
f"""Geonames ID for {value['en_GB']} is not a place, island or sea.
Please check https://www.geonames.org/{value['geonames_id']}"""
f"""Geonames ID for {value["en_GB"]} is not a place, island or sea.
Please check https://www.geonames.org/{value["geonames_id"]}"""
)

# Populate fields
Expand Down
26 changes: 13 additions & 13 deletions python/typing_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@
)

__all__ = [
"TranslationDictCleanedTitles",
"TranslationDictEntry",
"TranslationDictPlacenames",
"Database",
"DateData",
"DateTuple",
"FileData",
"IndividualsDict",
"IndividualsDictCleaned",
"IndividualsDictEntry",
"SeriesData",
"TranslationDict",
"TranslationDictCleaned",
"TranslationDictCleanedDocuments",
"TranslationDictCleanedPlacenames",
"TranslationDictTitles",
"TranslationDictEntryTitles",
"IndividualsDictEntry",
"TranslationDictCleanedTitles",
"TranslationDictEntry",
"TranslationDictEntryPlacenames",
"IndividualsDict",
"IndividualsDictCleaned",
"Database",
"SeriesData",
"DateData",
"FileData",
"DateTuple",
"TranslationDictEntryTitles",
"TranslationDictPlacenames",
"TranslationDictTitles",
]
4 changes: 2 additions & 2 deletions python/xlsx_functions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
from xlsx_functions.translate import translate_xlsx

__all__ = [
"add_identifier_columns",
"compare_rows",
"fill_in_xlsx",
"parse_file",
"parse_series",
"sanitize_xlsx",
"translate_xlsx",
"compare_rows",
"add_identifier_columns",
]
6 changes: 3 additions & 3 deletions python/xml_functions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
from xml_functions.xml_writer import XMLWriter

__all__ = [
"add_unitdate",
"XMLWriter",
"add_dao",
"add_dateset",
"add_geognames",
"add_persname",
"add_unitdate",
"add_unittitle",
"fix_daoset",
"add_dao",
"XMLWriter",
]
6 changes: 3 additions & 3 deletions python/xml_make_ead.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ def _create_xml_file(self) -> None:
for i in self.database.document_titles.keys()
if i not in self.used_translations
)
assert (
not unused_translations
), f"Found the following unused translations:\n{unused_translations}"
assert not unused_translations, (
f"Found the following unused translations:\n{unused_translations}"
)

# Make sure there are no missing translations
with open(self.log_missing_translations, encoding="utf-8") as log:
Expand Down
Loading