kallewoof
commented at 1:35 am on May 9, 2017:
member
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 Decimal from util.py, it is now imported directly from decimal. I may have missed some of these.
Options, please advice:
Discard this PR as redundant in favor of outcome in discussion in #9876 (__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 #9876.
Split into multiple PR’s to spread impact out over time, e.g. “p2p-*, mempool_*, …”.
Take as is or squashed in some fashion (p2p-*, mempool_*, …)
fanquake added the label
Tests
on May 9, 2017
practicalswift
commented at 8:13 am on May 9, 2017:
contributor
utACK6e43829
Very good! This will make Python linting easier!
sdaftuar
commented at 3:40 pm on May 10, 2017:
member
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)
practicalswift
commented at 3:58 pm on May 10, 2017:
contributor
@sdaftuar Do you have any examples of substantive PRs that would need to be rebased after merging this one?
MarcoFalke
commented at 4:14 pm on May 10, 2017:
member
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.
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!).
kallewoof
commented at 4:20 pm on May 10, 2017:
member
@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.
MarcoFalke
commented at 4:26 pm on May 10, 2017:
member
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.
@sdaftuarhttps://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.
@MarcoFalkehttps://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.
practicalswift
commented at 8:36 pm on May 10, 2017:
contributor
@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!
MarcoFalke
commented at 8:53 pm on May 10, 2017:
member
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)
@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.
practicalswift
commented at 8:59 pm on May 10, 2017:
contributor
@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 developer-notes.md.
ryanofsky
commented at 11:17 pm on May 10, 2017:
member
I think this is a good change because import * can make unfamiliar python code really hard to read (you have no idea where identifiers are coming from).
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 import * before making this change, that would also make this PR smaller and a little easier to review. Maybe the solution could be defining an Op class and replacing OP_RETURN with Op.RETURN, etc. Or just accepting strings like "OP_RETURN".
kallewoof
commented at 1:20 am on May 11, 2017:
member
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.
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.
practicalswift
commented at 12:40 pm on July 17, 2017:
contributor
MarcoFalke added the label
Brainstorming
on Jul 18, 2017
MarcoFalke added this to the milestone Future
on Jul 18, 2017
jtimon
commented at 8:57 am on September 23, 2017:
contributor
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).
kallewoof
commented at 5:50 am on September 25, 2017:
member
@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.)
laanwj
commented at 6:53 pm on March 7, 2018:
member
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.
laanwj closed this
on Mar 7, 2018
MarcoFalke removed this from the milestone Future
on Aug 12, 2018
This is a metadata mirror of the GitHub repository
bitcoin/bitcoin.
This site is not affiliated with GitHub.
Content is generated from a GitHub metadata backup.
generated: 2024-11-17 15:12 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me