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

build: update pre-commit hooks #511

Merged
merged 3 commits into from
Jul 23, 2024
Merged
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
8 changes: 4 additions & 4 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: v4.6.0
hooks:
- id: end-of-file-fixer
exclude_types: [svg]
Expand All @@ -15,7 +15,7 @@ repos:
- id: file-contents-sorter
files: ^fuji_server\/data\/.*.txt$
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.12.0
rev: v2.13.0
hooks:
- id: pretty-format-ini
args: [--autofix]
Expand All @@ -24,14 +24,14 @@ repos:
- id: pretty-format-yaml
args: [--autofix, --indent, '2']
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.4
rev: v1.5.5
hooks:
- id: insert-license
types: [python]
args: [--license-filepath=docs/license_header.txt]
exclude: docs
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.11
rev: v0.5.1
hooks:
- id: ruff
args: [--fix, --show-fixes, --exit-non-zero-on-fix]
Expand Down
6 changes: 3 additions & 3 deletions fuji_server/helper/metadata_collector_rdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,9 @@ def parse_metadata(self):
if isinstance(rdf_response.get("@context"), list):
for ctxi, ctxt in enumerate(rdf_response.get("@context")):
if "schema.org" in ctxt:
rdf_response["@context"][
ctxi
] = "https://schema.org/docs/jsonldcontext.json"
rdf_response["@context"][ctxi] = (
"https://schema.org/docs/jsonldcontext.json"
)
if isinstance(rdf_response.get("@context"), str):
if "schema.org" in rdf_response.get("@context"):
rdf_response["@context"] = "https://schema.org/docs/jsonldcontext.json"
Expand Down
6 changes: 3 additions & 3 deletions fuji_server/helper/request_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,9 @@ def content_negotiate(self, metric_id="", ignore_html=True):
xmltree = lxml.etree.XML(self.response_content, xmlparser)
root_element = xmltree.tag
if content_truncated:
self.parse_response = (
self.response_content
) = lxml.etree.tostring(xmltree)
self.parse_response = self.response_content = (
lxml.etree.tostring(xmltree)
)
except Exception:
self.logger.warning(
"%s : Parsing XML document failed !" % metric_id
Expand Down
6 changes: 3 additions & 3 deletions fuji_server/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def _deserialize(data, klass):

if klass in (int, float, str, bool):
return _deserialize_primitive(data, klass)
elif klass == object:
elif klass is object:
return _deserialize_object(data)
elif klass == datetime.date:
return deserialize_date(data)
Expand All @@ -30,9 +30,9 @@ def _deserialize(data, klass):
# if klass.__extra__ == dict:
# return _deserialize_dict(data, klass.__args__[1])
elif hasattr(klass, "__origin__"):
if klass.__origin__ == list or klass.__origin__ == list:
if klass.__origin__ is list or klass.__origin__ is list:
return _deserialize_list(data, klass.__args__[0])
if klass.__origin__ == dict:
if klass.__origin__ is dict:
return _deserialize_dict(data, klass.__args__[1])
else:
return deserialize_model(data, klass)
Expand Down
8 changes: 4 additions & 4 deletions metrics_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Copy the YAML content of this metric file to a new metric file and save the file

To define own metrics you can restrict the number of metrics and add configuration options to a limited number of existing metrics.

### Configure metrics and tests to be performed
### Configure metrics and tests to be performed

To restrict metrics choose those you want to use from the 0.6 list of metrics and tests and simply delete tests or metrics which you do not wish to be performed during your assessments.

Expand All @@ -26,12 +26,12 @@ For all metrics and tests you can change the YAML properties*metric_short_name*,

For some tests you can define additional parameters. For example, one can specify exactly which metadata elements, licenses, metadata standards or vocabularies are expected.

Generally, these specifications are defined using the YAML property *community_requirements* which has to be a dictionary containing the subproperties *target*, *modality*, and *required*.
Generally, these specifications are defined using the YAML property *community_requirements* which has to be a dictionary containing the subproperties *target*, *modality*, and *required*.

* *target* defines the test targets, defined in the F-UJI ontology, such as licenses, metadata properties etc. which is represented by a controlled list of values which is used for tests by default.
* *required* has to be a list which defines the necessary property values
* *modality* defines if *all* or *any* of *required* values need to be present to pass the test.
*match* specifies how matching values are identified: *wildcard* for wildcard-like match rules like 'test*'; *full* when a full match is required.
* *modality* defines if *all* or *any* of *required* values need to be present to pass the test.
*match* specifies how matching values are identified: *wildcard* for wildcard-like match rules like 'test*'; *full* when a full match is required.
*target_property* additionally defines the property of the *target* object in which matches are searched for, by default the property *name* or *label* is used for this purpose.
*modality* and *match* are currently not yet implemented, thus still hardcoded :( but may be implemented in future versions.

Expand Down
12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,15 @@ ignore = [

[tool.ruff.lint.isort]
known-first-party = ["fuji_server", "tests"]

[tool.ruff.lint.per-file-ignores]
# Note: ruff does not understand, that the logger, which gets passed through multiple inheritance is actually
# a logger instance. It would not apply f-strings to logging messages. But let's ignore UP031 and UP032 for now.
"fuji_server/evaluators/*.py" = [
"UP031", # printf-string-formatting
"UP032" # f-string
]
"fuji_server/helper/*.py" = [
"UP031", # printf-string-formatting
"UP032" # f-string
]
1 change: 1 addition & 0 deletions tests/helper/test_preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
They mock the fuji_server/data path to not override the files under fuji server

"""

import json
from typing import Any

Expand Down
Loading