Skip to content

Feature Request: support __slots__ #630

@rchen152

Description

@rchen152

Describe the Bug

When a class defines __slots__, pyrefly shouldn't allow writing to attributes that aren't specified in __slots__. This is tested in the dataclasses_slots conformance test, which we currently fail:

# This should generate an error because "y" is not in slots.
self.y = 3 # E

Sandbox Link

https://pyrefly.org/sandbox/?code=MYGwhgzhAECCBcAoaLoH00RAewC4Q2gF5oAKAcgA9yAaASmVQBMBTAM3TQEsA7L3DKQgsQbOklSTow0QDpKxaABYATIynSRbWQE9FqlAGJoAFQAWXGBDPYAriCY9yuaACMW0MCBwB3FkyA

(Only applicable for extension issues) IDE Information

No response

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions