Skip to content

Conditional deduction support with comparison of sys.hexversion against integer literal #21402

@jonathandung

Description

@jonathandung

Feature

Currently, mypy statically evaluates some if branches involving only sys.version_info and sys.platform as always false based on the version and platform it is running on. I propose to have it recognize comparisons against sys.hexversion as well.

Pitch

Some specialized functions targeting bugs patched in a certain alpha, beta or release candidate or internal behavioural differences between patch versions would need this functionality. Also, it may be desirable to give alpha/beta/rc versions a grace period for certain small deprecations, only raising an error on their use in the final python release. Implementation-wise, because the exact value of hexversion can be easily retrieved, and sys.platform and sys.version_info have set precedents, I do not believe it would be unreasonably hard to implement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions