test: moved from percent format to proper format for consistency #19586

pull sanjaykdragon wants to merge 1 commits into bitcoin:master from sanjaykdragon:master changing 2 files +16 −16
  1. sanjaykdragon commented at 9:21 PM on July 24, 2020: contributor

    Simple changes some of the python test related files. I converted from the old % format, ex: "test %s" % "hello" to the new str.format: "test {}".format("hello")

    This is more modern, as well as more consistent with the rest of the codebase (I have looked around and seen str.format used)

  2. REFACTOR: moved from percent format to proper format for consistency 95ea738e8c
  3. MarcoFalke renamed this:
    REFACTOR: moved from percent format to proper format for consistency
    test: moved from percent format to proper format for consistency
    on Jul 25, 2020
  4. MarcoFalke added the label Refactoring on Jul 25, 2020
  5. MarcoFalke added the label Tests on Jul 25, 2020
  6. practicalswift commented at 4:54 PM on July 25, 2020: contributor

    @sanjaykdragon How were these 15 instances chosen? :) AFAICT we have 247 instances of the old printf-style string formatting in our codebase:

    $ git grep "['\"] % " -- "*.py" | wc -l
    247
    

    If we are to do something like this I suggest looking at pyupgrade which can perform automatic conversion from the old printf-style string formatting to .format(…) :)

    pyupgrade is a tool (and pre-commit hook) to automatically upgrade syntax for newer versions of the language. Try pip3 install pyupgrade && pyupgrade $(git ls-files -- "*.py") && git diff to see the suggested changes.

    (Personally I don't have any strong opinion about this: just suggesting the proper tooling.)

  7. jonatack commented at 6:44 PM on July 25, 2020: member

    Welcome @sanjaykdragon and thank you for your contribution.

    For more information about stylistic cleanup, see:

    "Pull requests that refactor the code should not be made by new contributors. It requires a certain level of experience to know where the code belongs to and to understand the full ramification (including rebase effort of open pull requests)."

    If you're looking for ways to start contributing to the project, here is a great place to begin:

  8. promag commented at 10:52 AM on July 26, 2020: member

    +1 what @practicalswift said, as long as this doesn't conflict with other changes.

  9. jonatack commented at 11:03 AM on July 26, 2020: member

    TBH, that contributing guide statement to not submit refactoring PRs stopped me from doing so for the first full year, and meanwhile I've seen a number of new contributors begin with refactoring critical code and seen it both appreciated and merged. So I'm not sure if that statement is valid and should be in the guide.

    Here though, it's a pure style change. Once again maybe wrongly, I thought that they weren't accepted from new people. Maybe I should not have read the docs as much :smile:

  10. promag commented at 11:06 AM on July 26, 2020: member

    @jonatack I welcome style changes if then are in separate commit and simplify the PR while avoiding unnecessary style comments.

  11. sanjaykdragon commented at 3:01 PM on July 26, 2020: contributor

    @sanjaykdragon How were these 15 instances chosen? :) AFAICT we have 247 instances of the old printf-style string formatting in our codebase:

    $ git grep "['\"] % " -- "*.py" | wc -l
    247
    

    If we are to do something like this I suggest looking at pyupgrade which can perform automatic conversion from the old printf-style string formatting to .format(…) :)

    pyupgrade is a tool (and pre-commit hook) to automatically upgrade syntax for newer versions of the language. Try pip3 install pyupgrade && pyupgrade $(git ls-files -- "*.py") && git diff to see the suggested changes.

    (Personally I don't have any strong opinion about this: just suggesting the proper tooling.)

    I lowkey fear using automated tools on a big repo. I changed the files manually, although I probably should have automated it. pyugprade looks pretty interesting though

  12. sanjaykdragon commented at 3:01 PM on July 26, 2020: contributor

    TBH, that contributing guide statement to not submit refactoring PRs stopped me from doing so for the first full year, and meanwhile I've seen a number of new contributors begin with refactoring critical code and seen it both appreciated and merged. So I'm not sure if that statement is valid and should be in the guide.

    Here though, it's a pure style change. Once again maybe wrongly, I thought that they weren't accepted from new people. Maybe I should not have read the docs as much 😄

    I have seen a pretty mixed bag on this, and I don't know if i would consider this file critical code. I expect refactoring the consensus area would be more scrutinized

  13. DrahtBot commented at 6:33 PM on July 26, 2020: member

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #16365 (Log RPC parameters (arguments) if -debug=rpcparams by LarryRuane)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  14. fanquake commented at 6:43 AM on July 28, 2020: member

    ~0. This is what is stated in the style guidelines for the functional tests, but there's a chance these will all be changed again, to f"something {arg}" once we move to supporting 3.6+ (#13718), so I don't think theres' any rush to go through and chance all these now.

  15. sanjaykdragon closed this on Aug 8, 2020

  16. DrahtBot locked this on Feb 15, 2022

github-metadata-mirror

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: 2026-04-22 06:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me