From 655cdbfff99bd4f34f1498b70178cc8265462611 Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Fri, 17 Mar 2023 15:45:40 -0400 Subject: [PATCH 1/2] Run pre-commit autoupdate This patch is built off of `main` due to one of the `pre-commit` environments failing in its current pinned version, meaning this could potentially be part of a bugfix release. Signed-off-by: Alex Nelson --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d6274fe..57e17c2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,14 +1,14 @@ repos: - repo: https://github.com/psf/black - rev: 22.10.0 + rev: 23.1.0 hooks: - id: black - repo: https://github.com/pycqa/flake8 - rev: 5.0.4 + rev: 6.0.0 hooks: - id: flake8 - repo: https://github.com/pycqa/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort name: isort (python) From faac091ed29c377c5768e1aca15c6c6ab10e3269 Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Fri, 17 Mar 2023 15:46:47 -0400 Subject: [PATCH 2/2] Reformat per pre-commit Signed-off-by: Alex Nelson --- case_utils/case_file/__init__.py | 1 + case_utils/case_sparql_construct/__init__.py | 2 +- case_utils/case_sparql_select/__init__.py | 4 ++-- case_utils/ontology/src/ontology_and_version_iris.py | 3 ++- .../test_data_frame_to_table_text_json.py | 6 +++--- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/case_utils/case_file/__init__.py b/case_utils/case_file/__init__.py index ec51a85..9a4095f 100644 --- a/case_utils/case_file/__init__.py +++ b/case_utils/case_file/__init__.py @@ -39,6 +39,7 @@ DEFAULT_PREFIX = "http://example.org/kb/" + # Shortcut syntax for defining an immutable named tuple is noted here: # https://docs.python.org/3/library/typing.html#typing.NamedTuple # via the "See also" box here: https://docs.python.org/3/library/collections.html#collections.namedtuple diff --git a/case_utils/case_sparql_construct/__init__.py b/case_utils/case_sparql_construct/__init__.py index 6c9826c..06cd8a4 100644 --- a/case_utils/case_sparql_construct/__init__.py +++ b/case_utils/case_sparql_construct/__init__.py @@ -98,7 +98,7 @@ def main() -> None: construct_query_result = in_graph.query(construct_query_object) _logger.debug("type(construct_query_result) = %r." % type(construct_query_result)) _logger.debug("len(construct_query_result) = %d." % len(construct_query_result)) - for (row_no, row) in enumerate(construct_query_result): + for row_no, row in enumerate(construct_query_result): if row_no == 0: _logger.debug("row[0] = %r." % (row,)) out_graph.add(row) diff --git a/case_utils/case_sparql_select/__init__.py b/case_utils/case_sparql_select/__init__.py index 1e94265..4e5d6a2 100644 --- a/case_utils/case_sparql_select/__init__.py +++ b/case_utils/case_sparql_select/__init__.py @@ -86,10 +86,10 @@ def graph_and_query_to_data_frame( select_query_object = rdflib.plugins.sparql.processor.prepareQuery( select_query_text, initNs=nsdict ) - for (row_no, row) in enumerate(_graph.query(select_query_object)): + for row_no, row in enumerate(_graph.query(select_query_object)): tally = row_no + 1 record = [] - for (column_no, column) in enumerate(row): + for column_no, column in enumerate(row): if column is None: column_value = "" elif ( diff --git a/case_utils/ontology/src/ontology_and_version_iris.py b/case_utils/ontology/src/ontology_and_version_iris.py index 74f2304..7ac429d 100644 --- a/case_utils/ontology/src/ontology_and_version_iris.py +++ b/case_utils/ontology/src/ontology_and_version_iris.py @@ -28,7 +28,8 @@ def concept_is_cdo_concept(n_concept: rdflib.URIRef) -> bool: """ - This function is purposefully distinct from the function used in case_validate. Within this script, the publishing history of CASE and UCO is reviewed.""" + This function is purposefully distinct from the function used in case_validate. Within this script, the publishing history of CASE and UCO is reviewed. + """ concept_iri = str(n_concept) return ( concept_iri.startswith("https://ontology.unifiedcyberontology.org/") diff --git a/tests/case_utils/case_sparql_select/test_data_frame_to_table_text_json.py b/tests/case_utils/case_sparql_select/test_data_frame_to_table_text_json.py index 9e5cc24..8fc160d 100644 --- a/tests/case_utils/case_sparql_select/test_data_frame_to_table_text_json.py +++ b/tests/case_utils/case_sparql_select/test_data_frame_to_table_text_json.py @@ -36,9 +36,9 @@ ) -def make_data_frame_to_json_table_text_parameters() -> typing.Iterator[ - typing.Tuple[str, str, bool, bool] -]: +def make_data_frame_to_json_table_text_parameters() -> ( + typing.Iterator[typing.Tuple[str, str, bool, bool]] +): for use_header in [False, True]: for use_index in [False, True]: for output_mode in ["csv", "html", "json", "md", "tsv"]: