@@ -1007,26 +1007,43 @@ def _do_validate_(self, context: ValidationContext) -> bool:
10071007
10081008 logger .debug ("Running %s checks for Requirement '%s'" , len (self ._checks ), self .name )
10091009 all_passed = True
1010- for check in [_ for _ in self ._checks
1011- if not context .settings .skip_checks
1012- or _ .identifier not in context .settings .skip_checks ]:
1013-
1010+ checks_to_perform = [
1011+ _ for _ in self ._checks
1012+ if not context .settings .skip_checks
1013+ or _ .identifier not in context .settings .skip_checks
1014+ ]
1015+ for check in checks_to_perform :
10141016 try :
10151017 if check .overridden and not check .requirement .profile .identifier == context .profile_identifier :
10161018 logger .debug ("Skipping check '%s' because overridden by '%r'" ,
10171019 check .identifier , [_ .identifier for _ in check .overridden_by ])
10181020 continue
1019- context .validator .notify (RequirementCheckValidationEvent (
1020- EventType .REQUIREMENT_CHECK_VALIDATION_START , check ))
1021+ # Determine whether to skip event notification for inherited profiles
1022+ skip_event_notify = False
1023+ if check .requirement .profile .identifier != context .profile_identifier and \
1024+ context .settings .disable_inherited_profiles_issue_reporting :
1025+ logger .debug ("Inherited profiles reporting disabled. "
1026+ "Skipping requirement %s as it belongs to an inherited profile %s" ,
1027+ check .requirement .identifier , check .requirement .profile .identifier )
1028+ skip_event_notify = True
1029+ # Notify the start of the check execution if not skip_event_notify is set to True
1030+ if not skip_event_notify :
1031+ context .validator .notify (RequirementCheckValidationEvent (
1032+ EventType .REQUIREMENT_CHECK_VALIDATION_START , check ))
1033+ # Execute the check
10211034 check_result = check .execute_check (context )
10221035 logger .debug ("Result of check %s: %s" , check .identifier , check_result )
10231036 context .result ._add_executed_check (check , check_result )
1024- context .validator .notify (RequirementCheckValidationEvent (
1025- EventType .REQUIREMENT_CHECK_VALIDATION_END , check , validation_result = check_result ))
1037+ # Notify the end of the check execution if not skip_event_notify is set to True
1038+ if not skip_event_notify :
1039+ context .validator .notify (RequirementCheckValidationEvent (
1040+ EventType .REQUIREMENT_CHECK_VALIDATION_END , check , validation_result = check_result ))
10261041 logger .debug ("Ran check '%s'. Got result %s" , check .identifier , check_result )
1042+ # Ensure the check result is a boolean
10271043 if not isinstance (check_result , bool ):
10281044 logger .warning ("Ignoring the check %s as it returned the value %r instead of a boolean" , check .name )
10291045 raise RuntimeError (f"Ignoring invalid result from check { check .name } " )
1046+ # Aggregate the check result
10301047 all_passed = all_passed and check_result
10311048 if not all_passed and context .fail_fast :
10321049 break
@@ -1040,7 +1057,8 @@ def _do_validate_(self, context: ValidationContext) -> bool:
10401057 logger .warning ("Consider reporting this as a bug." )
10411058 if logger .isEnabledFor (logging .DEBUG ):
10421059 logger .exception (e )
1043-
1060+ skipped_checks = set (self ._checks ) - set (checks_to_perform )
1061+ context .result .skipped_checks .update (skipped_checks )
10441062 logger .debug ("Checks for Requirement '%s' completed. Checks passed? %s" , self .name , all_passed )
10451063 return all_passed
10461064
@@ -1625,7 +1643,7 @@ def __initialise__(cls, validation_settings: ValidationSettings):
16251643 profiles = [profile ]
16261644
16271645 # add inherited profiles if enabled
1628- if validation_settings .enable_profile_inheritance :
1646+ if not validation_settings .disable_inherited_profiles_issue_reporting :
16291647 profiles .extend (profile .inherited_profiles )
16301648 logger .debug ("Inherited profiles: %r" , profile .inherited_profiles )
16311649
@@ -1656,9 +1674,20 @@ def __initialise__(cls, validation_settings: ValidationSettings):
16561674 if severity < severity_validation :
16571675 continue
16581676 # count the checks
1659- requirement_checks = [_ for _ in requirement .get_checks_by_level (LevelCollection .get (severity .name ))
1660- if not _ .overridden or
1661- _ .requirement .profile .identifier == target_profile_identifier ]
1677+ requirement_checks = [
1678+ _
1679+ for _ in requirement .get_checks_by_level (
1680+ LevelCollection .get (severity .name )
1681+ )
1682+ if (
1683+ not validation_settings .skip_checks
1684+ or _ .identifier not in validation_settings .skip_checks
1685+ )
1686+ and (
1687+ not _ .overridden
1688+ or _ .requirement .profile .identifier == target_profile_identifier
1689+ )
1690+ ]
16621691 num_checks = len (requirement_checks )
16631692 requirement_checks_count += num_checks
16641693 if num_checks > 0 :
@@ -2325,12 +2354,20 @@ class ValidationSettings:
23252354 #: The profile identifier to validate against
23262355 profile_identifier : str = DEFAULT_PROFILE_IDENTIFIER
23272356 #: Flag to enable profile inheritance
2357+ # Use the `enable_profile_inheritance` flag with caution: disable inheritance only if the
2358+ # target validation profile is fully self-contained and does not rely on definitions
2359+ # from inherited profiles (e.g., entities defined upstream). For modularization
2360+ # purposes, some base entities and properties are defined in the base RO-Crate
2361+ # profile and are intentionally not redefined in specialized profiles; they are
2362+ # required for validations targeting those specializations and therefore cannot be skipped.
2363+ # Nevertheless, the validator can still suppress issue reporting for checks defined
2364+ # in inherited profiles by setting disable_inherited_profiles_issue_reporting to `True`.
23282365 enable_profile_inheritance : bool = True
23292366 # Validation settings
23302367 #: Flag to abort on first error
23312368 abort_on_first : Optional [bool ] = False
2332- #: Flag to disable inherited profiles reporting
2333- disable_inherited_profiles_reporting : bool = False
2369+ #: Flag to disable reporting of issues related to inherited profiles
2370+ disable_inherited_profiles_issue_reporting : bool = False
23342371 #: Flag to disable remote crate download
23352372 disable_remote_crate_download : bool = True
23362373 # Requirement settings
0 commit comments