Skip to content

Re-enable boundness analysis for implicit instance attributes #2117

@sharkdp

Description

@sharkdp

In astral-sh/ruff#20128, we disabled boundness analysis for implicit instance attributes:

class C:
    def __init__(self):
        if False:   
            self.x = 1

C().x  # would previously show an error, with this PR we pretend the attribute exists

It is possible that we can simply re-enable this now that we have a better strategy for dealing with these cyclic type inference problems.

We probably don't want a full-blown revert of that PR. I like TypeQualifiers::IMPLICIT_INSTANCE_ATTRIBUTE much better than TypeQualifiers::POSSIBLY_UNBOUND_IMPLICIT_ATTRIBUTE, so maybe we can prevent bringing the latter back.

For some reason, I don't see any regression tests for #758 in that PR, so we should probably add them when we resolve this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions