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

access all needs in needs_warning call back #1335

Closed
lionabt opened this issue Oct 22, 2024 · 2 comments
Closed

access all needs in needs_warning call back #1335

lionabt opened this issue Oct 22, 2024 · 2 comments

Comments

@lionabt
Copy link

lionabt commented Oct 22, 2024

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
@PhilipPartsch
Copy link
Contributor

This is a duplicate of #1238, now tracked with #1322. I have an open PR to overcome this, #1248.

@lionabt lionabt closed this as completed Oct 24, 2024
@lionabt
Copy link
Author

lionabt commented Oct 24, 2024

duplicate issue. see comment above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants