Skip to content

Commit

Permalink
Added check for __slots__ initialization when the __slots__ list …
Browse files Browse the repository at this point in the history
…is empty and the class is marked `@final`. This addresses #9387. (#9389)
  • Loading branch information
erictraut authored Nov 5, 2024
1 parent 6fb940a commit ae9160e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/pyright-internal/src/analyzer/typeEvaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3693,10 +3693,11 @@ export function createTypeEvaluator(
const inheritedSlotsNames = ClassType.getInheritedSlotsNames(memberClass);

if (inheritedSlotsNames && memberClass.shared.localSlotsNames) {
// Skip this check if the local slots is specified but empty because this pattern
// is used in a legitimate manner for mix-in classes.
// Skip this check if the local slots is specified but empty
// and the class isn't final. This pattern is used in a
// legitimate manner for mix-in classes.
if (
memberClass.shared.localSlotsNames.length > 0 &&
(memberClass.shared.localSlotsNames.length > 0 || ClassType.isFinal(memberClass)) &&
!inheritedSlotsNames.some((name) => name === memberName)
) {
// Determine whether the assignment corresponds to a descriptor
Expand Down

0 comments on commit ae9160e

Please sign in to comment.