@zzzen/pyright-internal 1.2.0-dev.20250406 → 1.2.0-dev.20250413

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/analyzer/binder.js +1 -0
  2. package/dist/analyzer/binder.js.map +1 -1
  3. package/dist/analyzer/checker.js +13 -7
  4. package/dist/analyzer/checker.js.map +1 -1
  5. package/dist/analyzer/codeFlowEngine.js +1 -1
  6. package/dist/analyzer/codeFlowEngine.js.map +1 -1
  7. package/dist/analyzer/constructors.js +2 -2
  8. package/dist/analyzer/constructors.js.map +1 -1
  9. package/dist/analyzer/dataClasses.js +4 -4
  10. package/dist/analyzer/dataClasses.js.map +1 -1
  11. package/dist/analyzer/enums.js +1 -1
  12. package/dist/analyzer/enums.js.map +1 -1
  13. package/dist/analyzer/operations.js +1 -1
  14. package/dist/analyzer/operations.js.map +1 -1
  15. package/dist/analyzer/parseTreeUtils.d.ts +1 -1
  16. package/dist/analyzer/parseTreeUtils.js +18 -3
  17. package/dist/analyzer/parseTreeUtils.js.map +1 -1
  18. package/dist/analyzer/program.js +6 -1
  19. package/dist/analyzer/program.js.map +1 -1
  20. package/dist/analyzer/protocols.js +2 -2
  21. package/dist/analyzer/protocols.js.map +1 -1
  22. package/dist/analyzer/sourceFile.js +1 -0
  23. package/dist/analyzer/sourceFile.js.map +1 -1
  24. package/dist/analyzer/typeEvaluator.js +72 -40
  25. package/dist/analyzer/typeEvaluator.js.map +1 -1
  26. package/dist/analyzer/typeGuards.js +91 -52
  27. package/dist/analyzer/typeGuards.js.map +1 -1
  28. package/dist/analyzer/typeUtils.js +2 -2
  29. package/dist/analyzer/typeUtils.js.map +1 -1
  30. package/dist/analyzer/types.d.ts +1 -0
  31. package/dist/analyzer/types.js +4 -0
  32. package/dist/analyzer/types.js.map +1 -1
  33. package/dist/common/extensibility.d.ts +1 -0
  34. package/dist/common/extensibility.js.map +1 -1
  35. package/dist/languageService/completionProvider.js +1 -1
  36. package/dist/languageService/completionProvider.js.map +1 -1
  37. package/dist/languageService/completionProviderUtils.js +1 -1
  38. package/dist/languageService/completionProviderUtils.js.map +1 -1
  39. package/dist/languageService/hoverProvider.js +1 -1
  40. package/dist/languageService/hoverProvider.js.map +1 -1
  41. package/dist/languageService/tooltipUtils.js +2 -2
  42. package/dist/languageService/tooltipUtils.js.map +1 -1
  43. package/dist/localization/localize.d.ts +1 -0
  44. package/dist/localization/localize.js +1 -0
  45. package/dist/localization/localize.js.map +1 -1
  46. package/dist/localization/package.nls.cs.json +1 -0
  47. package/dist/localization/package.nls.de.json +1 -0
  48. package/dist/localization/package.nls.en-us.json +4 -0
  49. package/dist/localization/package.nls.es.json +1 -0
  50. package/dist/localization/package.nls.fr.json +1 -0
  51. package/dist/localization/package.nls.it.json +1 -0
  52. package/dist/localization/package.nls.ja.json +1 -0
  53. package/dist/localization/package.nls.ko.json +1 -0
  54. package/dist/localization/package.nls.pl.json +1 -0
  55. package/dist/localization/package.nls.pt-br.json +1 -0
  56. package/dist/localization/package.nls.qps-ploc.json +1 -0
  57. package/dist/localization/package.nls.ru.json +1 -0
  58. package/dist/localization/package.nls.tr.json +1 -0
  59. package/dist/localization/package.nls.zh-cn.json +1 -0
  60. package/dist/localization/package.nls.zh-tw.json +1 -0
  61. package/dist/parser/parser.d.ts +2 -0
  62. package/dist/parser/parser.js +4 -0
  63. package/dist/parser/parser.js.map +1 -1
  64. package/dist/tests/checker.test.js +1 -1
  65. package/dist/tests/typeEvaluator2.test.js +2 -2
  66. package/dist/tests/typeEvaluator7.test.js +1 -1
  67. package/dist/tests/typeEvaluator7.test.js.map +1 -1
  68. package/dist/tests/typeEvaluator8.test.js +6 -2
  69. package/dist/tests/typeEvaluator8.test.js.map +1 -1
  70. package/package.json +1 -1
@@ -851,9 +851,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
851
851
  /* useCoroutine */ false)
852
852
  : undefined;
853
853
  const exprTypeResult = getTypeOfExpression(node.d.expr, flags, (0, typeUtils_1.makeInferenceContext)(expectedType));
854
+ const awaitableResult = getTypeOfAwaitable(exprTypeResult, node.d.expr);
854
855
  const typeResult = {
855
- type: getTypeOfAwaitable(exprTypeResult.type, node.d.expr),
856
- isIncomplete: exprTypeResult.isIncomplete,
856
+ type: awaitableResult.type,
857
+ isIncomplete: exprTypeResult.isIncomplete || awaitableResult.isIncomplete,
857
858
  typeErrors: exprTypeResult.typeErrors,
858
859
  };
859
860
  if (exprTypeResult.isIncomplete) {
@@ -1576,7 +1577,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
1576
1577
  if (!boundMethodResult || boundMethodResult.typeErrors) {
1577
1578
  return undefined;
1578
1579
  }
1579
- if ((0, types_1.isFunction)(boundMethodResult.type) || (0, types_1.isOverloaded)(boundMethodResult.type)) {
1580
+ if ((0, types_1.isFunctionOrOverloaded)(boundMethodResult.type)) {
1580
1581
  return boundMethodResult.type;
1581
1582
  }
1582
1583
  if ((0, types_1.isClassInstance)(boundMethodResult.type)) {
@@ -1671,7 +1672,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
1671
1672
  const constructorType = (0, constructors_1.createFunctionFromConstructor)(evaluatorInterface, subtype);
1672
1673
  if (constructorType) {
1673
1674
  (0, typeUtils_1.doForEachSubtype)(constructorType, (subtype) => {
1674
- if ((0, types_1.isFunction)(subtype) || (0, types_1.isOverloaded)(subtype)) {
1675
+ if ((0, types_1.isFunctionOrOverloaded)(subtype)) {
1675
1676
  addFunctionToSignature(subtype);
1676
1677
  }
1677
1678
  });
@@ -1867,7 +1868,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
1867
1868
  if (memberAccessClass && (0, types_1.isInstantiableClass)(memberAccessClass)) {
1868
1869
  declaredType = (0, typeUtils_1.partiallySpecializeType)(declaredType, memberAccessClass, getTypeClassType(), selfType);
1869
1870
  }
1870
- if ((0, types_1.isFunction)(declaredType) || (0, types_1.isOverloaded)(declaredType)) {
1871
+ if ((0, types_1.isFunctionOrOverloaded)(declaredType)) {
1871
1872
  if (bindFunction) {
1872
1873
  declaredType = bindFunctionToClassOrObject(classOrObjectBase, declaredType,
1873
1874
  /* memberClass */ undefined,
@@ -1884,14 +1885,15 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
1884
1885
  // the result. According to PEP 492, await operates on an Awaitable
1885
1886
  // (object that provides an __await__ that returns a generator object).
1886
1887
  // If errorNode is undefined, no errors are reported.
1887
- function getTypeOfAwaitable(type, errorNode) {
1888
+ function getTypeOfAwaitable(typeResult, errorNode) {
1888
1889
  if (!prefetched?.awaitableClass ||
1889
1890
  !(0, types_1.isInstantiableClass)(prefetched.awaitableClass) ||
1890
1891
  prefetched.awaitableClass.shared.typeParams.length !== 1) {
1891
- return types_1.UnknownType.create();
1892
+ return { type: types_1.UnknownType.create(), isIncomplete: typeResult.isIncomplete };
1892
1893
  }
1893
1894
  const awaitableProtocolObj = types_1.ClassType.cloneAsInstance(prefetched.awaitableClass);
1894
- return (0, typeUtils_1.mapSubtypes)(type, (subtype) => {
1895
+ const isIncomplete = !!typeResult.isIncomplete;
1896
+ const type = (0, typeUtils_1.mapSubtypes)(typeResult.type, (subtype) => {
1895
1897
  subtype = makeTopLevelTypeVarsConcrete(subtype);
1896
1898
  if ((0, types_1.isAnyOrUnknown)(subtype)) {
1897
1899
  return subtype;
@@ -1909,11 +1911,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
1909
1911
  return types_1.UnknownType.create();
1910
1912
  }
1911
1913
  }
1912
- if (errorNode) {
1914
+ if (errorNode && !typeResult.isIncomplete) {
1913
1915
  addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typeNotAwaitable().format({ type: printType(subtype) }) + diag?.getString(), errorNode);
1914
1916
  }
1915
1917
  return types_1.UnknownType.create();
1916
1918
  });
1919
+ return { type, isIncomplete };
1917
1920
  }
1918
1921
  // Validates that the type is an iterator and returns the iterated type
1919
1922
  // (i.e. the type returned from the '__next__' or '__anext__' method).
@@ -1921,6 +1924,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
1921
1924
  const iterMethodName = isAsync ? '__aiter__' : '__iter__';
1922
1925
  const nextMethodName = isAsync ? '__anext__' : '__next__';
1923
1926
  let isValidIterator = true;
1927
+ let isIncomplete = typeResult.isIncomplete;
1924
1928
  let type = (0, typeUtils_1.transformPossibleRecursiveTypeAlias)(typeResult.type);
1925
1929
  type = makeTopLevelTypeVarsConcrete(type);
1926
1930
  type = (0, types_1.removeUnbound)(type);
@@ -1989,7 +1993,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
1989
1993
  }
1990
1994
  // If it's an async iteration, there's an implicit
1991
1995
  // 'await' operator applied.
1992
- return getTypeOfAwaitable(nextReturnType, errorNode);
1996
+ const awaitableResult = getTypeOfAwaitable({ type: nextReturnType, isIncomplete: typeResult.isIncomplete }, errorNode);
1997
+ if (awaitableResult.isIncomplete) {
1998
+ isIncomplete = true;
1999
+ }
2000
+ return awaitableResult.type;
1993
2001
  }
1994
2002
  return undefined;
1995
2003
  });
@@ -1999,13 +2007,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
1999
2007
  diag.addAddendum(iterReturnTypeDiag);
2000
2008
  }
2001
2009
  }
2002
- if (!typeResult.isIncomplete && emitNotIterableError) {
2010
+ if (!isIncomplete && emitNotIterableError) {
2003
2011
  addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typeNotIterable().format({ type: printType(subtype) }) + diag.getString(), errorNode);
2004
2012
  }
2005
2013
  isValidIterator = false;
2006
2014
  return undefined;
2007
2015
  });
2008
- return isValidIterator ? { type: iterableType, isIncomplete: typeResult.isIncomplete } : undefined;
2016
+ return isValidIterator ? { type: iterableType, isIncomplete } : undefined;
2009
2017
  }
2010
2018
  // Validates that the type is an iterable and returns the iterable type argument.
2011
2019
  function getTypeOfIterable(typeResult, isAsync, errorNode, emitNotIterableError = true) {
@@ -4045,8 +4053,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
4045
4053
  // If type is undefined, emit a general error message indicating that the
4046
4054
  // member could not be accessed.
4047
4055
  if (!type) {
4048
- const isFunctionRule = (0, types_1.isFunction)(baseType) ||
4049
- (0, types_1.isOverloaded)(baseType) ||
4056
+ const isFunctionRule = (0, types_1.isFunctionOrOverloaded)(baseType) ||
4050
4057
  ((0, types_1.isClassInstance)(baseType) && types_1.ClassType.isBuiltIn(baseType, 'function'));
4051
4058
  if (!baseTypeResult.isIncomplete) {
4052
4059
  let diagMessage = localize_1.LocMessage.memberAccess();
@@ -4240,7 +4247,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
4240
4247
  }
4241
4248
  resultType = descResult.type;
4242
4249
  }
4243
- else if ((0, types_1.isFunction)(concreteSubtype) || (0, types_1.isOverloaded)(concreteSubtype)) {
4250
+ else if ((0, types_1.isFunctionOrOverloaded)(concreteSubtype) && types_1.TypeBase.isInstance(concreteSubtype)) {
4244
4251
  const typeResult = bindMethodForMemberAccess(subtype, concreteSubtype, memberInfo, classType, selfType, flags, memberName, usage, diag, recursionCount);
4245
4252
  resultType = typeResult.type;
4246
4253
  if (typeResult.typeErrors) {
@@ -4369,7 +4376,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
4369
4376
  }
4370
4377
  return { type: types_1.UnknownType.create(), typeErrors: true };
4371
4378
  }
4372
- if (!(0, types_1.isFunction)(methodType) && !(0, types_1.isOverloaded)(methodType)) {
4379
+ if (!(0, types_1.isFunctionOrOverloaded)(methodType)) {
4373
4380
  if ((0, types_1.isAnyOrUnknown)(methodType)) {
4374
4381
  return { type: methodType };
4375
4382
  }
@@ -4413,7 +4420,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
4413
4420
  /* diag */ undefined, constraints);
4414
4421
  accessMethodClass = solveAndApplyConstraints(accessMethodClass, constraints);
4415
4422
  const specializedType = (0, typeUtils_1.partiallySpecializeType)(methodType, accessMethodClass, getTypeClassType(), selfType ? (0, typeUtils_1.convertToInstantiable)(selfType) : classType);
4416
- if ((0, types_1.isFunction)(specializedType) || (0, types_1.isOverloaded)(specializedType)) {
4423
+ if ((0, types_1.isFunctionOrOverloaded)(specializedType)) {
4417
4424
  methodType = specializedType;
4418
4425
  }
4419
4426
  }
@@ -4673,7 +4680,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
4673
4680
  },
4674
4681
  });
4675
4682
  }
4676
- if (!(0, types_1.isFunction)(accessMemberType) && !(0, types_1.isOverloaded)(accessMemberType)) {
4683
+ if (!(0, types_1.isFunctionOrOverloaded)(accessMemberType)) {
4677
4684
  if ((0, types_1.isAnyOrUnknown)(accessMemberType)) {
4678
4685
  return { type: accessMemberType };
4679
4686
  }
@@ -8493,7 +8500,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
8493
8500
  // If the function is returning a callable, don't eliminate unsolved
8494
8501
  // type vars within a union. There are legit uses for unsolved type vars
8495
8502
  // within a callable.
8496
- if ((0, types_1.isFunction)(returnType) || (0, types_1.isOverloaded)(returnType)) {
8503
+ if ((0, types_1.isFunctionOrOverloaded)(returnType)) {
8497
8504
  eliminateUnsolvedInUnions = false;
8498
8505
  }
8499
8506
  let specializedReturnType = solveAndApplyConstraints(returnType, constraints, {
@@ -13475,7 +13482,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
13475
13482
  }
13476
13483
  else {
13477
13484
  let skipInference = false;
13478
- if ((0, types_1.isFunction)(defaultValueType) || (0, types_1.isOverloaded)(defaultValueType)) {
13485
+ if ((0, types_1.isFunctionOrOverloaded)(defaultValueType)) {
13479
13486
  // Do not infer parameter types that use a lambda or another function as a
13480
13487
  // default value. We're likely to generate false positives in this case.
13481
13488
  // It's not clear whether parameters should be positional-only or not.
@@ -13886,6 +13893,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
13886
13893
  return;
13887
13894
  }
13888
13895
  const exprTypeResult = getTypeOfExpression(node.d.expr);
13896
+ let isIncomplete = exprTypeResult.isIncomplete;
13889
13897
  let exprType = exprTypeResult.type;
13890
13898
  const isAsync = node.parent && node.parent.nodeType === 58 /* ParseNodeType.With */ && !!node.parent.d.isAsync;
13891
13899
  if ((0, typeUtils_1.isOptionalType)(exprType)) {
@@ -13904,7 +13912,17 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
13904
13912
  const enterTypeResult = getTypeOfMagicMethodCall(subtype, enterMethodName, [], node.d.expr,
13905
13913
  /* inferenceContext */ undefined, enterDiag.createAddendum());
13906
13914
  if (enterTypeResult) {
13907
- return isAsync ? getTypeOfAwaitable(enterTypeResult.type, node.d.expr) : enterTypeResult.type;
13915
+ if (isAsync) {
13916
+ if (enterTypeResult.isIncomplete) {
13917
+ isIncomplete = true;
13918
+ }
13919
+ const asyncResult = getTypeOfAwaitable({ type: enterTypeResult.type }, node.d.expr);
13920
+ if (asyncResult.isIncomplete) {
13921
+ isIncomplete = true;
13922
+ }
13923
+ return asyncResult.type;
13924
+ }
13925
+ return enterTypeResult.type;
13908
13926
  }
13909
13927
  if (!isAsync) {
13910
13928
  if (getTypeOfMagicMethodCall(subtype, '__aenter__', [], node.d.expr,
@@ -13930,7 +13948,17 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
13930
13948
  const exitTypeResult = getTypeOfMagicMethodCall(subtype, exitMethodName, [anyArg, anyArg, anyArg], node.d.expr,
13931
13949
  /* inferenceContext */ undefined, exitDiag);
13932
13950
  if (exitTypeResult) {
13933
- return isAsync ? getTypeOfAwaitable(exitTypeResult.type, node.d.expr) : exitTypeResult.type;
13951
+ if (exitTypeResult.isIncomplete) {
13952
+ isIncomplete = true;
13953
+ }
13954
+ if (isAsync) {
13955
+ const asyncResult = getTypeOfAwaitable({ type: exitTypeResult.type }, node.d.expr);
13956
+ if (asyncResult.isIncomplete) {
13957
+ isIncomplete = true;
13958
+ }
13959
+ return asyncResult.type;
13960
+ }
13961
+ return exitTypeResult.type;
13934
13962
  }
13935
13963
  }
13936
13964
  addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typeNotUsableWith().format({ type: printType(subtype), method: exitMethodName }) +
@@ -13938,9 +13966,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
13938
13966
  return types_1.UnknownType.create();
13939
13967
  });
13940
13968
  if (node.d.target) {
13941
- assignTypeToExpression(node.d.target, { type: scopedType, isIncomplete: exprTypeResult.isIncomplete }, node.d.target);
13969
+ assignTypeToExpression(node.d.target, { type: scopedType, isIncomplete }, node.d.target);
13942
13970
  }
13943
- writeTypeCache(node, { type: scopedType, isIncomplete: !!exprTypeResult.isIncomplete }, 0 /* EvalFlags.None */);
13971
+ writeTypeCache(node, { type: scopedType, isIncomplete }, 0 /* EvalFlags.None */);
13944
13972
  }
13945
13973
  function evaluateTypesForImportAs(node) {
13946
13974
  if (isTypeCached(node)) {
@@ -14862,7 +14890,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
14862
14890
  if (types_1.ClassType.isBuiltIn(classType, 'type') && typeArgs) {
14863
14891
  if (typeArgs.length >= 1) {
14864
14892
  // Treat type[function] as illegal.
14865
- if ((0, types_1.isFunction)(typeArgs[0].type) || (0, types_1.isOverloaded)(typeArgs[0].type)) {
14893
+ if ((0, types_1.isFunctionOrOverloaded)(typeArgs[0].type)) {
14866
14894
  addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeForm, localize_1.LocMessage.typeAnnotationWithCallable(), typeArgs[0].node);
14867
14895
  return { type: types_1.UnknownType.create() };
14868
14896
  }
@@ -15414,7 +15442,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
15414
15442
  if (!tracker) {
15415
15443
  return type;
15416
15444
  }
15417
- if ((0, types_1.isFunction)(type) || (0, types_1.isOverloaded)(type)) {
15445
+ if ((0, types_1.isFunctionOrOverloaded)(type)) {
15418
15446
  return (0, typeUtils_1.ensureSignaturesAreUnique)(type, tracker, node.start);
15419
15447
  }
15420
15448
  return type;
@@ -16924,13 +16952,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
16924
16952
  if (errorNode &&
16925
16953
  selfClass &&
16926
16954
  (0, types_1.isClass)(selfClass) &&
16955
+ !selfClass.priv.includeSubclasses &&
16927
16956
  member.isInstanceMember &&
16928
16957
  (0, types_1.isClass)(member.unspecializedClassType) &&
16929
16958
  (flags & 1024 /* MemberAccessFlags.DisallowGenericInstanceVariableAccess */) !== 0 &&
16930
16959
  (0, typeUtils_1.requiresSpecialization)(typeResult.type, { ignoreSelf: true, ignoreImplicitTypeArgs: true })) {
16931
16960
  const specializedType = (0, typeUtils_1.partiallySpecializeType)(typeResult.type, member.unspecializedClassType, getTypeClassType(), (0, typeUtils_1.selfSpecializeClass)(selfClass, { overrideTypeArgs: true }));
16932
- if ((0, types_1.findSubtype)(specializedType, (subtype) => !(0, types_1.isFunction)(subtype) &&
16933
- !(0, types_1.isOverloaded)(subtype) &&
16961
+ if ((0, types_1.findSubtype)(specializedType, (subtype) => !(0, types_1.isFunctionOrOverloaded)(subtype) &&
16934
16962
  (0, typeUtils_1.requiresSpecialization)(subtype, { ignoreSelf: true, ignoreImplicitTypeArgs: true }))) {
16935
16963
  addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.genericInstanceVariableAccess(), errorNode);
16936
16964
  }
@@ -17763,7 +17791,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
17763
17791
  }
17764
17792
  return true;
17765
17793
  }
17766
- else if ((0, types_1.isFunction)(concreteSrcType) || (0, types_1.isOverloaded)(concreteSrcType)) {
17794
+ else if ((0, types_1.isFunctionOrOverloaded)(concreteSrcType)) {
17767
17795
  // Is the destination a callback protocol (defined in PEP 544)?
17768
17796
  const destCallbackType = getCallbackProtocolType(destType, recursionCount);
17769
17797
  if (destCallbackType) {
@@ -18075,10 +18103,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
18075
18103
  }
18076
18104
  }
18077
18105
  }
18078
- if ((0, types_1.isFunction)(srcSubtype) || (0, types_1.isOverloaded)(srcSubtype)) {
18079
- if ((0, types_1.isFunction)(destSubtype) || (0, types_1.isOverloaded)(destSubtype)) {
18080
- return true;
18081
- }
18106
+ if ((0, types_1.isFunctionOrOverloaded)(srcSubtype) && (0, types_1.isFunctionOrOverloaded)(destSubtype)) {
18107
+ return true;
18082
18108
  }
18083
18109
  return false;
18084
18110
  });
@@ -18279,10 +18305,16 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
18279
18305
  if ((0, types_1.isModule)(leftType) || (0, types_1.isModule)(rightType)) {
18280
18306
  return (0, types_1.isTypeSame)(leftType, rightType, { ignoreConditions: true });
18281
18307
  }
18282
- const isLeftCallable = (0, types_1.isFunction)(leftType) || (0, types_1.isOverloaded)(leftType);
18283
- const isRightCallable = (0, types_1.isFunction)(rightType) || (0, types_1.isOverloaded)(rightType);
18284
- if (isLeftCallable !== isRightCallable) {
18285
- return false;
18308
+ const isLeftCallable = (0, types_1.isFunctionOrOverloaded)(leftType);
18309
+ const isRightCallable = (0, types_1.isFunctionOrOverloaded)(rightType);
18310
+ // If either type is a function, assume that it may be comparable. The other
18311
+ // operand might be a callable object, an 'object' instance, etc. We could
18312
+ // make this more precise for specific cases (e.g. if the other operand is
18313
+ // None or a literal or an instance of a nominal class that doesn't override
18314
+ // __call__ and is marked final, etc.), but coming up with a comprehensive
18315
+ // list is probably not feasible.
18316
+ if (isLeftCallable || isRightCallable) {
18317
+ return true;
18286
18318
  }
18287
18319
  if ((0, types_1.isInstantiableClass)(leftType) || ((0, types_1.isClassInstance)(leftType) && types_1.ClassType.isBuiltIn(leftType, 'type'))) {
18288
18320
  if ((0, types_1.isInstantiableClass)(rightType) ||
@@ -19273,7 +19305,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
19273
19305
  }
19274
19306
  // We also need to be careful with callback protocols.
19275
19307
  if ((0, types_1.isClassInstance)(declaredSubtype) && types_1.ClassType.isProtocolClass(declaredSubtype)) {
19276
- if ((0, types_1.isFunction)(assignedSubtype) || (0, types_1.isOverloaded)(assignedSubtype)) {
19308
+ if ((0, types_1.isFunctionOrOverloaded)(assignedSubtype)) {
19277
19309
  return assignedSubtype;
19278
19310
  }
19279
19311
  }
@@ -19304,7 +19336,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
19304
19336
  function validateOverrideMethod(baseMethod, overrideMethod, baseClass, diag, enforceParamNames = true) {
19305
19337
  // If we're overriding a non-method with a method, report it as an error.
19306
19338
  // This occurs when a non-property overrides a property.
19307
- if (!(0, types_1.isFunction)(baseMethod) && !(0, types_1.isOverloaded)(baseMethod)) {
19339
+ if (!(0, types_1.isFunctionOrOverloaded)(baseMethod)) {
19308
19340
  diag.addMessage(localize_1.LocAddendum.overrideType().format({ type: printType(baseMethod) }));
19309
19341
  return false;
19310
19342
  }
@@ -19884,7 +19916,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
19884
19916
  // bound to its own __call__ method but the first parameter
19885
19917
  // is annotated with its own callable type. This can lead to
19886
19918
  // infinite recursion.
19887
- if ((0, types_1.isFunction)(memberTypeFirstParamType) || (0, types_1.isOverloaded)(memberTypeFirstParamType)) {
19919
+ if ((0, types_1.isFunctionOrOverloaded)(memberTypeFirstParamType)) {
19888
19920
  if ((0, types_1.isClassInstance)(firstParamType) && types_1.ClassType.isProtocolClass(firstParamType)) {
19889
19921
  if (subDiag) {
19890
19922
  subDiag.addMessage(localize_1.LocMessage.bindTypeMismatch().format({