test: return typed P2PInterface from add_p2p_connection helpers #36547

Open
ViniciusCestarii wants to merge 1 commit from typed-p2p-connection into master AGit
ViniciusCestarii commented 2026-10-15 22:41:50 +00:00 (Migrated from github.com)

Return type of add_p2p_connection and add_outbound_p2p_connection is not explicitly typed so LSPs treats the return as Any.

Add explicit return type to improve DX.

Return type of add_p2p_connection and add_outbound_p2p_connection is not explicitly typed so LSPs treats the return as Any. Add explicit return type to improve DX.
DrahtBot commented 2026-10-15 22:41:59 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
ACK tumutech
Concept ACK fanquake

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #36990 (test: replace hard-coded RPC error codes by l0rinc)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36547 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36547.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36547#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | ACK | [tumutech](https://github.com/bitcoin/bitcoin/pull/36547#issuecomment-6302833241) | | Concept ACK | [fanquake](https://github.com/bitcoin/bitcoin/pull/36547#issuecomment-6208147624) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#36990](https://github.com/bitcoin/bitcoin/pull/36990) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36990.svg"></sub> (test: replace hard-coded RPC error codes by l0rinc) If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. <!--5faf32d7da4f0f540f40219e4f7537a3-->
First-time contributor

Base: 6799119cef7ead71e2b2fc7928a0ea58d720c708
Head: b08c7da4d19cf259f86a7b91a473fb6014f19eb0

I found no actionable issues in this static review.

Full review report

<!-- forgejo-review-bot:bitcoin/bitcoin --> Base: `6799119cef7ead71e2b2fc7928a0ea58d720c708` Head: `b08c7da4d19cf259f86a7b91a473fb6014f19eb0` I found no actionable issues in this static review. [Full review report](<https://review.fish.foo/traces/36547-b08c7da4d19cf259f86a7b91a473fb6014f19eb0-930-2.html>)
fanquake commented 2026-10-16 04:33:39 +00:00 (Migrated from github.com)

Concept ACK

Concept ACK
maflcko (Migrated from github.com) approved these changes 2026-10-16 08:05:52 +00:00
maflcko (Migrated from github.com) left a comment

I don't use type annotations in Python code, but seems fine if others want them

I don't use type annotations in Python code, but seems fine if others want them
maflcko (Migrated from github.com) commented 2026-10-16 08:04:38 +00:00
    def add_p2p_connection(self, p2p_conn: P2PInterfaceT, *, wait_for_verack=True, send_version=True, supports_v2_p2p=None, wait_for_v2_handshake=True, expect_success=True, 
    ...
    **kwargs,) -> P2PInterfaceT:

nit: at some point the lines are getting long enough to split them. Maybe now? (same below)

```suggestion def add_p2p_connection(self, p2p_conn: P2PInterfaceT, *, wait_for_verack=True, send_version=True, supports_v2_p2p=None, wait_for_v2_handshake=True, expect_success=True, ... **kwargs,) -> P2PInterfaceT: ``` nit: at some point the lines are getting long enough to split them. Maybe now? (same below)
ViniciusCestarii (Migrated from github.com) reviewed 2026-10-20 10:07:41 +00:00
ViniciusCestarii (Migrated from github.com) commented 2026-10-20 10:07:41 +00:00

I agree. Done on b08c7da4d1

I agree. Done on b08c7da4d19cf259f86a7b91a473fb6014f19eb0
ViniciusCestarii commented 2026-10-20 10:08:59 +00:00 (Migrated from github.com)
Thanks for the review. Force-pushed b08c7da4d19cf259f86a7b91a473fb6014f19eb0 addressing https://github.com/bitcoin/bitcoin/pull/36547#discussion_r4292253804
tumutech commented 2026-10-20 22:06:23 +00:00 (Migrated from github.com)

ACK b08c7da4d1

In an editor that reads python types, a dot on the value returned by add_p2p_connection or add_outbound_p2p_connection lists the methods of the class that was passed in, including those methods from P2PInterface.

ACK b08c7da4d19cf259f86a7b91a473fb6014f19eb0 In an editor that reads python types, a dot on the value returned by `add_p2p_connection` or `add_outbound_p2p_connection` lists the methods of the class that was passed in, including those methods from P2PInterface.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36547
No description provided.