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

♻️ Restrict needs_global_options keys #1410

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chrisjsewell
Copy link
Member

@chrisjsewell chrisjsewell commented Feb 24, 2025

As discussed in #1409,
needs_global_options has overlapping functionality with needs_extra_options.
It makes more sense that needs_global_options is only used to define defaults for fields,
whereas needs_extra_options is for specifying new fields.

This PR restricts the keys allowed to:

  • any needs_extra_options item
  • any needs_extra_links item
  • collapse
  • constraints
  • hide
  • layout
  • status
  • style
  • tags

This means that projects with unknown keys will need to add them to needs_extra_options, e.g.

   needs_extra_options = ["option1"]
   needs_global_options = {
      'option1': 'Fix value'
   }

Currently, just a deprecation warning is emitted, if any other keys are found, and no actual functionality is changed;
this will be left for change in a later version


note, there may be further changes in the future, as per #1409, like changing the name to needs_field_defaults, but that will be left for later

Copy link

codecov bot commented Feb 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.28%. Comparing base (4e10030) to head (c25d81d).
Report is 116 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1410      +/-   ##
==========================================
+ Coverage   86.87%   88.28%   +1.40%     
==========================================
  Files          56       60       +4     
  Lines        6532     7159     +627     
==========================================
+ Hits         5675     6320     +645     
+ Misses        857      839      -18     
Flag Coverage Δ
pytests 88.28% <100.00%> (+1.40%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@danwos
Copy link
Member

danwos commented Feb 25, 2025

Thanks for the PR.

BTW: the way it works with the PR was how it was done releases ago.
You always needed both conf-options to add and modify the new extra_options.
But looks like this got somehow dropped/lost over time.

@chrisjsewell
Copy link
Member Author

Thanks for the PR.

BTW: the way it works with the PR was how it was done releases ago.

You always needed both conf-options to add and modify the new extra_options.

But looks like this got somehow dropped/lost over time.

Ah good to know, so shouldn't break anything then 😅

@chrisjsewell
Copy link
Member Author

chrisjsewell commented Feb 25, 2025

@danwos is it me or do some of the docs examples make no sense:

needs_global_options = {'status': ('closed', 'status.lower() in ["done", "resolved", "closed"]')}

This could never take effect, because it is checking for an already set status, in which case a default would not be used

needs_global_options = {
      'status': [
            ('fulfilled', 'status.lower() in ["done", "resolved", "closed"]', 'type=="req"'),
            ('done', 'status.lower() in ["done", "resolved", "closed"]', 'type=="task"'),
            ('implemented', 'status.lower() in ["done", "resolved", "closed"]', 'type=="spec"')
      ]
   }

Same as above, but also:
The 3rd value of the tuple is meant to be the default, so why does it look like a filter?
Also, also, the logic here is weird, as it effectively does:

for (value, predicate, default) in list:
	if predicate(item):
		field = value
    else:
        field = default

so this means only the final default can ever take effect, the others get overridden

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

Successfully merging this pull request may close these issues.

2 participants