Skip to content

access all needs in needs_warning call back #1335

@lionabt

Description

@lionabt

Hello,
currently I try to do cross checks between needs using needs_warnings. Unfortunately the needs_warning call backs do not have a direct access to all needs. A workaround is to collect all needs in a global variable (list or dict for easier access using ID) in the first needs_warnings call back.

allNeeds=[]
def my_custom_warning_collector(need, log):
    allNeeds.append(need)
def my_custom_warning(need, log):
    # some checks    
    # some cross checks
    return False
needs_warnings = {
   'my_warning_collector': my_custom_warning_collector
   'my_custom_warning' : my_custom_warning
}

But this is clumsy and might lead to issues (e.g. needs_warnings call order might change).

Would it be possible to extend warning callbacks so that all needs can be accessed (as already available in dynamic functions see https://sphinx-needs.readthedocs.io/en/latest/configuration.html#incremental-build-support) or is there better way to do cross checks?

def my_custom_warning(need, log, needs):
    # some checks
    # some cross checks
    return false

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions