Skip to content

Improve code readability of json.tool #75154

Closed

Description

@dhimmel
mannequin
BPO 30971
Nosy @rhettinger, @bitdancer, @berkerpeksag, @dhimmel
PRs
  • bpo-30971: Improve code readability of json.tool #2720
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2017-07-21.19:51:14.409>
    created_at = <Date 2017-07-19.19:52:56.723>
    labels = ['3.7', 'type-feature', 'library']
    title = 'Improve code readability of json.tool'
    updated_at = <Date 2017-07-21.19:51:14.406>
    user = 'https://github.com/dhimmel'

    bugs.python.org fields:

    activity = <Date 2017-07-21.19:51:14.406>
    actor = 'rhettinger'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-07-21.19:51:14.409>
    closer = 'rhettinger'
    components = ['Library (Lib)']
    creation = <Date 2017-07-19.19:52:56.723>
    creator = 'dhimmel'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 30971
    keywords = []
    message_count = 4.0
    messages = ['298686', '298691', '298692', '298820']
    nosy_count = 4.0
    nosy_names = ['rhettinger', 'r.david.murray', 'berker.peksag', 'dhimmel']
    pr_nums = ['2720']
    priority = 'normal'
    resolution = 'rejected'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue30971'
    versions = ['Python 3.7']

    Activity

    1. dhimmel commented on Jul 19, 2017

      dhimmelmannequin
      MannequinAuthor

      In #2720, I propose code changes to the json.tool command line utility. These changes are entirely non-functional and instead focus on improving code readability, style, brevity, extensibility, and maintainability.

      These changes mainly came up during the implementation of two enhancements of json.tool:

      + #345 to add indentation / whitespace options (bpo-29636).

      + #201 to display non-ascii characters (bpo-27413).

      These issues and pull requests are currently awaiting further consensus around their design and desirability. Therefore, I wanted to separate the non-functional code improvements from these PRs into a distinct PR.

      This has the benefit of allowing the future enhancement PRs to focus solely on adding features rather than the readability changes.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      on Jul 19, 2017
    3. bitdancer commented on Jul 19, 2017

      @bitdancer
      Member

      However, our general policy is that we don't make such changes unless we are also touching the code for other reasons. So I think using this PR as a base for your feature PRs, and then committing everything together if they are accepted, would be the way to go. I don't know if it would work to actually use it as a base for the other PRs in github, or if it would work better to just make it the initial commit in a commit series. The github workflow is too new for us to have definite answers to such questions :)

    4. berkerpeksag commented on Jul 19, 2017

      @berkerpeksag
      Member

      I don't think most of the changes improve readability of json.tool. Everyone has their own preferences and it's usually not enough to justify code churn.

      Also, we don't need to add comments when the code itself is pretty descriptive:

          # Output JSON
          with options.outfile as outfile:
              json.dump(obj, outfile, sort_keys=options.sort_keys, indent=4)
              outfile.write('\n')

      IMO, the only acceptable change is the correct use of 'default' parameter for 'infile' and 'outfile'.

    5. rhettinger commented on Jul 21, 2017

      @rhettinger
      Contributor

      I concur with the other commenters and am marking this as closed.

      Thank you for the effort to contribute. May I suggest working on one the many open bug reports.

    6. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.7 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions