Skip to content

Commit

Permalink
Code cleanup: Removed unused parameter from getGetterTypeFromProperty…
Browse files Browse the repository at this point in the history
… function. Removed unused skipInferReturnType field.
  • Loading branch information
erictraut committed Jan 3, 2025
1 parent a254b79 commit 97da18a
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/pyright-internal/src/analyzer/properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export function clonePropertyWithSetter(
const typeAnnotation = getTypeAnnotationForParam(errorNode, 1);
if (typeAnnotation) {
// Verify consistency of the type.
const fgetType = evaluator.getGetterTypeFromProperty(classType, /* inferTypeIfNeeded */ false);
const fgetType = evaluator.getGetterTypeFromProperty(classType);
if (fgetType && !isAnyOrUnknown(fgetType)) {
const fsetType = evaluator.getTypeOfAnnotation(typeAnnotation, {
typeVarGetsCurScope: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/pyright-internal/src/analyzer/protocols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ function assignToProtocolInternal(
}
} else {
// Extract the property type from the property class.
let getterType = evaluator.getGetterTypeFromProperty(destMemberType, /* inferTypeIfNeeded */ true);
let getterType = evaluator.getGetterTypeFromProperty(destMemberType);

if (getterType) {
getterType = partiallySpecializeType(getterType, mroClass, evaluator.getTypeClassType());
Expand Down
9 changes: 2 additions & 7 deletions packages/pyright-internal/src/analyzer/typeEvaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,6 @@ interface ValidateArgTypeOptions {

interface EffectiveReturnTypeOptions {
callSiteInfo?: CallSiteEvaluationInfo;
skipInferReturnType?: boolean;
}

interface SignatureTrackerStackEntry {
Expand Down Expand Up @@ -23030,11 +23029,7 @@ export function createTypeEvaluator(
return specializedReturnType;
}

if (!options?.skipInferReturnType) {
return getInferredReturnType(type, options?.callSiteInfo);
}

return UnknownType.create();
return getInferredReturnType(type, options?.callSiteInfo);
}

function _getInferredReturnType(type: FunctionType, callSiteInfo?: CallSiteEvaluationInfo) {
Expand Down Expand Up @@ -23950,7 +23945,7 @@ export function createTypeEvaluator(
return true;
}

function getGetterTypeFromProperty(propertyClass: ClassType, inferTypeIfNeeded: boolean): Type | undefined {
function getGetterTypeFromProperty(propertyClass: ClassType): Type | undefined {
if (!ClassType.isPropertyClass(propertyClass)) {
return undefined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ export interface TypeEvaluator {
errorNode: ExpressionNode,
emitNotIterableError?: boolean
) => TypeResult | undefined;
getGetterTypeFromProperty: (propertyClass: ClassType, inferTypeIfNeeded: boolean) => Type | undefined;
getGetterTypeFromProperty: (propertyClass: ClassType) => Type | undefined;
getTypeOfArg: (arg: Arg, inferenceContext: InferenceContext | undefined) => TypeResult;
convertNodeToArg: (node: ArgumentNode) => ArgWithExpression;
buildTupleTypesList: (entryTypeResults: TypeResult[], stripLiterals: boolean) => TupleTypeArg[];
Expand Down
2 changes: 1 addition & 1 deletion packages/pyright-internal/src/analyzer/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1728,7 +1728,7 @@ export namespace FunctionType {
}

export function createSynthesizedInstance(name: string, additionalFlags = FunctionTypeFlags.None) {
return create(name, '', '', additionalFlags | FunctionTypeFlags.SynthesizedMethod, TypeFlags.Instance);
return create(name, name, '', additionalFlags | FunctionTypeFlags.SynthesizedMethod, TypeFlags.Instance);
}

function create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ export function getTypeDetail(

if (isProperty(functionType) && detail?.boundObjectOrClass && isClassInstance(detail.boundObjectOrClass)) {
const propertyType =
evaluator.getGetterTypeFromProperty(functionType as ClassType, /* inferTypeIfNeeded */ true) ||
UnknownType.create();
evaluator.getGetterTypeFromProperty(functionType as ClassType) || UnknownType.create();
return name + ': ' + evaluator.printType(propertyType) + ' (property)';
}

Expand Down

0 comments on commit 97da18a

Please sign in to comment.