mirror of
https://github.com/microsoft/pyright.git
synced 2025-12-23 09:19:29 +00:00
Fixed regression that results in a false positive when using the pydantic.dataclasses.dataclass decorator. This addresses #11060. (#11084)
Some checks are pending
Run mypy_primer on push / Run mypy_primer on push (push) Waiting to run
Validation / Typecheck (push) Waiting to run
Validation / Style (push) Waiting to run
Validation / Test macos-latest (push) Blocked by required conditions
Validation / Test ubuntu-latest (push) Blocked by required conditions
Validation / Test windows-latest (push) Blocked by required conditions
Validation / Build (push) Blocked by required conditions
Validation / Required (push) Blocked by required conditions
Some checks are pending
Run mypy_primer on push / Run mypy_primer on push (push) Waiting to run
Validation / Typecheck (push) Waiting to run
Validation / Style (push) Waiting to run
Validation / Test macos-latest (push) Blocked by required conditions
Validation / Test ubuntu-latest (push) Blocked by required conditions
Validation / Test windows-latest (push) Blocked by required conditions
Validation / Build (push) Blocked by required conditions
Validation / Required (push) Blocked by required conditions
This commit is contained in:
parent
8d9df830e0
commit
89825e1c4e
1 changed files with 10 additions and 3 deletions
|
|
@ -325,7 +325,7 @@ export function applyClassDecorator(
|
|||
}
|
||||
}
|
||||
|
||||
const applyDataclassTransform = (): void => {
|
||||
const applyDataclassTransform = (): boolean => {
|
||||
// Is this a dataclass decorator?
|
||||
let dataclassBehaviors: DataClassBehaviors | undefined;
|
||||
let callNode: CallNode | undefined;
|
||||
|
|
@ -344,7 +344,10 @@ export function applyClassDecorator(
|
|||
|
||||
if (dataclassBehaviors) {
|
||||
applyDataClassDecorator(evaluator, decoratorNode, originalClassType, dataclassBehaviors, callNode);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
if (isOverloaded(decoratorType)) {
|
||||
|
|
@ -383,14 +386,18 @@ export function applyClassDecorator(
|
|||
return inputClassType;
|
||||
}
|
||||
|
||||
applyDataclassTransform();
|
||||
if (applyDataclassTransform()) {
|
||||
return inputClassType;
|
||||
}
|
||||
} else if (isClassInstance(decoratorType)) {
|
||||
if (ClassType.isBuiltIn(decoratorType, 'deprecated')) {
|
||||
originalClassType.shared.deprecatedMessage = decoratorType.priv.deprecatedInstanceMessage;
|
||||
return inputClassType;
|
||||
}
|
||||
|
||||
applyDataclassTransform();
|
||||
if (applyDataclassTransform()) {
|
||||
return inputClassType;
|
||||
}
|
||||
}
|
||||
|
||||
return getTypeOfDecorator(evaluator, decoratorNode, inputClassType);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue