-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
pyreverse: Add show-stdlib option #8190
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
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #8190 +/- ##
=======================================
Coverage 95.71% 95.71%
=======================================
Files 175 175
Lines 18451 18455 +4
=======================================
+ Hits 17660 17665 +5
+ Misses 791 790 -1
|
Pierre-Sassoulas
left a comment
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.
Looks pretty nice !
This comment has been minimized.
This comment has been minimized.
|
Thank you for the PR! I will do a complete review later, but already a quick remark: |
I missed |
That is the cleanest approach in my opinion. |
DudeNr33
left a comment
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.
The logic looks fine to me. π
Aside from the logic to determine which modules belong to the stdlib only some tests are missing.
You can either add a functional test (i.e. a Python module and the resulting class diagram) in tests/pyreverse/functional/class_diagrams with a suitable rcfile (example), or add a plain unittest.
For the latter you can take a look at test_inspector.test_concat_interfaces for an example how you can extract a astroid node from a code sample in a unit test.
1b41dd2 to
8171a34
Compare
|
Submitted pylint-dev/astroid#2015. If that gets merged, we can replace Also added a couple tests. I went with a plain unit test because I thought it would be easier to confirm the behavior change between the options being set or not. Maybe there's an better way to implement them, not sure. |
This comment has been minimized.
This comment has been minimized.
DudeNr33
left a comment
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 putting in the effort in astroid and adding tests.
This made me realize we should flip the default value to preserve the existing behavior as default.
doc/whatsnew/fragments/8181.feature
Outdated
| @@ -0,0 +1,5 @@ | |||
| Add new option (``--show-stdlib``, ``-L``) to pyreverse. | |||
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.
| Add new option (``--show-stdlib``, ``-L``) to pyreverse. | |
| Add new option (``--show-stdlib``, ``-L``) to ``pyreverse``. |
Just a nitpick and I know that the existing release notes are also not consistent with this, but the majority of the docs put pylint/pyreverse in backticks.
Pierre-Sassoulas
left a comment
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.
We're in the alpha stage of 3.0 now, we could merge :)
3.0 will use Astroid >=2.15, right? So I can update this PR to use is_stdlib_module() instead of is_standard_module(). |
|
Definitely, I did not think of this but it would break main if you don't π (You can merge upstream/main, the test will start to fail) |
6e657b3 to
deb150e
Compare
|
Rebased to main, fixed quotes in whatnew fragment, updated to use |
This comment has been minimized.
This comment has been minimized.
Pierre-Sassoulas
left a comment
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.
LGTM, but I'll let @DudeNr33 merge.
DudeNr33
left a comment
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.
Only one remark regarding the category of the news fragment now that we decided to change the default behavior, and then we are good to go!
| @@ -0,0 +1,5 @@ | |||
| Add new option (``--show-stdlib``, ``-L``) to ``pyreverse``. | |||
| This is similar to the behavior of ``--show-builtin`` in that standard library | |||
| modules are now not included by default, and this option will include them. | |||
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.
I think we should probably put this under "breaking changes" (i. e. rename the file to 8181.breaking), as it is a change in the default behavior.
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.
Updated
deb150e to
16c2852
Compare
DudeNr33
left a comment
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 this addition and the patience waiting for 3.0!
This can really help to make diagrams more readable. π
|
π€ According to the primer, this change has no effect on the checked open source code. π€π This comment was generated for commit 16c2852 |
Type of Changes
Description
Adds an option (
--show-stdlib,-L) to pyreverse. This is similar to the behavior of--show-builtinin that if this option is not included, standard library modules are not included by default.To determine if a module is part of the standard library, sys.stdlib_module_names was used. Since this is only available in 3.10 and above, the generating code was backported to 3.7, 3.8, and 3.9. Then a list was generated. These were condensed for commonality to reduce code and create a shim.
Closes #8181