Skip to content

Commit

Permalink
Fixed a bug that resulted in incorrect type evaluation when an async …
Browse files Browse the repository at this point in the history
…function with an inferred return type is decorated with a class or function that uses a ParamSpec (such as `functools.wraps`). This addresses #6080. (#6081)

Co-authored-by: Eric Traut <[email protected]>
  • Loading branch information
erictraut and msfterictraut authored Oct 4, 2023
1 parent 4137f0c commit b7bbbd6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/pyright-internal/src/analyzer/typeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2584,7 +2584,10 @@ export function removeParamSpecVariadicsFromFunction(type: FunctionType): Functi
return type;
}

return FunctionType.cloneRemoveParamSpecVariadics(type, argsParam.type);
return FunctionType.cloneRemoveParamSpecVariadics(
type,
TypeVarType.cloneForParamSpecAccess(argsParam.type, /* access */ undefined)
);
}

function _expandVariadicUnpackedUnion(type: Type) {
Expand Down
4 changes: 4 additions & 0 deletions packages/pyright-internal/src/analyzer/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1848,6 +1848,10 @@ export namespace FunctionType {
newFunction.details.paramSpec = paramSpec;
}

if (type.inferredReturnType) {
newFunction.inferredReturnType = type.inferredReturnType;
}

return newFunction;
}

Expand Down

0 comments on commit b7bbbd6

Please sign in to comment.