mirror of
https://github.com/microsoft/pyright.git
synced 2024-10-26 10:55:06 +03:00
Fixed recent regression that results in a false positive error when applying a @property
decorator to a method that has already had a decorator applied to it. This addresses #7667. (#7671)
This commit is contained in:
parent
dd09712579
commit
f2e277aa5c
@ -944,6 +944,7 @@ function assignTypeToParamSpec(
|
||||
newFunction.details.docString = srcType.details.docString;
|
||||
newFunction.details.deprecatedMessage = srcType.details.deprecatedMessage;
|
||||
newFunction.details.paramSpec = srcType.details.paramSpec;
|
||||
newFunction.details.methodClass = srcType.details.methodClass;
|
||||
|
||||
let updateContextWithNewFunction = false;
|
||||
|
||||
|
@ -25433,6 +25433,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, evaluatorOptions
|
||||
remainingFunction.details.typeVarScopeId = effectiveSrcType.details.typeVarScopeId;
|
||||
remainingFunction.details.constructorTypeVarScopeId =
|
||||
effectiveSrcType.details.constructorTypeVarScopeId;
|
||||
remainingFunction.details.methodClass = effectiveSrcType.details.methodClass;
|
||||
remainingParams.forEach((param) => {
|
||||
FunctionType.addParameter(remainingFunction, param);
|
||||
});
|
||||
|
@ -1821,6 +1821,7 @@ export namespace FunctionType {
|
||||
FunctionType.addHigherOrderTypeVarScopeIds(newFunction, paramSpecValue.details.higherOrderTypeVarScopeIds);
|
||||
|
||||
newFunction.details.paramSpec = paramSpecValue.details.paramSpec;
|
||||
newFunction.details.methodClass = paramSpecValue.details.methodClass;
|
||||
}
|
||||
|
||||
return newFunction;
|
||||
|
21
packages/pyright-internal/src/tests/samples/property18.py
Normal file
21
packages/pyright-internal/src/tests/samples/property18.py
Normal file
@ -0,0 +1,21 @@
|
||||
# This sample tests the case where a @property decorator is applied to
|
||||
# a method that has been previously decorated.
|
||||
|
||||
from typing import ParamSpec, TypeVar, Callable
|
||||
|
||||
P = ParamSpec("P")
|
||||
R = TypeVar("R")
|
||||
|
||||
|
||||
def deco1(func: Callable[P, R]) -> Callable[P, R]: ...
|
||||
|
||||
|
||||
class ClassA:
|
||||
@property
|
||||
@deco1
|
||||
def prop(self) -> int:
|
||||
return 1
|
||||
|
||||
|
||||
a = ClassA()
|
||||
reveal_type(a.prop, expected_text="int")
|
@ -1189,6 +1189,12 @@ test('Property17', () => {
|
||||
TestUtils.validateResults(analysisResults, 0);
|
||||
});
|
||||
|
||||
test('Property18', () => {
|
||||
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['property18.py']);
|
||||
|
||||
TestUtils.validateResults(analysisResults, 0);
|
||||
});
|
||||
|
||||
test('Operator1', () => {
|
||||
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['operator1.py']);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user