Page MenuHomePhabricator

[lint] switch from Black to Ruff for python code formatting
ClosedPublic

Authored by PiRK on Fri, Nov 7, 14:55.

Details

Summary

Ruff yields the same result as Black for 99+% of formatted lines, and it can do both formatting and checking, so this opens the way to replace both Black, flake8 (and all its plugins), isort, flynt... by a single dependency with more capabilites (such as preventing the class of errors fixed in D18896)

The python changes are mostly automated formatting done by the new linter, except for:

  • same line comments move to previous line
  • accidental trailing , removed, to avoid pointless reformatting. These had no effect, turning the result of the line into a tuple then immediately dismissing it

Depends on D18912

Test Plan
arc liberate
arc lint --everything

ninja all check-all

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

PiRK requested review of this revision.Fri, Nov 7, 14:55
PiRK planned changes to this revision.Fri, Nov 7, 15:00

i should be able to split this more, some changes are probably compatible with black (blank lines, bare tuples...)

test/functional/test_framework/test_framework.py
546 ↗(On Diff #56516)

this is the only change i don't really like

PiRK edited the summary of this revision. (Show Details)

split most newline changes into its own diff

PiRK added inline comments.
electrum/electrumabc_gui/qt/external_plugins_window.py
413 ↗(On Diff #56535)

manual edit (pointless accidental tuple)

electrum/electrumabc_gui/qt/main_window.py
155 ↗(On Diff #56535)

manual edit: comment to previous line

rebase for minor change in Contributing.md

Tail of the build log:

Build 'Bitcoin ABC Diffs / Diff Testing' #103228, branch 'refs/tags/phabricator/diff/56535'
Triggered 2025-11-10 07:59:08 by 'Phabricator Staging (phabricator-staging)'
Started 2025-11-10 08:19:41 on agent 'buildagent2'
Finished 2025-11-10 08:19:41 with status FAILURE 'Unable to collect changes'
VCS revisions: 'BitcoinABC_BitcoinAbcStaging' (Git, instance id 22): 'N/A' (checkout rules: '+:. => ./bitcoin-abc')
TeamCity URL https://build.bitcoinabc.org/buildConfiguration/BitcoinABC_BitcoinAbcStaging/1011506 
TeamCity server version is 2025.03.1 (build 186125), server timezone: GMT (UTC)

[07:59:08]E: bt15 (20m:33s)
[07:59:08]i: TeamCity server version is 2025.03.1 (build 186125)
[07:59:08] : Finalize build settings
[07:59:08] : Collecting changes in 2 VCS roots
[07:59:08] :	 [Collecting changes in 2 VCS roots] VCS Root details
[07:59:08] :		 [VCS Root details] "Bitcoin ABC Staging" {instance id=22, parent internal id=3, parent id=BitcoinABC_BitcoinAbcStaging, description: "ssh://vcs@reviews.bitcoinabc.org:2221/source/bitcoin-abc-staging.git#refs/heads/master"}
[07:59:08] :		 [VCS Root details] "abc-infrastructure" {instance id=24, parent internal id=7, parent id=AutomatedDeployments_BitcoinAbcDeveloperTools_AbcInfrastructure, description: "ssh://vcs@reviews.bitcoinabc.org:2221/source/infrastructure.git#refs/heads/master"}
[07:59:08]i: Loading current repository state for VCS root 'Bitcoin ABC Staging' (running for 20m:33s)
[07:59:08]i:	 [Loading current repository state for VCS root 'Bitcoin ABC Staging'] VCS root 'Bitcoin ABC Staging': git -c credential.helper= -c credential.helper=/opt/teamcity/temp/credHelper5094448836704981854.sh ls-remote origin
[07:59:08]i:	 [Loading current repository state for VCS root 'Bitcoin ABC Staging'] Loading current repository state for VCS root 'abc-infrastructure' (running for 20m:33s)
[07:59:08]i:		 [Loading current repository state for VCS root 'abc-infrastructure'] VCS root 'abc-infrastructure': git -c credential.helper= -c credential.helper=/opt/teamcity/temp/credHelper11627887992003917676.sh ls-remote origin
[07:59:08]i:		 [Loading current repository state for VCS root 'abc-infrastructure'] VCS root 'Bitcoin ABC Staging': Warning: Permanently added '[reviews.bitcoinabc.org]:2221' (ED25519) to the list of known hosts.
[07:59:08]i:		 [Loading current repository state for VCS root 'abc-infrastructure'] VCS root 'abc-infrastructure': Warning: Permanently added '[reviews.bitcoinabc.org]:2221' (ED25519) to the list of known hosts.
[07:59:08]i:		 [Loading current repository state for VCS root 'abc-infrastructure'] VCS root 'Bitcoin ABC Staging': phabricator-ssh-exec: Unable to establish a connection to any database host (while trying "reviews_bitcoinabc_repository"). All masters and replicas are completely unreachable.
[07:59:08]i:		 [Loading current repository state for VCS root 'abc-infrastructure'] VCS root 'Bitcoin ABC Staging': 
[07:59:08]i:		 [Loading current repository state for VCS root 'abc-infrastructure'] VCS root 'Bitcoin ABC Staging': AphrontConnectionQueryException: Attempt to connect to phabricator@127.0.0.1 failed with error #1040: Too many connections.
[07:59:08]i:		 [Loading current repository state for VCS root 'abc-infrastructure'] VCS root 'Bitcoin ABC Staging': fatal: Could not read from remote repository.
[07:59:08]i:		 [Loading current repository state for VCS root 'abc-infrastructure'] VCS root 'Bitcoin ABC Staging': 
[07:59:08]i:		 [Loading current repository state for VCS root 'abc-infrastructure'] VCS root 'Bitcoin ABC Staging': Please make sure you have the correct access rights
[07:59:08]i:		 [Loading current repository state for VCS root 'abc-infrastructure'] VCS root 'Bitcoin ABC Staging': and the repository exists.
[07:59:09]i:		 [Loading current repository state for VCS root 'abc-infrastructure'] Detecting changes in VCS root 'abc-infrastructure' (used in 'Bitcoin-ABC Infra Checkout', 'Extract Electrum ABC from ABC' and 5 other configurations)
[07:59:09]i:		 [Loading current repository state for VCS root 'abc-infrastructure'] Will collect changes for 'abc-infrastructure' starting from revision 602c7e2af027bb16cc6a4fc5a25601e8c853be5e
[07:59:09] : Compute revision for 'abc-infrastructure' in Automated Deployments / Bitcoin ABC Infra / Bitcoin-ABC Infra Checkout
[07:59:09] :	 [Compute revision for 'abc-infrastructure' in Automated Deployments / Bitcoin ABC Infra / Bitcoin-ABC Infra Checkout] Upper limit revision: 602c7e2af027bb16cc6a4fc5a25601e8c853be5e
[07:59:09]i:	 [Compute revision for 'abc-infrastructure' in Automated Deployments / Bitcoin ABC Infra / Bitcoin-ABC Infra Checkout] MaxModId = 83296
[07:59:09] :	 [Compute revision for 'abc-infrastructure' in Automated Deployments / Bitcoin ABC Infra / Bitcoin-ABC Infra Checkout] Computed revision: 602c7e2af027bb16cc6a4fc5a25601e8c853be5e
[08:19:41] : The build is removed from the queue to be prepared for the start
[08:19:41]E: Failed to collect changes, error: git -c credential.helper= -c credential.helper=/opt/teamcity/temp/credHelper5094448836704981854.sh ls-remote origin command failed.
exit code: 128
stderr: Warning: Permanently added '[reviews.bitcoinabc.org]:2221' (ED25519) to the list of known hosts.
phabricator-ssh-exec: Unable to establish a connection to any database host (while trying "reviews_bitcoinabc_repository"). All masters and replicas are completely unreachable.

AphrontConnectionQueryException: Attempt to connect to phabricator@127.0.0.1 failed with error #1040: Too many connections.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists., VCS root: "Bitcoin ABC Staging" {instance id=22, parent internal id=3, parent id=BitcoinABC_BitcoinAbcStaging, description: "ssh://vcs@reviews.bitcoinabc.org:2221/source/bitcoin-abc-staging.git#refs/heads/master"}
[08:19:41]E: Failed to collect changes, error: git -c credential.helper= -c credential.helper=/opt/teamcity/temp/credHelper5094448836704981854.sh ls-remote origin command failed.
exit code: 128
stderr: Warning: Permanently added '[reviews.bitcoinabc.org]:2221' (ED25519) to the list of known hosts.
phabricator-ssh-exec: Unable to establish a connection to any database host (while trying "reviews_bitcoinabc_repository"). All masters and replicas are completely unreachable.

AphrontConnectionQueryException: Attempt to connect to phabricator@127.0.0.1 failed with error #1040: Too many connections.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists., VCS root: "Bitcoin ABC Staging" {instance id=22, parent internal id=3, parent id=BitcoinABC_BitcoinAbcStaging, description: "ssh://vcs@reviews.bitcoinabc.org:2221/source/bitcoin-abc-staging.git#refs/heads/master"}
[08:19:41] : Build finished
Fabien added a subscriber: Fabien.
Fabien added inline comments.
test/functional/chronik_block_header.py
83 ↗(On Diff #56537)

That seems superfluous ?

test/functional/chronik_blocks.py
33 ↗(On Diff #56537)

dito

This revision is now accepted and ready to land.Mon, Nov 10, 09:23
test/functional/chronik_block_header.py
83 ↗(On Diff #56537)

It seems intentional https://github.com/psf/black/pull/909

Black missed it because it is inside a f-string