psf / psf/black

Assert statement condition broken up in unfortunate way

Open
#348 8 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

F: parentheses F: symmetry T: style
Dominant language
Python
Stars
41.8k
Forks
2.9k
Avg merge
5d 6h
Merged PRs (30d)
9

Description

Operating system: Win 10 1803 x64
Python version: 3.6.5
Black version: 18.6b2
Does also happen on master: yes

Black outputs the following code in one project (https://github.com/googlei18n/fontmake/pull/444/commits/e22a624deb3429eb4882e9c31cb15e8c769fc1f9):

        assert len(ufo_order) == len(
            ot_order
        ), "{}, subsetting: amount of glyphs does not match with {}".format(
            ufo.path, otf_path
        )

The placement of the assert condition is unfortunate... Is this expected? Is there a more elegant way to write that code?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running Black on the assert example from the issue and compare the output with the original formatting. Then trace the formatter behavior responsible for splitting the assert condition and determine whether the project has tests covering this case. The issue is done only when the intended, more elegant formatting is agreed and captured by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.