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

👌 Add type warnings of extra options in external/import reads #1389

Merged
merged 4 commits into from
Jan 27, 2025

Conversation

chrisjsewell
Copy link
Member

@chrisjsewell chrisjsewell commented Jan 26, 2025

Currently, the value of all extra options is expected to be a string; other types are not supported in various aspects of sphinx-needs (such as needextend, dynamic functions and filtering), and in-fact are already silently converted to strings during processing,
see:

needs_info[key] = str(needs_kwargs[key])

This PR adds the needs.mistyped_external_values and needs.mistyped_import_values warnings for non-string values, for needs_external_needs and needimport sources respectively. The warning is only emitted once per source, to avoid creating too many warnings.

Note, in the future it is hoped that more types will be supported via configuration in needs_extra_options (see #1338)

Currently, the value of all extra options is expected to be a string; other types are not supported in other aspects of sphinx-needs, such as `needextend` and dynamic functions.

This PR adds the `needs. mistyped_external_values ` and `needs.mistyped_import_values` warnings for non-string values, for `needs_external_needs` and `needimport` sources respectively.
The warning is only emitted once per source, to avoid creating too many warnings.

Note, in the future it is likely that more types will be supported via configuration in `needs_extra_options` (see #1338)
@chrisjsewell chrisjsewell changed the title 👌 Add type checking of extra options to external/import reads 👌 Add type checking of extra options in external/import reads Jan 26, 2025
Copy link

codecov bot commented Jan 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.00%. Comparing base (4e10030) to head (4c1ea0c).
Report is 102 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1389      +/-   ##
==========================================
+ Coverage   86.87%   88.00%   +1.12%     
==========================================
  Files          56       60       +4     
  Lines        6532     7142     +610     
==========================================
+ Hits         5675     6285     +610     
  Misses        857      857              
Flag Coverage Δ
pytests 88.00% <100.00%> (+1.12%) ⬆️

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.

@chrisjsewell chrisjsewell changed the title 👌 Add type checking of extra options in external/import reads 👌 Add type warnings of extra options in external/import reads Jan 26, 2025
@chrisjsewell chrisjsewell requested a review from ubmarco January 26, 2025 21:40
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.

LGTM

@chrisjsewell chrisjsewell merged commit 540a321 into master Jan 27, 2025
18 checks passed
@chrisjsewell chrisjsewell deleted the external-json-type-check branch January 27, 2025 08:55
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