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

♻️ Don't process dynamic functions on internal need fields #1387

Merged
merged 5 commits into from
Jan 27, 2025

Conversation

chrisjsewell
Copy link
Member

@chrisjsewell chrisjsewell commented Jan 26, 2025

For most "internal" need fields it does not make sense that these would be dynamic, and anyway this would fail since their values are not string types.

In this PR, we skip dynamic function processing, for core fields that should not be altered by the user.

For most "internal" need fields it does not make sense that these would be dynamic,
and anyway this would fail since they are not string types.

In this PR, we skip dynamic function processing, for core fields that should not be altered by the user.
@chrisjsewell chrisjsewell requested a review from ubmarco January 26, 2025 13:28
Copy link

codecov bot commented Jan 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.20%. Comparing base (4e10030) to head (61adc01).
Report is 105 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1387      +/-   ##
==========================================
+ Coverage   86.87%   88.20%   +1.32%     
==========================================
  Files          56       60       +4     
  Lines        6532     7129     +597     
==========================================
+ Hits         5675     6288     +613     
+ Misses        857      841      -16     
Flag Coverage Δ
pytests 88.20% <100.00%> (+1.32%) ⬆️

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.

@@ -167,33 +174,38 @@ class CoreFieldParameters(TypedDict):
"type": {
"description": "Type of the need.",
"schema": {"type": "string", "default": ""},
"allow_df": True,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can the type and below type specific values be set by a df?

Copy link
Member Author

@chrisjsewell chrisjsewell Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well thats a discussion to be had; I wouldn't expect them to, but they technically can already, so removing them would be a breaking change.
Currently, in this PR I have basically just allowed all str/list[str] fields, so as to be approximately back-compatible

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's deprecate this, only usecase are 'type fields' coming from needimport or external needs. Users are in control of the JSONs, so they can set primary data there.

@chrisjsewell chrisjsewell requested a review from ubmarco January 27, 2025 09:36
Copy link
Member

@ubmarco ubmarco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally approve of this as this is something that users shouldn't be doing.
Not sure whether we break anyone's workflow.
I'd deprecate the dynamic functions on core fields, then finally remove that possibility. This PR makes our life simpler by making this configurable. Thanks.

@chrisjsewell chrisjsewell merged commit 663d8d4 into master Jan 27, 2025
18 checks passed
@chrisjsewell chrisjsewell deleted the restrict-dynamic-func-fields branch January 27, 2025 13:03
chrisjsewell added a commit that referenced this pull request Feb 20, 2025
It is unintended and unlikely the dynamic functions would have been used
in there fields, but just in case we issue a warning of the deprecation,
so that we can remove them in the future

fields affected: `type`, `type_name`, `type_prefix`, `type_color`,
`type_style`.

this follows on from #1387 and the fields now allowed are:

- ``status``
- ``tags``
- ``style``
- ``constraints``
- all `needs_extra_options`
- all `needs_extra_links`
- all `needs_global_options`
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