Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • diffoscope diffoscope
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 132
    • Issues 132
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 2
    • Merge requests 2
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Reproducible BuildsReproducible Builds
  • diffoscopediffoscope
  • Merge requests
  • !96

Fix Black version detection

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Brent Spillner requested to merge spillner/diffoscope:black-version-detection into master Dec 08, 2021
  • Overview 2
  • Commits 4
  • Pipelines 6
  • Changes 1

Black made a significant change in the format of the --version output string between versions 21.10 ("black, version 21.10b0") and 21.11 ("black, 21.11b0 (compiled: no)"), which breaks the assumption in black_version() that the numeric version token will always be the last element of a .split() on the output string.

I changed the logic to instead report the first .split() component that begins with a decimal digit. This has been tested to work correctly for all black versions between 21.6b0, and I verified that all of the version strings available in pip (starting at 18.30) do indeed begin with a decimal digit. This branch started life as part of my work to get merge request !94 (closed) to pass the CI test pipeline; after I grasped the problem I decided to separate it out into a separate request as it's a simpler issue and has the potential to affect more users as they upgrade local toolchains.

Of note, the latest black release as of this writing (21.12b0) keeps the new --version format introduced by 21.11b0, so I assume it's not a one-off or regression. However, I do not recommend that diffoscope users switch to black 21.12b0 yet, as it has a different regression that wants to remove a newline from diffoscope/comparators/directory.py, which all other recent versions of black (including the one in the CI pipeline environment) want to re-insert.

Edited Dec 08, 2021 by Brent Spillner
Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: black-version-detection