Skip to content
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

IDLE: Include end newlines in whitespace fix. #83043

Closed
terryjreedy opened this issue Nov 20, 2019 · 6 comments
Closed

IDLE: Include end newlines in whitespace fix. #83043

terryjreedy opened this issue Nov 20, 2019 · 6 comments
Assignees
Labels
3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes topic-IDLE type-bug An unexpected behavior, bug, or error

Comments

@terryjreedy
Copy link
Member

BPO 38862
Nosy @rhettinger, @terryjreedy, @taleinat
PRs
  • bpo-38862: IDLE Strip Trailing Whitespace fixes end newlines  #17366
  • [3.8] bpo-38862: IDLE Strip Trailing Whitespace fixes end newlines (GH-17366) #17370
  • [3.7] bpo-38862: IDLE Strip Trailing Whitespace fixes end newlines (GH-17366) #17371
  • [3.7] bpo-38862: IDLE Strip Trailing Whitespace fixes end newlines (GH-17366) #17379
  • [3.8] bpo-38862: IDLE Strip Trailing Whitespace fixes end newlines (GH-17366) #17380
  • 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 = 'https://github.com/terryjreedy'
    closed_at = <Date 2019-11-27.01:13:58.033>
    created_at = <Date 2019-11-20.06:06:45.234>
    labels = ['3.8', 'expert-IDLE', 'type-bug', '3.7', '3.9']
    title = 'IDLE: Include end newlines in whitespace fix.'
    updated_at = <Date 2019-11-27.01:13:58.033>
    user = 'https://github.com/terryjreedy'

    bugs.python.org fields:

    activity = <Date 2019-11-27.01:13:58.033>
    actor = 'terry.reedy'
    assignee = 'terry.reedy'
    closed = True
    closed_date = <Date 2019-11-27.01:13:58.033>
    closer = 'terry.reedy'
    components = ['IDLE']
    creation = <Date 2019-11-20.06:06:45.234>
    creator = 'terry.reedy'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 38862
    keywords = ['patch']
    message_count = 6.0
    messages = ['357030', '357388', '357409', '357412', '357545', '357546']
    nosy_count = 3.0
    nosy_names = ['rhettinger', 'terry.reedy', 'taleinat']
    pr_nums = ['17366', '17370', '17371', '17379', '17380']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue38862'
    versions = ['Python 3.7', 'Python 3.8', 'Python 3.9']

    @terryjreedy
    Copy link
    Member Author

    Format => Strip Trailing Whitespace should strip extra newlines at the end of the file after stripping each line, and make sure that there is at least one. The latter is done when saving, and that code can be reused.

    @terryjreedy terryjreedy added 3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes labels Nov 20, 2019
    @terryjreedy terryjreedy self-assigned this Nov 20, 2019
    @terryjreedy terryjreedy added topic-IDLE type-bug An unexpected behavior, bug, or error labels Nov 20, 2019
    @terryjreedy terryjreedy changed the title IDLE: Include end whitespace in whitespace fix. IDLE: Include end newlines in whitespace fix. Nov 20, 2019
    @terryjreedy
    Copy link
    Member Author

    patchcheck.py removes even a single newline if that is all that remains after stripping each line. So the revised rule is that a file should be either empty or end with a non-whitespace followed by a newline. My intent is that a file be ready to merge to out github python/cpython repository.

    @terryjreedy
    Copy link
    Member Author

    Currently, iomenu.IOBinding.fixnewlines makes sure that when a non-empty non-Shell file is saved (and possibly run), it ends with at least 1 newline. At one time, I believe, compile needed this, and it is still good practice. (Git diffs note the absence of a final newline.)

    I originally planned to incorporate possible newline addition into do_rstrip, in anticipation of calling do_rstrip on save, but I have changed my mind, at least for the present. That code can stay where it is. If someone explicitly runs Strip Trailing Whitespace, adding a newline would sometimes be desired, but would sometimes be unexpected and possibly a nuisance. do_rstrip will ensure that non-Shell files end with at most 1 newline.

    My revised intent is that once we strip on save, saved files should be properly formatted for use or merging into a repository.

    @terryjreedy
    Copy link
    Member Author

    New changeset 6bf644e by Terry Jan Reedy in branch 'master':
    bpo-38862: IDLE Strip Trailing Whitespace fixes end newlines (GH-17366)
    6bf644e

    @terryjreedy
    Copy link
    Member Author

    New changeset 2fb9719 by Terry Jan Reedy in branch '3.7':
    [3.7] bpo-38862: IDLE Strip Trailing Whitespace fixes end newlines (GH-17366) (bpo-17379)
    2fb9719

    @terryjreedy
    Copy link
    Member Author

    New changeset a9c86f5 by Terry Jan Reedy in branch '3.8':
    [3.8] bpo-38862: IDLE Strip Trailing Whitespace fixes end newlines (GH-17366)
    a9c86f5

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes topic-IDLE type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant