Skip to content

Incorrect missing-attribute when valid class attribute is included in __slots__ #2444

Closed

Description

@jakevdp

Describe the Bug

Example:

class Foo:
    __slots__ = ["__name__"]

    def __init__(self):
        self.__name__ = "foo_instance"

print(Foo.__name__)

Runtime result:

$ python test.py
Foo

pyrefly check result:

$ pyrefly check test.py
ERROR Instance-only attribute `__name__` of class `Foo` is not visible on the class [missing-attribute]
 --> test.py:7:7
  |
8 | print(Foo.__name__)
  |       ^^^^^^^^^^^^
  |
 INFO 1 error

Sandbox Link

sandbox link

(Only applicable for extension issues) IDE Information

No response

Activity

  1. rchen152 commented on Feb 16, 2026

    @rchen152
    Contributor

    Thanks for the report! This looks related to #630. We currently have no, or very minimal, support for __slots__, I believe.

  2. added theissue type on Feb 16, 2026
  3. added this to the V1 Release milestone on Mar 16, 2026
  4. yangdanny97 commented on Mar 18, 2026

    @yangdanny97
    Collaborator

    #630 is closed but the bug still repros

  5. self-assigned this
    on Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions