Skip to content

Black formatting leaves an extra line at the end of the file #1877

Description

@Tinche

Environment data

  • VS Code version: 1.23.1
  • Extension version (available under the Extensions sidebar): 2018.5.0
  • OS and version: macOs High Sierra
  • Python version (& distribution if applicable, e.g. Anaconda): CPython 3.6.5
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): venv
  • Relevant/affected Python packages and their versions: black-18.6b1

Actual behavior

Formatting using black leaves two empty lines at the end of the file, if the file has more than 1 empty line already.

Expected behavior

Formatting should leave just one line, and this is what happens when I run black manually from the terminal.

Steps to reproduce:

  1. Open Python file
  2. Insert 10 empty lines at the end
  3. Activate "Format document" with black set as the formatter

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

##########Linting Output - flake8##########
20,1,W,W391:blank line at end of file

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

Activity

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

    area-editor-*User-facing catch-allarea-formattingbugIssue identified by VS Code Team member as probable bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions