Page MenuHomePhabricator

[electrum] typehints and minor cleanup in interface.py
ClosedPublic

Authored by PiRK on Dec 7 2023, 21:00.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC40e6b84392b8: [electrum] typehints and minor cleanup in interface.py
Summary

This is a code cleanup to help me better understand the network.py code.

Add typehints where the IDE cannot guees the type.
Use an Enum for interface modes for better type-safety and more helpful IDE assistance.
Remove an unused TCPConnection.protocol attribute.
Use the more modern NamedTuple class definition.

Test Plan
python test_runner.py
python -m electrumabc.interface
pytest electrumabc/tests/regtest

Run the application, check the network dialog, change the server.

Diff Detail

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

Event Timeline

PiRK requested review of this revision.Dec 7 2023, 21:00

remove comment that is made useless by using explicit args

electrum/electrumabc/interface.py
381 ↗(On Diff #43496)

And here I tried Interface.Mode or self.Mode for consistency with the above style, but neither one worked. Mode is in scope and works, though.

389 ↗(On Diff #43496)

And here I tried Interface.Mode or self.Mode for consistency with the above style, but neither one worked. Mode is in scope and works, though.

electrum/electrumabc/interface.py
381 ↗(On Diff #43496)

Here Mode is not in scope, so <classname>.Mode must be used

This revision is now accepted and ready to land.Dec 7 2023, 22:08