-
Notifications
You must be signed in to change notification settings - Fork 71
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 ids
option for needimport
#1292
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1292 +/- ##
==========================================
- Coverage 86.87% 86.86% -0.02%
==========================================
Files 56 60 +4
Lines 6532 6914 +382
==========================================
+ Hits 5675 6006 +331
- Misses 857 908 +51
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
A more performant alternative to the `filter` option. Also, add and to improve the `needimport` tests
6776e98
to
5d5c061
Compare
try: | ||
with open(correct_need_import_path) as needs_file: | ||
needs_import_list = json.load(needs_file) | ||
except json.JSONDecodeError as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OSError
should also be caught, but there is already a TODO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(knowing what exceptions to handle is always a pain, I was reading this with interest recently https://discuss.python.org/t/extend-type-hints-to-cover-exceptions/23788/51)
@@ -146,6 +143,13 @@ def run(self) -> Sequence[nodes.Node]: | |||
|
|||
needs_config = NeedsSphinxConfig(self.config) | |||
data = needs_import_list["versions"][version] | |||
|
|||
if ids := self.options.get("ids"): | |||
id_list = [i.strip() for i in ids.split(",") if i.strip()] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can IDs contain a dynamic function, so you would have to use the 'split with dyn' function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh no definitely not, no dynamic functions here; this is intended for fast filtering
need["tags"] = need["tags"] + tags | ||
if tags := [ | ||
tag.strip() | ||
for tag in re.split("[;,]", self.options.get("tags", "")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, the new function should be used (or is that in a different open PR?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was already existing, but again no dynamic functions.
I feel you are confusing this directive with a need
declaration directive, that is the only place we use dynamic functions in the directive options
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR
A more performant alternative to the
filter
option.This PR also adds some other performance optimisations;
caching the schema load and not reading the import file twice (during validation)
Also, add to and improve the
needimport
tests