Skip to content

too many cycle iterations in cyclic dependent attributes #692

@Glyphack

Description

@Glyphack

Summary

This was found by mypy primer. The original code is in this file:
https://github.com/caronc/apprise/blob/ce90151051f630803cba755fc9f06e16f7d8590b/apprise/plugins/email/base.py#L244

I think this is a minimal reproduction. Although the secure attribute is defined in parent class in the original code but while playing this code fails(with defined it fails as well I just don't know why):

from typing import Self

class A:
    def __init__(self: Self, secure_mode=None):
        if secure_mode:
            self.secure_mode = secure_mode.lower()
        else:
            self.secure_mode = "insecure" \
                if not self.secure else "ssl"

        if self.secure_mode not in ["secure"]:
            raise TypeError("invalid")

        # Next line is when the member lookup happens and the cycle starts
        if not self.secure and self.secure_mode != "insecure":
            self.secure = True

The cycle happens in member lookup with policy on self.secure The fixed point iteration does not converge. These are the two values that are returned from member_lookup_with_policy:

member_lookup_with_policy: PlaceAndQualifiers {
    place: Unbound,
    qualifiers: TypeQualifiers(
        0x0,
    ),
}

member_lookup_with_policy: PlaceAndQualifiers {
    place: Type(
        Union(
            UnionType {
                elements: [
                    Dynamic(
                        Unknown,
                    ),
                    BooleanLiteral(
                        true,
                    ),
                ],
            },
        ),
        PossiblyUnbound,
    ),
    qualifiers: TypeQualifiers(
        0x0,
    ),
}

Version

9570d39 2025-06-23

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfatala fatal error (panic or crash)

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions