-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Refactor depth filtering logic #10200
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests β
Additional details and impacted files@@ Coverage Diff @@
## main #10200 +/- ##
==========================================
+ Coverage 95.84% 95.86% +0.02%
==========================================
Files 175 175
Lines 19056 19053 -3
==========================================
+ Hits 18264 18265 +1
+ Misses 792 788 -4
|
This comment has been minimized.
This comment has been minimized.
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.
Thank you for the merge request ! LGTM, some nits:
Co-authored-by: Pierre Sassoulas <[email protected]>
for more information, see https://pre-commit.ci
Thanks for the review, your suggestions make sense. One thing I noticed when playing around with it. If you call pyreverse for a subpackage and apply a depth limit. For example: pyreverse --max-depth 1 package.subpackage The diagram is correctly generated and starts only at subpackage. However the depth limit is still calculated with respect to the root package. I think it would be more intuitive to calculate depth relative to subpackage in this case. What do you think? |
This comment has been minimized.
This comment has been minimized.
However I am unsure how to achive this given that pyreverse lets you specify multiple packages to analyse |
Yeah hard to reconcile all the arguments. Maybe it's easier to add a warning like "You asked for depth=1 but linked |
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.
Thank you for the refactor! I agree with Pierre, I would go for a warning right now for the case you mentioned.
Thanks for the review and for the suggestion regarding the warning! For properly implementing this warning I would need to implement this in main.py so that I dont have to gather the arguments passed. Maybe it makes more sense to just document this behavior instead? |
Yes, maybe adding a short notice in the help text of the option that explains how the counting works/where it starts would be the best solution for now. |
From experience no one ever read the documentation, so I would favor a warning (unless it's really unreasonable to do it of course). |
I agree with Pierre that documentation is hardly read, so a warning would be much more effective in guiding users. However, to properly detect this edge case, I would need access to the original specified by the user (self.args in main.py) inside DiadefsHandler. Right now, I donβt see a straightforward way to pass this information without modifying the argument flow, but Iβll think about possible solutions. If anyone has suggestions on a clean way to achieve this, Iβd be happy to discuss! |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Sorry for the delay, had to do prioritize some other stuff. I changed the depth logic to always choose the deepest packge (in other words the leaf nodes of the specified package tree). If a user specifies nested package names, a warning is now emitted to prevent confusion. I believe this approach is more intuitive and aligns with user expectations. Let me know what you thinkβI'll update the documentation accordingly if you approve :) |
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.
Thank you ! It's getting kinda big to review, we might want to do the refactor moving code from test_writer to test_diadefs in a prior refactor PR to ease this one.
My only actual request changes is on the logging that should be a warning :)
Co-authored-by: Pierre Sassoulas <[email protected]>
for more information, see https://pre-commit.ci
This comment has been minimized.
This comment has been minimized.
π€ According to the primer, this change has no effect on the checked open source code. π€π This comment was generated for commit 0e629d9 |
Thanks Pierre, I`ve applied your suggestions and fixed the tests. Regarding the warning, Ruff forced me to set a stacklevel for warnings.warn(). Based on my understanding, stacklevel=2 is appropriate for libraries as it makes the warning point to the calling code rather than our implementation details. Let me know what you think on that one. I agree that the PR is getting quite large. However, since this PR moves all the filtering logic from |
Type of Changes
Description
Refactored the depth filtering logic, as discussed in #10077. Implementation should be much cleaner now :)