-
Notifications
You must be signed in to change notification settings - Fork 38.7k
[test] Remove all * imports #10366
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
[test] Remove all * imports #10366
Conversation
|
utACK 6e43829 Very good! This will make Python linting easier! |
|
I still question this goal, because I think having to (for example) manually add each script opcode as an import when you want to use one in a test is needlessly time-wasting for test writers, but for now I'd like to make the more important observation that merging this will likely cause substantive PRs to need to be rebased (punishment for actually including or updating a test!). For reference, my earlier comments on this idea: #9876 (comment) |
|
@sdaftuar Do you have any examples of substantive PRs that would need to be rebased after merging this one? |
|
This will make Python linting easier!
Even though I can understand the desire to have a single style or converge
the whole python code base to pep8, I tend to object based on the
maintenance overhead. The python syntax is already rather strict and
currently we should not make it more strict without clear reasoning. The
thread Suhas liked to, explains why wildcards could be useful to write
tests more productively and with less hassle.
Please note that we don't have a general coding guide for python code at
this point and refactoring for the sake of pep8 without previous discussion
might cause more hassle than it is worth.
So Concept NACK on this pull for now, as it would conflict with the ongoing
test_framework refactoring. More precisely, it would go in the wrong
direction, when i see `+ stop_node` in the diff, which is planned to be
made a private method of the test framework, so should not be added to the
list of imports.
…On Wed, May 10, 2017 at 5:40 PM, Suhas Daftuar ***@***.***> wrote:
I still question this goal, because I think having to (for example)
manually add each script opcode as an import when you want to use one in a
test is needlessly time-wasting for test writers, but for now I'd like to
make the more important observation that merging this will cause
substantive PRs to all need to be rebased (punishment for actually
including or updating a test!).
For reference, my earlier comments on this idea: #9876 (comment)
<#9876>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#10366 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGGmv1zMoNpRFfmh65687T0aL6yBNvJfks5r4dp7gaJpZM4NUs4F>
.
|
|
@sdaftuar I have to respectfully disagree. Adding opcodes as you use them makes perfect sense to me. It also gives you an overview of what opcodes are actually being checked, as an added bonus, just by looking at the imports and not the tests themselves (which can be a bit long-winded at times, unfortunately). I also have a hard time believing this PR would cause conflicts in a lot of test PRs, and I am fairly sure most of the test developers agree that * imports are just generally bad. @MarcoFalke It's no so much about a style but about proper development. Importing * means you lose control over what is going where, just like rampant usage of using namespace xyz in C++. In core proper it can be flat out dangerous and lead to unpredictable behavior with version upgrades, which may not necessarily be the case with functional tests, but it's still a step in the right direction. |
|
I agree it is a step in the right direction, but right now is not a good
time to do global refactors that stall progress of other pulls. I think we
should wait until less refactoring happens in the core files of the test
framework (such as https://github.com/bitcoin/bitcoin/pull/10359/files#diff-
bf6de4c07d2e9114c8f01eea45c6cab3L11) and revisit this pull after the dust
has settled.
…On Wed, May 10, 2017 at 6:20 PM, kallewoof ***@***.***> wrote:
@sdaftuar <https://github.com/sdaftuar> I have to respectfully disagree.
Adding opcodes as you use them makes perfect sense to me. It also gives you
an overview of what opcodes are actually being checked, as an added bonus,
just by looking at the imports and not the tests themselves (which can be a
bit long-winded at times, unfortunately). I also have a hard time believing
this PR would cause conflicts in a lot of test PRs, and I am fairly sure
most of the test developers agree that * imports are just generally bad.
@MarcoFalke <https://github.com/MarcoFalke> It's no so much about a style
but about proper development. Importing * means you lose control over what
is going where, just like rampant usage of using namespace xyz in C++. In
core proper it can be flat out dangerous and lead to unpredictable behavior
with version upgrades, which may not necessarily be the case with
functional tests, but it's still a step in the right direction.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#10366 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGGmvwlNzvLJbPYa-xieJMvnPjetCp2Eks5r4ePhgaJpZM4NUs4F>
.
|
|
@MarcoFalke When mentioning the linting improvements I was specifically thinking about finding unused imports (see below on why that matters), not full PEP-8 compliance :-) Explicit imports in tests make it easier to get a quick feeling for what a specific test case covers. And perhaps more importantly, by using explicit imports while at the same time removing unused imports it makes it very clear what is not covered by a specific test case (not imported ⇔ not tested). Strong concept ACK! |
|
The tests in /functional/ are not supposed to test the test framework,
but the bitcoind/qt api and internals, so test coverage can not be
inferred from which utility methods are (or are not) imported from the
test framework.
by using explicit imports while at the same time removing unused imports
As mentioned earlier, removing unused imports is a cleanup that should
happen every couple of months, not on a regular basis... Another
reason against explicit imports is that people will start opening
daily pulls to sort all of those alphabetically (see #10302)
…On Wed, May 10, 2017 at 10:36 PM, practicalswift ***@***.***> wrote:
@MarcoFalke When mentioning the linting improvements I was specifically
thinking about finding unused imports (see below on why that matters), not
full PEP-8 compliance :-)
Explicit imports in tests make it easier to get a quick feeling for what a
specific test case covers. And perhaps more importantly, by using explicit
imports while at the same time removing unused imports it makes it very
clear what is not covered by a specific test case (not imported ⇔ not
tested).
Strong concept ACK!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
|
@MarcoFalke Let's agree that sorting imports alphabetically daily is a waste of time :-) That kind of PR:s can perhaps be avoided by adding a clear policy in |
|
I think this is a good change because I also think @sdaftuar has a good point about script opcodes, and if there could be a solution for referencing opcodes that doesn't rely on |
|
@ryanofsky There is the import test_framework.script as script
[...]
p2sh_program = CScript([script.OP_TRUE])
[...]approach. A bit verbose perhaps, but better than import *. |
I don't see what would be stalled by replacing the import statements with explicit ones, aside from the cases of new imports. I'm perfectly content waiting on #10359 and other PR's that are considered high priority though, but I am also fairly certain @jnewbery (author of #10359) is all for this PR being merged, considering he tried the same thing in #9876. |
|
Needs rebase :-) |
6e43829 to
edcd452
Compare
|
Rebased! |
e98d380 to
5452c50
Compare
5452c50 to
55ac976
Compare
0b80c1c to
306b4be
Compare
|
Concept ACK, needs rebase EDIT: Although I think it's fine to have small exceptions like for the example of the opcodes (these examples can be separated to their own files). |
|
@jtimon That might make sense, yeah. (As for rebasing, I will hold off on that until I know we are ready to move forward with this.) |
|
Closing this, this seems to be somewhat controversial, and that's not desirable for something that makes changes all over the test framework and causes lots of necessary rebases of other commits. |
Another take at #9876 (I didn't realize it existed, but it's closed and I really do think we should get rid of
import *s if possible!).Main difference that I can see: each commit corresponds to one file.
I attempted to pull imported imports out as much as possible, e.g. instead of importing
Decimalfromutil.py, it is now imported directly fromdecimal. I may have missed some of these.Options, please advice:
__all__) -- personally I don't think this approach is ideal, as it breeds bad behavior from example (import *is considered bad behavior, even if__all__makes it more controllable) -- or in favor of reopening Remove wildcard imports from qa #9876.p2p-*,mempool_*, ...".p2p-*,mempool_*, ...)