-
Notifications
You must be signed in to change notification settings - Fork 255
Add __slots__ validation for attribute assignments #2029
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
|
Thanks for the PR! I will take a look! |
|
|
||
| // Check current class - compute slots metadata on-demand to ensure fields are solved | ||
| let metadata = self.get_metadata_for_class(class); | ||
| let slots = self.compute_slots_metadata(class, metadata.dataclass_metadata()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we stored the slots metadata in the class, why are we computing it here as well? More generally, why is recomputing needed/can we find a way to compute this only once for each class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, I actually tried switching to use the stored metadata.slots_metadata() but it broke the tests. I believe the issue is timing: slots_metadata gets computed during class_metadata_of() which happens early in the solving process, before the __slots__ field type is fully resolved. At that point the type might still be Any or not have the literal strings extracted yet. If we want to avoid recomputation in the future, we'd probably need some kind of lazy/deferred computation pattern (compute on first access rather than during class metadata construction). Could potentially be a followup discussion?
| match &slots_ty { | ||
| Type::Tuple(Tuple::Concrete(elts)) => { | ||
| for elt in elts.iter() { | ||
| if let Type::Literal(Lit::Str(s)) = elt { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am seeing various new errors coming from mypy primer. Curious if there is any sense on whether those are legitimate?
Also, do we know that at this point, pyrefly is inferring the literal types we expect for slots?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked into these, most are false positives. The slots check was running for all attribute types including properties/descriptors, but Python's __slots__ only restricts instance attributes. For example, dulwich's Blob.data and many discord.py attributes are properties, not instance slots.
Fixed by only checking slots for ReadWrite/ReadOnly class attributes, skipping Property and Descriptor variants.
For the literal type inference, the code extracts literal strings from the tuple (the Type::Tuple(Tuple::Concrete(elts)) match).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Are the current mypy primer results meant to be the latest results? I am still seeing a lot of false positives.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, those are the latest results. I'm not completely sure myself which ones are still false positives (after adding the descriptor/property fix), but I believe they appear because slots checking didn't exist before this PR, so they're "new" in the sense that we're now checking something we weren't before.
Open to more feedback for the primer results.
| self.x = 1 # OK | ||
| self.z = 3 # OK - child has implicit __dict__ | ||
| "#, | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add a testcase invoking the init method?
class Base:
__slots__ = ("x",)
def __init__(self, x: int, flag: bool = False):
self.x = x
class Child(Base):
__slots__ = ("y",)
def __init__(self, x: int, y: int):
super().__init__(x)
self.y = y
which should succeed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, added this test case, thanks
…slots inheritance test case
|
Diff from mypy_primer, showing the effect of this PR on open source code: antidote (https://github.com/Finistere/antidote)
+ ERROR tests/core/test_thread_safety.py:123:19-34: Default `object` is not assignable to parameter `v1` with type `tuple[int, float]` [bad-function-definition]
+ ERROR tests/core/test_thread_safety.py:123:73-88: Default `object` is not assignable to parameter `v2` with type `tuple[int, float]` [bad-function-definition]
+ ERROR tests/lib/lazy/test_lazy.py:960:23-38: Default `object` is not assignable to parameter `v` with type `int` [bad-function-definition]
+ ERROR tests/lib/lazy/test_lazy.py:964:24-39: Default `object` is not assignable to parameter `v` with type `int` [bad-function-definition]
+ ERROR tests/lib/lazy/test_lazy.py:970:35-50: Default `object` is not assignable to parameter `v` with type `int` [bad-function-definition]
+ ERROR tests/lib/lazy/test_lazy.py:974:33-48: Default `object` is not assignable to parameter `v` with type `int` [bad-function-definition]
+ ERROR tests/lib/lazy/test_lazy.py:979:36-51: Default `object` is not assignable to parameter `v` with type `int` [bad-function-definition]
+ ERROR tests/lib/lazy/test_lazy.py:984:35-50: Default `object` is not assignable to parameter `v` with type `int` [bad-function-definition]
+ ERROR tests/test_examples.py:24:35-64: Cannot index into `dict[str, str]` [bad-index]
+ ERROR src/antidote/core/scope.py:130:26-30: Unexpected keyword argument `name` in function `object.__init__` [unexpected-keyword]
+ ERROR src/antidote/core/scope.py:130:37-44: Unexpected keyword argument `default` in function `object.__init__` [unexpected-keyword]
+ ERROR src/antidote/core/scope.py:130:54-61: Unexpected keyword argument `catalog` in function `object.__init__` [unexpected-keyword]
+ ERROR src/antidote/core/scope.py:132:34-69: `ScopeGlobalVar[T]` is not assignable to upper bound `AbstractScopeVar[Any]` of type variable `SVar` [bad-specialization]
+ ERROR src/antidote/core/scope.py:133:21-56: `ScopeGlobalVar[T]` is not assignable to upper bound `AbstractScopeVar[Any]` of type variable `SVar` [bad-specialization]
+ ERROR src/antidote/core/scope.py:133:58-69: Object of class `object` has no attribute `set` [missing-attribute]
+ ERROR src/antidote/core/scope.py:135:30-65: `ScopeGlobalVar[T]` is not assignable to upper bound `AbstractScopeVar[Any]` of type variable `SVar` [bad-specialization]
+ ERROR src/antidote/core/scope.py:136:16-29: Object of class `object` has no attribute `reset` [missing-attribute]
+ ::error file=tests/core/test_thread_safety.py,line=123,col=19,endLine=123,endColumn=34,title=Pyrefly bad-function-definition::Default `object` is not assignable to parameter `v1` with type `tuple[int, float]`
+ ::error file=tests/core/test_thread_safety.py,line=123,col=73,endLine=123,endColumn=88,title=Pyrefly bad-function-definition::Default `object` is not assignable to parameter `v2` with type `tuple[int, float]`
+ ::error file=tests/lib/lazy/test_lazy.py,line=960,col=23,endLine=960,endColumn=38,title=Pyrefly bad-function-definition::Default `object` is not assignable to parameter `v` with type `int`
+ ::error file=tests/lib/lazy/test_lazy.py,line=964,col=24,endLine=964,endColumn=39,title=Pyrefly bad-function-definition::Default `object` is not assignable to parameter `v` with type `int`
+ ::error file=tests/lib/lazy/test_lazy.py,line=970,col=35,endLine=970,endColumn=50,title=Pyrefly bad-function-definition::Default `object` is not assignable to parameter `v` with type `int`
+ ::error file=tests/lib/lazy/test_lazy.py,line=974,col=33,endLine=974,endColumn=48,title=Pyrefly bad-function-definition::Default `object` is not assignable to parameter `v` with type `int`
+ ::error file=tests/lib/lazy/test_lazy.py,line=979,col=36,endLine=979,endColumn=51,title=Pyrefly bad-function-definition::Default `object` is not assignable to parameter `v` with type `int`
+ ::error file=tests/lib/lazy/test_lazy.py,line=984,col=35,endLine=984,endColumn=50,title=Pyrefly bad-function-definition::Default `object` is not assignable to parameter `v` with type `int`
+ ::error file=tests/test_examples.py,line=24,col=35,endLine=24,endColumn=64,title=Pyrefly bad-index::Cannot index into `dict[str, str]`%0A Argument `object` is not assignable to parameter `key` with type `str` in function `dict.__getitem__`
+ ::error file=src/antidote/core/scope.py,line=130,col=26,endLine=130,endColumn=30,title=Pyrefly unexpected-keyword::Unexpected keyword argument `name` in function `object.__init__`
+ ::error file=src/antidote/core/scope.py,line=130,col=37,endLine=130,endColumn=44,title=Pyrefly unexpected-keyword::Unexpected keyword argument `default` in function `object.__init__`
+ ::error file=src/antidote/core/scope.py,line=130,col=54,endLine=130,endColumn=61,title=Pyrefly unexpected-keyword::Unexpected keyword argument `catalog` in function `object.__init__`
+ ::error file=src/antidote/core/scope.py,line=132,col=34,endLine=132,endColumn=69,title=Pyrefly bad-specialization::`ScopeGlobalVar[T]` is not assignable to upper bound `AbstractScopeVar[Any]` of type variable `SVar`
+ ::error file=src/antidote/core/scope.py,line=133,col=21,endLine=133,endColumn=56,title=Pyrefly bad-specialization::`ScopeGlobalVar[T]` is not assignable to upper bound `AbstractScopeVar[Any]` of type variable `SVar`
+ ::error file=src/antidote/core/scope.py,line=133,col=58,endLine=133,endColumn=69,title=Pyrefly missing-attribute::Object of class `object` has no attribute `set`
+ ::error file=src/antidote/core/scope.py,line=135,col=30,endLine=135,endColumn=65,title=Pyrefly bad-specialization::`ScopeGlobalVar[T]` is not assignable to upper bound `AbstractScopeVar[Any]` of type variable `SVar`
+ ::error file=src/antidote/core/scope.py,line=136,col=16,endLine=136,endColumn=29,title=Pyrefly missing-attribute::Object of class `object` has no attribute `reset`
Tanjun (https://github.com/FasterSpeeding/Tanjun)
+ ERROR tanjun/checks.py:178:26-31: Expected 0 positional arguments, got 2 in function `object.__init__` [bad-argument-count]
+ ERROR tanjun/checks.py:178:48-62: Unexpected keyword argument `halt_execution` in function `object.__init__` [unexpected-keyword]
+ ERROR tanjun/checks.py:189:16-35: Object of class `OwnerCheck` has no attribute `_handle_result` [missing-attribute]
+ ERROR tanjun/checks.py:236:26-31: Expected 0 positional arguments, got 2 in function `object.__init__` [bad-argument-count]
+ ERROR tanjun/checks.py:236:48-62: Unexpected keyword argument `halt_execution` in function `object.__init__` [unexpected-keyword]
+ ERROR tanjun/checks.py:242:16-35: Object of class `NsfwCheck` has no attribute `_handle_result` [missing-attribute]
+ ERROR tanjun/checks.py:282:26-31: Expected 0 positional arguments, got 2 in function `object.__init__` [bad-argument-count]
+ ERROR tanjun/checks.py:282:48-62: Unexpected keyword argument `halt_execution` in function `object.__init__` [unexpected-keyword]
+ ERROR tanjun/checks.py:288:16-35: Object of class `SfwCheck` has no attribute `_handle_result` [missing-attribute]
+ ERROR tanjun/checks.py:328:26-31: Expected 0 positional arguments, got 2 in function `object.__init__` [bad-argument-count]
+ ERROR tanjun/checks.py:328:48-62: Unexpected keyword argument `halt_execution` in function `object.__init__` [unexpected-keyword]
+ ERROR tanjun/checks.py:333:16-35: Object of class `DmCheck` has no attribute `_handle_result` [missing-attribute]
+ ERROR tanjun/checks.py:373:26-31: Expected 0 positional arguments, got 2 in function `object.__init__` [bad-argument-count]
+ ERROR tanjun/checks.py:373:48-62: Unexpected keyword argument `halt_execution` in function `object.__init__` [unexpected-keyword]
+ ERROR tanjun/checks.py:378:16-35: Object of class `GuildCheck` has no attribute `_handle_result` [missing-attribute]
+ ::error file=tanjun/checks.py,line=178,col=26,endLine=178,endColumn=31,title=Pyrefly bad-argument-count::Expected 0 positional arguments, got 2 in function `object.__init__`
+ ::error file=tanjun/checks.py,line=178,col=48,endLine=178,endColumn=62,title=Pyrefly unexpected-keyword::Unexpected keyword argument `halt_execution` in function `object.__init__`
+ ::error file=tanjun/checks.py,line=189,col=16,endLine=189,endColumn=35,title=Pyrefly missing-attribute::Object of class `OwnerCheck` has no attribute `_handle_result`
+ ::error file=tanjun/checks.py,line=236,col=26,endLine=236,endColumn=31,title=Pyrefly bad-argument-count::Expected 0 positional arguments, got 2 in function `object.__init__`
+ ::error file=tanjun/checks.py,line=236,col=48,endLine=236,endColumn=62,title=Pyrefly unexpected-keyword::Unexpected keyword argument `halt_execution` in function `object.__init__`
+ ::error file=tanjun/checks.py,line=242,col=16,endLine=242,endColumn=35,title=Pyrefly missing-attribute::Object of class `NsfwCheck` has no attribute `_handle_result`
+ ::error file=tanjun/checks.py,line=282,col=26,endLine=282,endColumn=31,title=Pyrefly bad-argument-count::Expected 0 positional arguments, got 2 in function `object.__init__`
+ ::error file=tanjun/checks.py,line=282,col=48,endLine=282,endColumn=62,title=Pyrefly unexpected-keyword::Unexpected keyword argument `halt_execution` in function `object.__init__`
+ ::error file=tanjun/checks.py,line=288,col=16,endLine=288,endColumn=35,title=Pyrefly missing-attribute::Object of class `SfwCheck` has no attribute `_handle_result`
+ ::error file=tanjun/checks.py,line=328,col=26,endLine=328,endColumn=31,title=Pyrefly bad-argument-count::Expected 0 positional arguments, got 2 in function `object.__init__`
+ ::error file=tanjun/checks.py,line=328,col=48,endLine=328,endColumn=62,title=Pyrefly unexpected-keyword::Unexpected keyword argument `halt_execution` in function `object.__init__`
+ ::error file=tanjun/checks.py,line=333,col=16,endLine=333,endColumn=35,title=Pyrefly missing-attribute::Object of class `DmCheck` has no attribute `_handle_result`
+ ::error file=tanjun/checks.py,line=373,col=26,endLine=373,endColumn=31,title=Pyrefly bad-argument-count::Expected 0 positional arguments, got 2 in function `object.__init__`
+ ::error file=tanjun/checks.py,line=373,col=48,endLine=373,endColumn=62,title=Pyrefly unexpected-keyword::Unexpected keyword argument `halt_execution` in function `object.__init__`
+ ::error file=tanjun/checks.py,line=378,col=16,endLine=378,endColumn=35,title=Pyrefly missing-attribute::Object of class `GuildCheck` has no attribute `_handle_result`
stone (https://github.com/dropbox/stone)
+ ERROR test/test_python_gen.py:334:45-54: Unexpected keyword argument `max_value` in function `object.__init__` [unexpected-keyword]
+ ERROR test/test_python_gen.py:598:45-54: Unexpected keyword argument `max_value` in function `object.__init__` [unexpected-keyword]
+ ::error file=test/test_python_gen.py,line=334,col=45,endLine=334,endColumn=54,title=Pyrefly unexpected-keyword::Unexpected keyword argument `max_value` in function `object.__init__`
+ ::error file=test/test_python_gen.py,line=598,col=45,endLine=598,endColumn=54,title=Pyrefly unexpected-keyword::Unexpected keyword argument `max_value` in function `object.__init__`
dd-trace-py (https://github.com/DataDog/dd-trace-py)
- ERROR tests/contrib/grpc_aio/hellostreamingworld_pb2.pyi:10:17-28: `list[str]` is not assignable to attribute `__slots__` with type `tuple[str, ...]` [bad-assignment]
- ERROR tests/contrib/grpc_aio/hellostreamingworld_pb2.pyi:16:17-42: `list[str]` is not assignable to attribute `__slots__` with type `tuple[str, ...]` [bad-assignment]
- ::error file=tests/contrib/grpc_aio/hellostreamingworld_pb2.pyi,line=10,col=17,endLine=10,endColumn=28,title=Pyrefly bad-assignment::`list[str]` is not assignable to attribute `__slots__` with type `tuple[str, ...]`
- ::error file=tests/contrib/grpc_aio/hellostreamingworld_pb2.pyi,line=16,col=17,endLine=16,endColumn=42,title=Pyrefly bad-assignment::`list[str]` is not assignable to attribute `__slots__` with type `tuple[str, ...]`
zope.interface (https://github.com/zopefoundation/zope.interface)
+ ERROR src/zope/interface/common/collections.py:229:5-8: Class member `IMappingView.abc` overrides parent class `ISized` in an inconsistent manner [bad-override]
+ ERROR src/zope/interface/common/collections.py:241:5-8: Class member `IValuesView.abc` overrides parent class `ICollection` in an inconsistent manner [bad-override]
+ ERROR src/zope/interface/common/numbers.py:39:5-8: Class member `IComplex.abc` overrides parent class `INumber` in an inconsistent manner [bad-override]
+ ERROR src/zope/interface/common/numbers.py:49:5-8: Class member `IReal.abc` overrides parent class `IComplex` in an inconsistent manner [bad-override]
+ ERROR src/zope/interface/common/numbers.py:61:5-8: Class member `IRational.abc` overrides parent class `IReal` in an inconsistent manner [bad-override]
+ ERROR src/zope/interface/common/numbers.py:65:5-8: Class member `IIntegral.abc` overrides parent class `IRational` in an inconsistent manner [bad-override]
+ ::error file=src/zope/interface/common/collections.py,line=229,col=5,endLine=229,endColumn=8,title=Pyrefly bad-override::Class member `IMappingView.abc` overrides parent class `ISized` in an inconsistent manner%0A `IMappingView.abc` has type `type[MappingView]`, which is not consistent with `type[Sized]` in `ISized.abc` (the type of read-write attributes cannot be changed)
- ::error file=src/zope/interface/common/collections.py,line=233,col=5,endLine=233,endColumn=8,title=Pyrefly bad-override::Class member `IItemsView.abc` overrides parent class `ISet` in an inconsistent manner%0A `IItemsView.abc` has type `type[Sized]`, which is not consistent with `type[AbstractSet]` in `ISet.abc` (the type of read-write attributes cannot be changed)
+ ::error file=src/zope/interface/common/collections.py,line=233,col=5,endLine=233,endColumn=8,title=Pyrefly bad-override::Class member `IItemsView.abc` overrides parent class `ISet` in an inconsistent manner%0A `IItemsView.abc` has type `type[MappingView]`, which is not consistent with `type[AbstractSet]` in `ISet.abc` (the type of read-write attributes cannot be changed)
- ::error file=src/zope/interface/common/collections.py,line=237,col=5,endLine=237,endColumn=8,title=Pyrefly bad-override::Class member `IKeysView.abc` overrides parent class `ISet` in an inconsistent manner%0A `IKeysView.abc` has type `type[Sized]`, which is not consistent with `type[AbstractSet]` in `ISet.abc` (the type of read-write attributes cannot be changed)
+ ::error file=src/zope/interface/common/collections.py,line=237,col=5,endLine=237,endColumn=8,title=Pyrefly bad-override::Class member `IKeysView.abc` overrides parent class `ISet` in an inconsistent manner%0A `IKeysView.abc` has type `type[MappingView]`, which is not consistent with `type[AbstractSet]` in `ISet.abc` (the type of read-write attributes cannot be changed)
+ ::error file=src/zope/interface/common/collections.py,line=241,col=5,endLine=241,endColumn=8,title=Pyrefly bad-override::Class member `IValuesView.abc` overrides parent class `ICollection` in an inconsistent manner%0A `IValuesView.abc` has type `type[MappingView]`, which is not consistent with `type[Sized]` in `ICollection.abc` (the type of read-write attributes cannot be changed)
+ ::error file=src/zope/interface/common/numbers.py,line=39,col=5,endLine=39,endColumn=8,title=Pyrefly bad-override::Class member `IComplex.abc` overrides parent class `INumber` in an inconsistent manner%0A `IComplex.abc` has type `type[Complex]`, which is not consistent with `type[Number]` in `INumber.abc` (the type of read-write attributes cannot be changed)
+ ::error file=src/zope/interface/common/numbers.py,line=49,col=5,endLine=49,endColumn=8,title=Pyrefly bad-override::Class member `IReal.abc` overrides parent class `IComplex` in an inconsistent manner%0A `IReal.abc` has type `type[Real]`, which is not consistent with `type[Complex]` in `IComplex.abc` (the type of read-write attributes cannot be changed)
+ ::error file=src/zope/interface/common/numbers.py,line=61,col=5,endLine=61,endColumn=8,title=Pyrefly bad-override::Class member `IRational.abc` overrides parent class `IReal` in an inconsistent manner%0A `IRational.abc` has type `type[Rational]`, which is not consistent with `type[Real]` in `IReal.abc` (the type of read-write attributes cannot be changed)
+ ::error file=src/zope/interface/common/numbers.py,line=65,col=5,endLine=65,endColumn=8,title=Pyrefly bad-override::Class member `IIntegral.abc` overrides parent class `IRational` in an inconsistent manner%0A `IIntegral.abc` has type `type[Integral]`, which is not consistent with `type[Rational]` in `IRational.abc` (the type of read-write attributes cannot be changed)
discord.py (https://github.com/Rapptz/discord.py)
+ ERROR discord/abc.py:574:9-25: Cannot assign to attribute `_overwrites`: not listed in `__slots__` of class `GuildChannel` [missing-attribute]
+ ERROR discord/app_commands/tree.py:1128:9-35: Cannot assign to attribute `command_failed`: not listed in `__slots__` of class `Interaction` [missing-attribute]
- ERROR discord/app_commands/tree.py:1216:9-32: Object of class `Interaction` has no attribute `_cs_command` [missing-attribute]
+ ERROR discord/app_commands/tree.py:1216:9-32: Cannot assign to attribute `_cs_command`: not listed in `__slots__` of class `Interaction` [missing-attribute]
- ERROR discord/app_commands/tree.py:1273:9-32: Object of class `Interaction` has no attribute `_cs_command` [missing-attribute]
+ ERROR discord/app_commands/tree.py:1260:13-39: Cannot assign to attribute `command_failed`: not listed in `__slots__` of class `Interaction` [missing-attribute]
+ ERROR discord/app_commands/tree.py:1273:9-32: Cannot assign to attribute `_cs_command`: not listed in `__slots__` of class `Interaction` [missing-attribute]
- ERROR discord/app_commands/tree.py:1280:9-34: Object of class `Interaction` has no attribute `_cs_namespace` [missing-attribute]
+ ERROR discord/app_commands/tree.py:1280:9-34: Cannot assign to attribute `_cs_namespace`: not listed in `__slots__` of class `Interaction` [missing-attribute]
+ ERROR discord/app_commands/tree.py:1299:13-39: Cannot assign to attribute `command_failed`: not listed in `__slots__` of class `Interaction` [missing-attribute]
+ ERROR discord/asset.py:213:9-20: Cannot assign to attribute `_state`: not listed in `__slots__` of class `Asset` [missing-attribute]
+ ERROR discord/asset.py:214:9-18: Cannot assign to attribute `_url`: not listed in `__slots__` of class `Asset` [missing-attribute]
+ ERROR discord/asset.py:215:9-23: Cannot assign to attribute `_animated`: not listed in `__slots__` of class `Asset` [missing-attribute]
+ ERROR discord/asset.py:216:9-18: Cannot assign to attribute `_key`: not listed in `__slots__` of class `Asset` [missing-attribute]
+ ERROR discord/channel.py:207:26-31: Unexpected keyword argument `state` in function `object.__init__` [unexpected-keyword]
+ ERROR discord/channel.py:207:39-43: Unexpected keyword argument `data` in function `object.__init__` [unexpected-keyword]
+ ERROR discord/channel.py:210:49-56: Object of class `VoiceChannelSoundEffect` has no attribute `id` [missing-attribute]
+ ERROR discord/channel.py:210:66-77: Object of class `VoiceChannelSoundEffect` has no attribute `volume` [missing-attribute]
+ ERROR discord/channel.py:219:41-48: Object of class `VoiceChannelSoundEffect` has no attribute `id` [missing-attribute]
+ ERROR discord/channel.py:224:16-23: Object of class `VoiceChannelSoundEffect` has no attribute `id` [missing-attribute]
+ ERROR discord/components.py:197:9-16: Cannot assign to attribute `id`: not listed in `__slots__` of class `ActionRow` [missing-attribute]
+ ERROR discord/components.py:198:9-22: Cannot assign to attribute `children`: not listed in `__slots__` of class `ActionRow` [missing-attribute]
+ ERROR discord/components.py:272:9-16: Cannot assign to attribute `id`: not listed in `__slots__` of class `Button` [missing-attribute]
+ ERROR discord/components.py:273:9-19: Cannot assign to attribute `style`: not listed in `__slots__` of class `Button` [missing-attribute]
+ ERROR discord/components.py:274:9-23: Cannot assign to attribute `custom_id`: not listed in `__slots__` of class `Button` [missing-attribute]
+ ERROR discord/components.py:275:9-17: Cannot assign to attribute `url`: not listed in `__slots__` of class `Button` [missing-attribute]
+ ERROR discord/components.py:276:9-22: Cannot assign to attribute `disabled`: not listed in `__slots__` of class `Button` [missing-attribute]
+ ERROR discord/components.py:277:9-19: Cannot assign to attribute `label`: not listed in `__slots__` of class `Button` [missing-attribute]
+ ERROR discord/components.py:280:13-23: Cannot assign to attribute `emoji`: not listed in `__slots__` of class `Button` [missing-attribute]
+ ERROR discord/components.py:282:13-23: Cannot assign to attribute `emoji`: not listed in `__slots__` of class `Button` [missing-attribute]
+ ERROR discord/components.py:285:13-24: Cannot assign to attribute `sku_id`: not listed in `__slots__` of class `Button` [missing-attribute]
+ ERROR discord/components.py:287:13-24: Cannot assign to attribute `sku_id`: not listed in `__slots__` of class `Button` [missing-attribute]
+ ERROR discord/components.py:383:9-23: Cannot assign to attribute `custom_id`: not listed in `__slots__` of class `SelectMenu` [missing-attribute]
+ ERROR discord/components.py:384:9-25: Cannot assign to attribute `placeholder`: not listed in `__slots__` of class `SelectMenu` [missing-attribute]
+ ERROR discord/components.py:385:9-24: Cannot assign to attribute `min_values`: not listed in `__slots__` of class `SelectMenu` [missing-attribute]
+ ERROR discord/components.py:386:9-24: Cannot assign to attribute `max_values`: not listed in `__slots__` of class `SelectMenu` [missing-attribute]
+ ERROR discord/components.py:387:9-22: Cannot assign to attribute `required`: not listed in `__slots__` of class `SelectMenu` [missing-attribute]
+ ERROR discord/components.py:388:9-21: Cannot assign to attribute `options`: not listed in `__slots__` of class `SelectMenu` [missing-attribute]
+ ERROR discord/components.py:389:9-22: Cannot assign to attribute `disabled`: not listed in `__slots__` of class `SelectMenu` [missing-attribute]
+ ERROR discord/components.py:390:9-27: Cannot assign to attribute `channel_types`: not listed in `__slots__` of class `SelectMenu` [missing-attribute]
+ ERROR discord/components.py:391:9-28: Cannot assign to attribute `default_values`: not listed in `__slots__` of class `SelectMenu` [missing-attribute]
+ ERROR discord/components.py:394:9-16: Cannot assign to attribute `id`: not listed in `__slots__` of class `SelectMenu` [missing-attribute]
- ERROR discord/components.py:512:27-31: `None` is not assignable to attribute `_emoji` with type `PartialEmoji` [bad-assignment]
+ ERROR discord/components.py:474:9-19: Cannot assign to attribute `label`: not listed in `__slots__` of class `SelectOption` [missing-attribute]
+ ERROR discord/components.py:475:9-19: Cannot assign to attribute `value`: not listed in `__slots__` of class `SelectOption` [missing-attribute]
+ ERROR discord/components.py:476:9-25: Cannot assign to attribute `description`: not listed in `__slots__` of class `SelectOption` [missing-attribute]
+ ERROR discord/components.py:479:9-21: Cannot assign to attribute `default`: not listed in `__slots__` of class `SelectOption` [missing-attribute]
+ ERROR discord/components.py:506:17-28: Cannot assign to attribute `_emoji`: not listed in `__slots__` of class `SelectOption` [missing-attribute]
+ ERROR discord/components.py:508:17-28: Cannot assign to attribute `_emoji`: not listed in `__slots__` of class `SelectOption` [missing-attribute]
+ ERROR discord/components.py:512:13-24: Cannot assign to attribute `_emoji`: not listed in `__slots__` of class `SelectOption` [missing-attribute]
+ ERROR discord/components.py:596:9-19: Cannot assign to attribute `style`: not listed in `__slots__` of class `TextInput` [missing-attribute]
+ ERROR discord/components.py:597:9-19: Cannot assign to attribute `label`: not listed in `__slots__` of class `TextInput` [missing-attribute]
+ ERROR discord/components.py:598:9-23: Cannot assign to attribute `custom_id`: not listed in `__slots__` of class `TextInput` [missing-attribute]
+ ERROR discord/components.py:599:9-25: Cannot assign to attribute `placeholder`: not listed in `__slots__` of class `TextInput` [missing-attribute]
+ ERROR discord/components.py:600:9-19: Cannot assign to attribute `value`: not listed in `__slots__` of class `TextInput` [missing-attribute]
+ ERROR discord/components.py:601:9-22: Cannot assign to attribute `required`: not listed in `__slots__` of class `TextInput` [missing-attribute]
+ ERROR discord/components.py:602:9-24: Cannot assign to attribute `min_length`: not listed in `__slots__` of class `TextInput` [missing-attribute]
+ ERROR discord/components.py:603:9-24: Cannot assign to attribute `max_length`: not listed in `__slots__` of class `TextInput` [missing-attribute]
+ ERROR discord/components.py:604:9-16: Cannot assign to attribute `id`: not listed in `__slots__` of class `TextInput` [missing-attribute]
+ ERROR discord/components.py:787:9-22: Cannot assign to attribute `children`: not listed in `__slots__` of class `SectionComponent` [missing-attribute]
+ ERROR discord/components.py:789:9-16: Cannot assign to attribute `id`: not listed in `__slots__` of class `SectionComponent` [missing-attribute]
+ ERROR discord/components.py:851:9-19: Cannot assign to attribute `media`: not listed in `__slots__` of class `ThumbnailComponent` [missing-attribute]
+ ERROR discord/components.py:852:9-25: Cannot assign to attribute `description`: not listed in `__slots__` of class `ThumbnailComponent` [missing-attribute]
+ ERROR discord/components.py:853:9-21: Cannot assign to attribute `spoiler`: not listed in `__slots__` of class `ThumbnailComponent` [missing-attribute]
+ ERROR discord/components.py:854:9-16: Cannot assign to attribute `id`: not listed in `__slots__` of class `ThumbnailComponent` [missing-attribute]
+ ERROR discord/components.py:899:9-21: Cannot assign to attribute `content`: not listed in `__slots__` of class `TextDisplay` [missing-attribute]
+ ERROR discord/components.py:900:9-16: Cannot assign to attribute `id`: not listed in `__slots__` of class `TextDisplay` [missing-attribute]
+ ERROR discord/components.py:1130:9-19: Cannot assign to attribute `items`: not listed in `__slots__` of class `MediaGalleryComponent` [missing-attribute]
+ ERROR discord/components.py:1131:9-16: Cannot assign to attribute `id`: not listed in `__slots__` of class `MediaGalleryComponent` [missing-attribute]
+ ERROR discord/components.py:1184:9-19: Cannot assign to attribute `media`: not listed in `__slots__` of class `FileComponent` [missing-attribute]
+ ERROR discord/components.py:1185:9-21: Cannot assign to attribute `spoiler`: not listed in `__slots__` of class `FileComponent` [missing-attribute]
+ ERROR discord/components.py:1186:9-16: Cannot assign to attribute `id`: not listed in `__slots__` of class `FileComponent` [missing-attribute]
+ ERROR discord/components.py:1187:9-18: Cannot assign to attribute `name`: not listed in `__slots__` of class `FileComponent` [missing-attribute]
+ ERROR discord/components.py:1188:9-18: Cannot assign to attribute `size`: not listed in `__slots__` of class `FileComponent` [missing-attribute]
+ ERROR discord/components.py:1239:9-21: Cannot assign to attribute `spacing`: not listed in `__slots__` of class `SeparatorComponent` [missing-attribute]
+ ERROR discord/components.py:1240:9-21: Cannot assign to attribute `visible`: not listed in `__slots__` of class `SeparatorComponent` [missing-attribute]
+ ERROR discord/components.py:1241:9-16: Cannot assign to attribute `id`: not listed in `__slots__` of class `SeparatorComponent` [missing-attribute]
+ ERROR discord/components.py:1295:9-22: Cannot assign to attribute `children`: not listed in `__slots__` of class `Container` [missing-attribute]
+ ERROR discord/components.py:1296:9-16: Cannot assign to attribute `id`: not listed in `__slots__` of class `Container` [missing-attribute]
+ ERROR discord/components.py:1304:9-21: Cannot assign to attribute `spoiler`: not listed in `__slots__` of class `Container` [missing-attribute]
+ ERROR discord/components.py:1307:9-21: Cannot assign to attribute `_colour`: not listed in `__slots__` of class `Container` [missing-attribute]
+ ERROR discord/components.py:1309:13-25: Cannot assign to attribute `_colour`: not listed in `__slots__` of class `Container` [missing-attribute]
+ ERROR discord/components.py:1370:9-19: Cannot assign to attribute `label`: not listed in `__slots__` of class `LabelComponent` [missing-attribute]
+ ERROR discord/components.py:1371:9-16: Cannot assign to attribute `id`: not listed in `__slots__` of class `LabelComponent` [missing-attribute]
+ ERROR discord/components.py:1372:9-25: Cannot assign to attribute `description`: not listed in `__slots__` of class `LabelComponent` [missing-attribute]
+ ERROR discord/components.py:1431:9-23: Cannot assign to attribute `custom_id`: not listed in `__slots__` of class `FileUploadComponent` [missing-attribute]
+ ERROR discord/components.py:1432:9-24: Cannot assign to attribute `min_values`: not listed in `__slots__` of class `FileUploadComponent` [missing-attribute]
+ ERROR discord/components.py:1433:9-24: Cannot assign to attribute `max_values`: not listed in `__slots__` of class `FileUploadComponent` [missing-attribute]
+ ERROR discord/components.py:1434:9-22: Cannot assign to attribute `required`: not listed in `__slots__` of class `FileUploadComponent` [missing-attribute]
+ ERROR discord/components.py:1435:9-16: Cannot assign to attribute `id`: not listed in `__slots__` of class `FileUploadComponent` [missing-attribute]
+ ERROR discord/emoji.py:118:9-22: Cannot assign to attribute `guild_id`: not listed in `__slots__` of class `Emoji` [missing-attribute]
+ ERROR discord/emoji.py:119:9-20: Cannot assign to attribute `_state`: not listed in `__slots__` of class `Emoji` [missing-attribute]
+ ERROR discord/emoji.py:123:9-28: Cannot assign to attribute `require_colons`: not listed in `__slots__` of class `Emoji` [missing-attribute]
+ ERROR discord/emoji.py:124:9-21: Cannot assign to attribute `managed`: not listed in `__slots__` of class `Emoji` [missing-attribute]
+ ERROR discord/emoji.py:127:9-22: Cannot assign to attribute `animated`: not listed in `__slots__` of class `Emoji` [missing-attribute]
+ ERROR discord/emoji.py:128:9-23: Cannot assign to attribute `available`: not listed in `__slots__` of class `Emoji` [missing-attribute]
+ ERROR discord/emoji.py:129:9-20: Cannot assign to attribute `_roles`: not listed in `__slots__` of class `Emoji` [missing-attribute]
+ ERROR discord/emoji.py:131:9-18: Cannot assign to attribute `user`: not listed in `__slots__` of class `Emoji` [missing-attribute]
+ ERROR discord/ext/commands/context.py:304:9-27: Cannot assign to attribute `_baton`: not listed in `__slots__` of class `Interaction` [missing-attribute]
+ ERROR discord/ext/commands/hybrid.py:455:9-27: Cannot assign to attribute `_baton`: not listed in `__slots__` of class `Interaction` [missing-attribute]
+ ERROR discord/ext/commands/hybrid.py:490:9-35: Cannot assign to attribute `command_failed`: not listed in `__slots__` of class `Interaction` [missing-attribute]
- ERROR discord/interactions.py:214:48-64: `object | ButtonMessageComponentInteractionData | ChatInputApplicationCommandInteractionData | MessageApplicationCommandInteractionData | ModalSubmitInteractionData | SelectMessageComponentInteractionData | UserApplicationCommandInteractionData | None` is not assignable to attribute `data` with type `ButtonMessageComponentInteractionData | ChatInputApplicationCommandInteractionData | MessageApplicationCommandInteractionData | ModalSubmitInteractionData | SelectMessageComponentInteractionData | UserApplicationCommandInteractionData | None` [bad-assignment]
+ ERROR discord/interactions.py:197:9-20: Cannot assign to attribute `_state`: not listed in `__slots__` of class `Interaction` [missing-attribute]
+ ERROR discord/interactions.py:198:9-21: Cannot assign to attribute `_client`: not listed in `__slots__` of class `Interaction` [missing-attribute]
+ ERROR discord/interactions.py:200:9-32: Cannot assign to attribute `_original_response`: not listed in `__slots__` of class `Interaction` [missing-attribute]
+ ERROR discord/interactions.py:203:9-20: Cannot assign to attribute `_baton`: not listed in `__slots__` of class `Interaction` [missing-attribute]
+ ERROR discord/interactions.py:204:9-20: Cannot assign to attribute `extras`: not listed in `__slots__` of class `Interaction` [missing-attribute]
+ ERROR discord/interactions.py:205:9-28: Cannot assign to attribute `command_failed`: not listed in `__slots__` of class `Interaction` [missing-attribute]
+ ERROR discord/interactions.py:212:9-16: Cannot assign to attribute `id`: not listed in `__slots__` of class `Interaction` [missing-attribute]
+ ERROR discord/interactions.py:213:9-18: Cannot assign to attribute `type`: not listed in `__slots__` of class `Interaction` [missing-attribute]
... (truncated 540 lines) ...
pydantic (https://github.com/pydantic/pydantic)
+ ERROR pydantic/v1/color.py:70:13-23: Cannot assign to attribute `_rgba`: not listed in `__slots__` of class `Color` [missing-attribute]
+ ERROR pydantic/v1/color.py:72:13-23: Cannot assign to attribute `_rgba`: not listed in `__slots__` of class `Color` [missing-attribute]
+ ERROR pydantic/v1/color.py:74:13-23: Cannot assign to attribute `_rgba`: not listed in `__slots__` of class `Color` [missing-attribute]
+ ERROR pydantic/v1/color.py:80:9-23: Cannot assign to attribute `_original`: not listed in `__slots__` of class `Color` [missing-attribute]
- ERROR pydantic/v1/fields.py:593:36-62: Expected a type form, got instance of `tuple[Any, ...]` [not-a-type]
- ERROR pydantic/v1/fields.py:607:30-40: Argument `type[Any] | TypeVar | Unknown` is not assignable to parameter `type_` with type `type[Any]` in function `pydantic.v1.typing.is_literal_type` [bad-argument-type]
- ERROR pydantic/v1/fields.py:609:27-37: Argument `type[Any] | TypeVar | Unknown` is not assignable to parameter `type_` with type `type[Any]` in function `pydantic.v1.typing.is_typeddict` [bad-argument-type]
- ERROR pydantic/v1/fields.py:612:24-34: Argument `type[Any] | TypeVar | Unknown` is not assignable to parameter `ann_type` with type `type[Any]` in function `pydantic.v1.typing.is_finalvar` [bad-argument-type]
- ERROR pydantic/v1/fields.py:618:39-49: Argument `type[Any] | TypeVar | Unknown` is not assignable to parameter `tp` with type `type[Any]` in function `pydantic.v1.typing.get_args` [bad-argument-type]
- ERROR pydantic/v1/fields.py:623:29-39: Argument `type[Any] | TypeVar | Unknown` is not assignable to parameter `tp` with type `type[Any]` in function `pydantic.v1.typing.get_origin` [bad-argument-type]
- ERROR pydantic/v1/fields.py:626:35-45: Argument `type[Any] | TypeVar | Unknown` is not assignable to parameter `tp` with type `type[Any]` in function `pydantic.v1.typing.get_args` [bad-argument-type]
- ERROR pydantic/v1/fields.py:644:35-45: Argument `type[Any] | TypeVar | Unknown` is not assignable to parameter `tp` with type `type[Any]` in function `pydantic.v1.typing.get_args` [bad-argument-type]
- ERROR pydantic/v1/fields.py:668:29-39: Argument `type[Any] | TypeVar | Unknown` is not assignable to parameter `tp` with type `type[Any]` in function `pydantic.v1.typing.get_args` [bad-argument-type]
- ERROR pydantic/v1/fields.py:692:35-45: Argument `type[Any] | TypeVar | Unknown` is not assignable to parameter `tp` with type `type[Any]` in function `pydantic.v1.typing.get_args` [bad-argument-type]
- ERROR pydantic/v1/fields.py:702:35-45: Argument `type[Any] | TypeVar | Unknown` is not assignable to parameter `tp` with type `type[Any]` in function `pydantic.v1.typing.get_args` [bad-argument-type]
- ERROR pydantic/v1/fields.py:712:35-45: Argument `type[Any] | TypeVar | Unknown` is not assignable to parameter `tp` with type `type[Any]` in function `pydantic.v1.typing.get_args` [bad-argument-type]
- ERROR pydantic/v1/fields.py:715:35-45: Argument `type[Any] | TypeVar | Unknown` is not assignable to parameter `tp` with type `type[Any]` in function `pydantic.v1.typing.get_args` [bad-argument-type]
- ERROR pydantic/v1/fields.py:718:35-45: Argument `type[Any] | TypeVar | Unknown` is not assignable to parameter `tp` with type `type[Any]` in function `pydantic.v1.typing.get_args` [bad-argument-type]
- ERROR pydantic/v1/fields.py:722:61-71: Argument `type[Any] | TypeVar | Unknown` is not assignable to parameter `tp` with type `type[Any]` in function `pydantic.v1.typing.get_args` [bad-argument-type]
- ERROR pydantic/v1/fields.py:723:35-45: Argument `type[Any] | TypeVar | Unknown` is not assignable to parameter `tp` with type `type[Any]` in function `pydantic.v1.typing.get_args` [bad-argument-type]
- ERROR pydantic/v1/fields.py:726:61-71: Argument `type[Any] | TypeVar | Unknown` is not assignable to parameter `tp` with type `type[Any]` in function `pydantic.v1.typing.get_args` [bad-argument-type]
- ERROR pydantic/v1/fields.py:727:35-45: Argument `type[Any] | TypeVar | Unknown` is not assignable to parameter `tp` with type `type[Any]` in function `pydantic.v1.typing.get_args` [bad-argument-type]
- ERROR pydantic/v1/fields.py:730:61-71: Argument `type[Any] | TypeVar | Unknown` is not assignable to parameter `tp` with type `type[Any]` in function `pydantic.v1.typing.get_args` [bad-argument-type]
- ERROR pydantic/v1/fields.py:734:61-71: Argument `type[Any] | TypeVar | Unknown` is not assignable to parameter `tp` with type `type[Any]` in function `pydantic.v1.typing.get_args` [bad-argument-type]
- ERROR pydantic/v1/fields.py:735:35-45: Argument `type[Any] | TypeVar | Unknown` is not assignable to parameter `tp` with type `type[Any]` in function `pydantic.v1.typing.get_args` [bad-argument-type]
- ERROR pydantic/v1/fields.py:740:35-45: Argument `type[Any] | TypeVar | Unknown` is not assignable to parameter `tp` with type `type[Any]` in function `pydantic.v1.typing.get_args` [bad-argument-type]
- ERROR pydantic/v1/fields.py:749:108-118: Argument `type[Any] | TypeVar | Unknown` is not assignable to parameter `tp` with type `type[Any]` in function `pydantic.v1.typing.get_args` [bad-argument-type]
- ERROR pydantic/v1/fields.py:756:50-60: Argument `type[Any] | TypeVar | Unknown` is not assignable to parameter `type_` with type `type[Any]` in function `ModelField._create_sub_type` [bad-argument-type]
+ ERROR pydantic/v1/error_wrappers.py:32:9-17: Cannot assign to attribute `exc`: not listed in `__slots__` of class `ErrorWrapper` [missing-attribute]
+ ERROR pydantic/v1/error_wrappers.py:33:9-18: Cannot assign to attribute `_loc`: not listed in `__slots__` of class `ErrorWrapper` [missing-attribute]
+ ERROR pydantic/v1/fields.py:152:9-21: Cannot assign to attribute `default`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:153:9-29: Cannot assign to attribute `default_factory`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:154:9-19: Cannot assign to attribute `alias`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:155:9-28: Cannot assign to attribute `alias_priority`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:156:9-19: Cannot assign to attribute `title`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:157:9-25: Cannot assign to attribute `description`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:158:9-21: Cannot assign to attribute `exclude`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:159:9-21: Cannot assign to attribute `include`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:160:9-19: Cannot assign to attribute `const`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:161:9-16: Cannot assign to attribute `gt`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:162:9-16: Cannot assign to attribute `ge`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:163:9-16: Cannot assign to attribute `lt`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:164:9-16: Cannot assign to attribute `le`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:165:9-25: Cannot assign to attribute `multiple_of`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:166:9-27: Cannot assign to attribute `allow_inf_nan`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:167:9-24: Cannot assign to attribute `max_digits`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:168:9-28: Cannot assign to attribute `decimal_places`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:169:9-23: Cannot assign to attribute `min_items`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:170:9-23: Cannot assign to attribute `max_items`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:171:9-26: Cannot assign to attribute `unique_items`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:172:9-24: Cannot assign to attribute `min_length`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:173:9-24: Cannot assign to attribute `max_length`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:174:9-28: Cannot assign to attribute `allow_mutation`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:175:9-19: Cannot assign to attribute `regex`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:176:9-27: Cannot assign to attribute `discriminator`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:177:9-18: Cannot assign to attribute `repr`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:178:9-19: Cannot assign to attribute `extra`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:212:21-33: Cannot assign to attribute `exclude`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:214:21-33: Cannot assign to attribute `include`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:407:9-18: Cannot assign to attribute `name`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:408:9-23: Cannot assign to attribute `has_alias`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:409:9-19: Cannot assign to attribute `alias`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:410:9-24: Cannot assign to attribute `annotation`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:411:9-19: Cannot assign to attribute `type_`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:412:9-25: Cannot assign to attribute `outer_type_`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:413:9-30: Cannot assign to attribute `class_validators`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:414:9-21: Cannot assign to attribute `default`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:415:9-29: Cannot assign to attribute `default_factory`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:416:9-22: Cannot assign to attribute `required`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:417:9-19: Cannot assign to attribute `final`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:418:9-26: Cannot assign to attribute `model_config`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:419:9-24: Cannot assign to attribute `field_info`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:420:9-31: Cannot assign to attribute `discriminator_key`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:421:9-33: Cannot assign to attribute `discriminator_alias`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:423:9-24: Cannot assign to attribute `allow_none`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:424:9-29: Cannot assign to attribute `validate_always`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:425:9-24: Cannot assign to attribute `sub_fields`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:426:9-32: Cannot assign to attribute `sub_fields_mapping`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:427:9-23: Cannot assign to attribute `key_field`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:428:9-24: Cannot assign to attribute `validators`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:429:9-28: Cannot assign to attribute `pre_validators`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:430:9-29: Cannot assign to attribute `post_validators`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:431:9-24: Cannot assign to attribute `parse_json`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:432:9-19: Cannot assign to attribute `shape`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:470:21-39: Cannot assign to attribute `default`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:517:9-26: Cannot assign to attribute `model_config`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:523:13-34: Cannot assign to attribute `alias`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:524:13-43: Cannot assign to attribute `alias_priority`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:525:13-23: Cannot assign to attribute `alias`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:528:13-36: Cannot assign to attribute `exclude`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:531:13-36: Cannot assign to attribute `include`: not listed in `__slots__` of class `FieldInfo` [missing-attribute]
+ ERROR pydantic/v1/fields.py:552:13-26: Cannot assign to attribute `required`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:554:13-25: Cannot assign to attribute `default`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:571:13-23: Cannot assign to attribute `type_`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:572:13-29: Cannot assign to attribute `outer_type_`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:573:13-28: Cannot assign to attribute `annotation`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:579:13-28: Cannot assign to attribute `allow_none`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:584:13-23: Cannot assign to attribute `type_`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:585:13-28: Cannot assign to attribute `parse_json`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:587:13-23: Cannot assign to attribute `type_`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:588:13-28: Cannot assign to attribute `parse_json`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:591:17-27: Cannot assign to attribute `type_`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:593:17-27: Cannot assign to attribute `type_`: not listed in `__slots__` of class `ModelField` [missing-attribute]
+ ERROR pydantic/v1/fields.py:595:17-27: Cannot assign to attribute `type_`: not listed in `__slots__` of class `ModelField` [missing-attribute]
... (truncated 256 lines) ...
mongo-python-driver (https://github.com/mongodb/mongo-python-driver)
+ ERROR pymongo/operations.py:231:26-32: Expected 0 positional arguments, got 4 in function `object.__init__` [bad-argument-count]
... (truncated 425 lines) ...``` |
Summary
Validate that attribute assignments like
self.y = 3respect__slots__restrictions. When a class defines__slots__, Pyrefly now errors if you try to assign to an attribute not in the slots.Key changes:
ClassAttributehandling path (not justcheck_setattrwhich only runs for unfound attributes)slots_metadata()tocompute_slots_metadata()and make it public, called on-demand to ensure fields are fully solved__slots__correctly (they get implicit__dict__and allow any attributes)Addresses #630.
Tests
Added 6 test cases covering:
@dataclass(slots=True)preventing unknown attributes__slots__ = ("x",)preventing unknown attributes__dict__in slots allowing dynamic attributes__slots__getting implicit__dict__Open to feedback!