Skip to content

HTTPSConnection.__init__(port=) incorrectly annotated as str | None for 3.12 #11057

Description

@allisonkarlitskaya

This was introduced in #10392.

As far as I can tell by reading the code, it's only ever valid to give an integer or None. This matches the (correct) typeshed annotations for HTTPConnection and versions before Python 3.12. The problem seems to be specific to HTTPSConnection and Python 3.12.

Activity

  1. sobolevn commented on Nov 22, 2023

    @sobolevn
    Member

    Hm, indeed it looks like int for port is correct. Please, send a PR :)

    port: int
    sock: socket | Any # can be `None` if `.connect()` was not called
    def __init__(
    self,
    host: str,
    port: int | None = None,

    Implementation: https://github.com/python/cpython/blob/bfc6d91c784c428c6f5c706a316cdce9140c4753/Lib/http/client.py#L920

  2. allisonkarlitskaya commented on Nov 22, 2023

    @allisonkarlitskaya
    ContributorAuthor

    Please, send a PR :)

    tada: #11058

  3. added a commit that references this issue on Nov 22, 2023
    d607cc9
  4. added a commit that references this issue on Nov 22, 2023
    53d5ee5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions