Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,14 @@
magic trailing commas and intentional multiline formatting (#4865)
- Fix `fix_fmt_skip_in_one_liners` crashing on `with` statements (#4853)
- Fix `fix_fmt_skip_in_one_liners` crashing on annotated parameters (#4854)
- Fix new lines being added after imports with `# fmt: skip` on them (#4894)

### Packaging

<!-- Changes to how Black is packaged, such as dependency requirements -->

- Releases now include arm64 Windows binaries and wheels (#4814)

### Integrations

<!-- For example, Docker, GitHub Actions, pre-commit, editors -->

- Add `output-file` input to GitHub Action `psf/black` to write formatter output to a
file for artifact capture and log cleanliness (#4824)

Expand Down
1 change: 1 addition & 0 deletions src/black/lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,7 @@ def _maybe_empty_lines(self, current_line: Line) -> tuple[int, int]:
and self.previous_line.depth == 0
and current_line.depth == 0
and not current_line.is_import
and not current_line.is_fmt_pass_converted(first_leaf_matches=is_import)
and Preview.always_one_newline_after_import in self.mode
):
return 1, 0
Expand Down
21 changes: 21 additions & 0 deletions tests/data/cases/preview_fmtpass_imports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# flags: --preview

# Regression test for https://github.com/psf/black/issues/3438

import ast
import collections # fmt: skip
import dataclasses
# fmt: off
import os
# fmt: on
import pathlib

import re # fmt: skip
import secrets

# fmt: off
import sys
# fmt: on

import tempfile
import zoneinfo