test: return typed P2PInterface from add_p2p_connection helpers #36547

pull ViniciusCestarii wants to merge 1 commits into bitcoin:master from ViniciusCestarii:typed-p2p-connection changing 1 files +28 −3
  1. ViniciusCestarii commented at 10:41 PM on October 15, 2026: contributor

    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.

  2. DrahtBot added the label Tests on Oct 15, 2026
  3. DrahtBot commented at 10:41 PM on October 15, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    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 <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. fanquake commented at 4:33 AM on October 16, 2026: member

    Concept ACK

  5. in test/functional/test_framework/test_node.py:768 in e25a0927cd
     764 | @@ -761,7 +765,7 @@ def assert_start_raises_init_error(self, extra_args=None, expected_msg=None, mat
     765 |              if assert_msg:
     766 |                  self._raise_assertion_error(assert_msg)
     767 |  
     768 | -    def add_p2p_connection(self, p2p_conn, *, wait_for_verack=True, send_version=True, supports_v2_p2p=None, wait_for_v2_handshake=True, expect_success=True, **kwargs):
     769 | +    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:
    


    maflcko commented at 8:04 AM on October 16, 2026:
        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 commented at 10:07 AM on October 20, 2026:

    I agree. Done on b08c7da4d19cf259f86a7b91a473fb6014f19eb0

  6. maflcko approved
  7. maflcko commented at 8:05 AM on October 16, 2026: member

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

  8. test: return typed P2PInterface from add_p2p_connection helpers b08c7da4d1
  9. ViniciusCestarii force-pushed on Oct 20, 2026
  10. ViniciusCestarii commented at 10:08 AM on October 20, 2026: contributor

    Thanks for the review. Force-pushed b08c7da4d19cf259f86a7b91a473fb6014f19eb0 addressing #36547 (review)

  11. tumutech commented at 10:06 PM on October 20, 2026: none

    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.

  12. DrahtBot requested review from fanquake on Oct 20, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-10-21 19:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me