Skip to content

Descriptors that have different behavior on instance and class don't work with no-strict-optional #17289

@koogoro

Description

@koogoro

Bug Report

Descriptors that detect whether the property is being invoked on an instance or the class itself don't work correctly with no-strict-optional, and instead act like they are being invoked on a union of an instance and the class itself.

To Reproduce
https://gist.github.com/mypy-play/20278be77b4ecaca10c4e180752808c4

Bug appears on 1.10.0 but not on 1.9.0.

Expected Behavior

No errors.

Actual Behavior

main.py:21: error: Incompatible types in assignment (expression has type "str | int", variable has type "str") [assignment]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions