Skip to content

Type inference regression with sort and cmp_to_key #9372

Description

@JukkaL

This code fragment started generating errors after 0.780 release:

fromfunctoolsimportcmp_to_keyx= [(1, '')]
deff(): passreveal_type(cmp_to_key)
x.sort(key=cmp_to_key(lambdax, y: f())) # Cannot infer type argument 1 of "cmp_to_key"

It might be related to python/typeshed#4192.

This happens only about 3 times in a big Dropbox internal codebase, and this is infrequent enough that I don't consider it release-blocking. I'm marking it as high-priority since this is a regression.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions