Skip to content

Wrong type for ssl.Options.OP_ALL #16378

Description

@DiegoBaldassarMilleuno

The following:

from ssl import Options

reveal_type(Options.OP_NO_SSLv2)
reveal_type(Options.OP_ALL)

def f(a: Options) -> None: ...
f(Options.OP_NO_SSLv2)
f(Options.OP_ALL)

When run through mypy 2.3.1 it reports:

/tmp/ramdisk/test.py:3: note: Revealed type is "Literal[ssl.Options.OP_NO_SSLv2]?"
/tmp/ramdisk/test.py:4: note: Revealed type is "int"
/tmp/ramdisk/test.py:8: error: Argument 1 to "f" has incompatible type "int"; expected "Options"  [arg-type]
Found 1 error in 1 file (checked 1 source file)

When run through pyright 1.1.413 it reports:

/tmp/ramdisk/test.py
  /tmp/ramdisk/test.py:3:13 - information: Type of "Options.OP_NO_SSLv2" is "Literal[Options.OP_NO_SSLv2]"
  /tmp/ramdisk/test.py:4:13 - information: Type of "Options.OP_ALL" is "int"
  /tmp/ramdisk/test.py:8:3 - error: Argument of type "int" cannot be assigned to parameter "a" of type "Options" in function "f"
    "int" is not assignable to "Options" (reportArgumentType)
1 error, 0 warnings, 2 informations

I believe the error is in ssl.py in the definition of OP_ALL, where it should probably be instead:

    OP_ALL: Options

Activity

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

    help wantedAn actionable problem of low to medium complexity where a PR would be very welcomestubs: false positiveType checkers report false errors

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions