Skip to content

Commit

Permalink
Rename severities hard-coded tuple to mutable set
Browse files Browse the repository at this point in the history
This lets `allow_infos` to influence the `all_warn` variable
appropriately.  With this patch, the new `test_126.py` now passes.

References:
* #126

Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
  • Loading branch information
ajnelson-nist committed Feb 28, 2022
1 parent 1d8686f commit ea68381
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pyshacl/shape.py
Expand Up @@ -477,12 +477,16 @@ def validate(
focus_value_nodes = self.value_nodes(target_graph, focus)
filter_reports: bool = False
allow_conform: bool = False
allowed_severities: Set[URIRef] = set()
if allow_infos:
allowed_severities.add(SH_Info)
if self.severity == SH_Info:
allow_conform = True
else:
filter_reports = True
if allow_warnings:
allowed_severities.add(SH_Info)
allowed_severities.add(SH_Warning)
if self.severity in (SH_Warning, SH_Info):
allow_conform = True
else:
Expand Down Expand Up @@ -516,7 +520,7 @@ def validate(
v_str, v_node, v_parts = _r_inner
severity_bits = list(filter(lambda p: p[0] == v_node and p[1] == SH_resultSeverity, v_parts))
if severity_bits:
all_warn = all_warn and severity_bits[0][2] in (SH_Warning, SH_Info)
all_warn = all_warn and severity_bits[0][2] in allowed_severities
non_conformant = not all_warn
else:
non_conformant = non_conformant or (not _is_conform)
Expand Down

0 comments on commit ea68381

Please sign in to comment.