Skip to content

Apply overload materialization to nested Any - #11601

Merged
Rich Chiodo (rchiodo) merged 7 commits into
mainfrom
rchiodo-fix-overload-materialization
Aug 10, 2026
Merged

Rich Chiodo (rchiodo) merged 7 commits into
mainfrom
rchiodo-fix-overload-materialization

Conversation

@rchiodo

@rchiodo Rich Chiodo (rchiodo) commented Aug 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • apply overload Step 5 when Any or Unknown appears in an invariant nominal type argument
  • keep all compatible overloads until materialization filtering determines which later overloads can be eliminated
  • propagate ambiguous inferred __init__ self types while preserving explicitly specialized constructor results
  • add the overloads_evaluation.py conformance regression and realistic primer-derived coverage

Why

Overload matching previously marked only a top-level Any or Unknown argument as non-definitive. An argument such as list[Any] was therefore treated as a definitive match for the first compatible overload, so overloads for list[int] and list[str] incorrectly selected list[int].

The overload specification requires materialization filtering in this case. The updated logic detects nested gradual forms in invariant nominal positions, evaluates whether a candidate accepts every supported materialization, and eliminates only subsequent overloads. If multiple candidates with non-equivalent results remain, nested Any produces Any and nested Unknown produces Unknown.

Precision boundaries

The proof is intentionally limited to nominal generic relationships, including covariant base adaptation through the MRO. Unsupported proofs involving structural protocols, callable signatures, unions, contravariant generic arguments, or TypeVar-dependent relationships retain the existing overload-selection behavior rather than making an unsound elimination.

Normal assignability cannot answer the Step 5 question because it checks one gradual source type and accepts Any or Unknown without proving that every materialization is covered. The dedicated traversal is therefore conservative and tri-state: true means all materializations are covered, false identifies a counterexample, and an unproven shape preserves legacy overload ordering.

For overloaded constructors, the effective specialized self types participate in ambiguity handling. Explicit class specialization remains authoritative and is not degraded to Any or Unknown.

Filtering intentionally keeps overloadsUsedForCall aligned with the retained candidates for both the existing top-level gradual path and the new nested-materialization path. Deprecation diagnostics therefore report only overloads that remain possible; an exact diagnostic-range assertion pins this behavior.

The broadened test matrix covers primer-derived Series/Index operators, Prefect-style callable receivers, Home Assistant optional overloads, scipy shape-specialized concatenation, re.Pattern[Any | Unknown], inferred and explicit constructors, multi-argument filtering, and mixed keyword/default calls. It also pins unchanged behavior for covariance, top-level gradual arguments, equivalent returns, concrete/unambiguous calls, defaults and literal context, bounded/constrained TypeVars, unsupported proof shapes, contravariance, deprecation, and invalid calls. Concrete downstream operations and expected errors guard against accidental diagnostic suppression.

Conformance case

For:

@overload
def overloaded(value: list[int]) -> list[int]: ...

@overload
def overloaded(value: list[str]) -> list[str]: ...

def check(value: list[Any]) -> None:
    reveal_type(overloaded(value), expected_text="Any")

both invariant overloads remain possible, so the result is now Any rather than list[int].

Tests

  • npx jest typeEvaluator6.test --runInBand --forceExit (150 tests; all overload and constructor evaluator tests)
  • focused solver, TypedDict, and deprecation Jest selection (116 tests)
  • npm run build in packages/pyright-internal
  • npm run typecheck
  • npm run check:syncpack
  • npm run check:eslint
  • npm run check:prettier
  • git diff --check

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@StellaHuang95

Stella Huang (StellaHuang95) commented Aug 7, 2026 •

Copy link
Copy Markdown
Collaborator

🔒 Automated review in progress — Stella Huang (@StellaHuang95) is auto-reviewing this PR.

@github-actions

This comment has been minimized.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved via Review Center.

@StellaHuang95 Stella Huang (StellaHuang95) added the review-auto:approved Automated review: no blocking findings (approval posted). label Aug 7, 2026
Rich Chiodo (rchiodo) and others added 3 commits August 10, 2026 09:31
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved via Review Center.

@github-actions

This comment has been minimized.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved via Review Center.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved via Review Center.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved via Review Center.

@github-actions

Copy link
Copy Markdown
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

sympy (https://github.com/sympy/sympy)
+ .../projects/sympy/sympy/parsing/latex/lark/latex_parser.py
+   .../projects/sympy/sympy/parsing/latex/lark/latex_parser.py:139:26 - error: No overloads for "join" match the provided arguments (reportCallIssue)
+   .../projects/sympy/sympy/parsing/latex/lark/latex_parser.py:139:36 - error: Argument of type "list[Unknown | str]" cannot be assigned to parameter "iterable" of type "Iterable[LiteralString]" in function "join" (reportArgumentType)
-   .../projects/sympy/sympy/simplify/tests/test_hyperexpand.py:545:30 - error: Cannot access attribute "n" for class "Basic"
-     Attribute "n" is unknown (reportAttributeAccessIssue)
-   .../projects/sympy/sympy/simplify/tests/test_hyperexpand.py:547:32 - error: Cannot access attribute "n" for class "Basic"
-     Attribute "n" is unknown (reportAttributeAccessIssue)
-   .../projects/sympy/sympy/solvers/bivariate.py:135:15 - error: Operator "-" not supported for "None" (reportOptionalOperand)
-   .../projects/sympy/sympy/solvers/bivariate.py:139:17 - error: Operator "-" not supported for type "Basic | Unknown" (reportOperatorIssue)
-   .../projects/sympy/sympy/solvers/bivariate.py:144:23 - error: Operator "-" not supported for "None" (reportOptionalOperand)
-   .../projects/sympy/sympy/solvers/deutils.py:234:14 - error: Operator "not in" not supported for types "str" and "Unknown | int"
-     Operator "not in" not supported for types "str" and "int" (reportOperatorIssue)
-   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:423:38 - error: Argument of type "Unknown | Expr | Literal[0]" cannot be assigned to parameter "expr" of type "Expr" in function "make_args"
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:423:38 - error: Argument of type "int | Expr" cannot be assigned to parameter "expr" of type "Expr" in function "make_args"
-     Type "Unknown | Expr | Literal[0]" is not assignable to type "Expr"
+     Type "int | Expr" is not assignable to type "Expr"
-       "Literal[0]" is not assignable to "Expr" (reportArgumentType)
+       "int" is not assignable to "Expr" (reportArgumentType)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:504:19 - error: Operator "**" not supported for types "Unknown | Basic" and "Literal[2]"
+     Operator "**" not supported for types "Basic" and "Literal[2]" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:505:19 - error: Operator "*" not supported for types "Unknown | Basic" and "Unknown | Basic"
+     Operator "*" not supported for types "Basic" and "Basic" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:506:19 - error: Operator "**" not supported for types "Unknown | Basic" and "Literal[2]"
+     Operator "**" not supported for types "Basic" and "Literal[2]" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:569:42 - error: Operator "*" not supported for types "int" and "Unknown | Basic"
+     Operator "*" not supported for types "int" and "Basic" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:569:50 - error: Operator "*" not supported for types "Expr" and "Unknown | Basic"
+     Operator "*" not supported for types "Expr" and "Basic" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:725:42 - error: Operator "**" not supported for types "Unknown | Basic" and "Literal[2]"
+     Operator "**" not supported for types "Basic" and "Literal[2]" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:735:19 - error: Operator "**" not supported for types "Unknown | Basic" and "Literal[2]"
+     Operator "**" not supported for types "Basic" and "Literal[2]" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:736:19 - error: Operator "**" not supported for types "Unknown | Basic" and "Literal[2]"
+     Operator "**" not supported for types "Basic" and "Literal[2]" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:737:19 - error: Operator "**" not supported for types "Unknown | Basic" and "Literal[2]"
+     Operator "**" not supported for types "Basic" and "Literal[2]" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:814:47 - error: Operator "**" not supported for types "Unknown | Basic" and "Literal[2]"
+     Operator "**" not supported for types "Basic" and "Literal[2]" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:841:26 - error: Operator "**" not supported for types "Unknown | Basic" and "Literal[2]"
+     Operator "**" not supported for types "Basic" and "Literal[2]" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:842:22 - error: Operator "*" not supported for types "Unknown | Basic" and "Unknown | Basic"
+     Operator "*" not supported for types "Basic" and "Basic" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:843:36 - error: Operator "*" not supported for types "int" and "Unknown | Basic"
+     Operator "*" not supported for types "int" and "Basic" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:843:42 - error: Operator "*" not supported for types "Unknown | Basic" and "Unknown | Basic"
+     Operator "*" not supported for types "Basic" and "Basic" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:843:51 - error: Operator "*" not supported for types "int" and "Unknown | Basic"
+     Operator "*" not supported for types "int" and "Basic" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:843:57 - error: Operator "*" not supported for types "Unknown | Basic" and "Unknown | Basic"
+     Operator "*" not supported for types "Basic" and "Basic" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:843:66 - error: Operator "*" not supported for types "Unknown | Basic" and "Unknown | Basic"
+     Operator "*" not supported for types "Basic" and "Basic" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:845:53 - error: Operator "*" not supported for types "Unknown | Basic" and "Unknown | Basic"
+     Operator "*" not supported for types "Basic" and "Basic" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:854:18 - error: Operator "**" not supported for types "Unknown | Basic" and "Literal[2]"
+     Operator "**" not supported for types "Basic" and "Literal[2]" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:856:22 - error: Operator "**" not supported for types "Unknown | Basic" and "Literal[2]"
+     Operator "**" not supported for types "Basic" and "Literal[2]" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:865:22 - error: Operator "*" not supported for types "Unknown | Basic" and "Unknown | Basic"
+     Operator "*" not supported for types "Basic" and "Basic" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:865:36 - error: Operator "*" not supported for types "Unknown | Basic" and "Unknown | Basic"
+     Operator "*" not supported for types "Basic" and "Basic" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:867:27 - error: Operator "**" not supported for types "Unknown | Basic" and "Literal[2]"
+     Operator "**" not supported for types "Basic" and "Literal[2]" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:868:27 - error: Operator "*" not supported for types "Unknown | Basic" and "Unknown | Basic"
+     Operator "*" not supported for types "Basic" and "Basic" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:869:27 - error: Operator "*" not supported for types "Unknown | Basic" and "Unknown | Basic"
+     Operator "*" not supported for types "Basic" and "Basic" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:870:27 - error: Operator "**" not supported for types "Unknown | Basic" and "Literal[2]"
+     Operator "**" not supported for types "Basic" and "Literal[2]" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:871:27 - error: Operator "*" not supported for types "Unknown | Basic" and "Unknown | Basic"
+     Operator "*" not supported for types "Basic" and "Basic" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:872:27 - error: Operator "**" not supported for types "Unknown | Basic" and "Literal[2]"
+     Operator "**" not supported for types "Basic" and "Literal[2]" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:876:24 - error: Operator "**" not supported for types "Unknown | Basic" and "Literal[2]"
+     Operator "**" not supported for types "Basic" and "Literal[2]" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:877:24 - error: Operator "**" not supported for types "Unknown | Basic" and "Literal[2]"
+     Operator "**" not supported for types "Basic" and "Literal[2]" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:878:24 - error: Operator "**" not supported for types "Unknown | Basic" and "Literal[2]"
+     Operator "**" not supported for types "Basic" and "Literal[2]" (reportOperatorIssue)
+   .../projects/sympy/sympy/solvers/diophantine/diophantine.py:879:24 - error: Operator "*" not supported for types "Unknown | Basic" and "Unknown | Basic"
+     Operator "*" not supported for types "Basic" and "Basic" (reportOperatorIssue)

... (truncated 1267 lines) ...

scikit-learn (https://github.com/scikit-learn/scikit-learn)
-   .../projects/scikit-learn/sklearn/preprocessing/tests/test_polynomial.py:649:21 - error: Argument of type "Array2D[float64] | Array2D[Unknown] | Any | Unknown | csr_array[float64, tuple[int, int]] | csr_array[Unknown, tuple[int, int]] | SparseABC | <subclass of SparseABC and spmatrix[Any]> | <subclass of csr_array[float64, tuple[int, int]] and spmatrix[Any]> | <subclass of csr_array[Unknown, tuple[int, int]] and spmatrix[Any]>" cannot be assigned to parameter "actual" of type "_NumericArrayLike" in function "assert_allclose"
+   .../projects/scikit-learn/sklearn/preprocessing/tests/test_polynomial.py:649:21 - error: Argument of type "Array2D[float64] | Any | Unknown | csr_array[float64, tuple[int, int]] | SparseABC | <subclass of SparseABC and spmatrix[Any]> | <subclass of csr_array[float64, tuple[int, int]] and spmatrix[Any]>" cannot be assigned to parameter "actual" of type "_NumericArrayLike" in function "assert_allclose"
-     Type "Array2D[float64] | Array2D[Unknown] | Any | Unknown | csr_array[float64, tuple[int, int]] | csr_array[Unknown, tuple[int, int]] | SparseABC | <subclass of SparseABC and spmatrix[Any]> | <subclass of csr_array[float64, tuple[int, int]] and spmatrix[Any]> | <subclass of csr_array[Unknown, tuple[int, int]] and spmatrix[Any]>" is not assignable to type "_NumericArrayLike"
+     Type "Array2D[float64] | Any | Unknown | csr_array[float64, tuple[int, int]] | SparseABC | <subclass of SparseABC and spmatrix[Any]> | <subclass of csr_array[float64, tuple[int, int]] and spmatrix[Any]>" is not assignable to type "_NumericArrayLike"
-   .../projects/scikit-learn/sklearn/preprocessing/tests/test_polynomial.py:720:21 - error: Argument of type "Array2D[float64] | Array2D[Unknown] | Any | Unknown | csr_array[float64, tuple[int, int]] | csr_array[Unknown, tuple[int, int]] | SparseABC | <subclass of SparseABC and spmatrix[Any]> | <subclass of csr_array[float64, tuple[int, int]] and spmatrix[Any]> | <subclass of csr_array[Unknown, tuple[int, int]] and spmatrix[Any]>" cannot be assigned to parameter "actual" of type "_NumericArrayLike" in function "assert_allclose"
+   .../projects/scikit-learn/sklearn/preprocessing/tests/test_polynomial.py:720:21 - error: Argument of type "Array2D[float64] | Any | Unknown | csr_array[float64, tuple[int, int]] | SparseABC | <subclass of SparseABC and spmatrix[Any]> | <subclass of csr_array[float64, tuple[int, int]] and spmatrix[Any]>" cannot be assigned to parameter "actual" of type "_NumericArrayLike" in function "assert_allclose"
-     Type "Array2D[float64] | Array2D[Unknown] | Any | Unknown | csr_array[float64, tuple[int, int]] | csr_array[Unknown, tuple[int, int]] | SparseABC | <subclass of SparseABC and spmatrix[Any]> | <subclass of csr_array[float64, tuple[int, int]] and spmatrix[Any]> | <subclass of csr_array[Unknown, tuple[int, int]] and spmatrix[Any]>" is not assignable to type "_NumericArrayLike"
+     Type "Array2D[float64] | Any | Unknown | csr_array[float64, tuple[int, int]] | SparseABC | <subclass of SparseABC and spmatrix[Any]> | <subclass of csr_array[float64, tuple[int, int]] and spmatrix[Any]>" is not assignable to type "_NumericArrayLike"
-   .../projects/scikit-learn/sklearn/preprocessing/tests/test_polynomial.py:1370:63 - error: Argument of type "csr_array[float64, tuple[int, int]] | csr_array[Unknown, tuple[int, int]] | Any | Unknown | SparseABC | <subclass of SparseABC and spmatrix[Any]> | <subclass of csr_array[float64, tuple[int, int]] and spmatrix[Any]> | <subclass of csr_array[Unknown, tuple[int, int]] and spmatrix[Any]>" cannot be assigned to parameter "desired" of type "_NumericArrayLike" in function "assert_allclose"
+   .../projects/scikit-learn/sklearn/preprocessing/tests/test_polynomial.py:1370:63 - error: Argument of type "csr_array[float64, tuple[int, int]] | Any | Unknown | SparseABC | <subclass of SparseABC and spmatrix[Any]> | <subclass of csr_array[float64, tuple[int, int]] and spmatrix[Any]>" cannot be assigned to parameter "desired" of type "_NumericArrayLike" in function "assert_allclose"
-     Type "csr_array[float64, tuple[int, int]] | csr_array[Unknown, tuple[int, int]] | Any | Unknown | SparseABC | <subclass of SparseABC and spmatrix[Any]> | <subclass of csr_array[float64, tuple[int, int]] and spmatrix[Any]> | <subclass of csr_array[Unknown, tuple[int, int]] and spmatrix[Any]>" is not assignable to type "_NumericArrayLike"
+     Type "csr_array[float64, tuple[int, int]] | Any | Unknown | SparseABC | <subclass of SparseABC and spmatrix[Any]> | <subclass of csr_array[float64, tuple[int, int]] and spmatrix[Any]>" is not assignable to type "_NumericArrayLike"

prefect (https://github.com/PrefectHQ/prefect)
-   .../projects/prefect/src/integrations/prefect-azure/tests/test_credentials.py:39:19 - error: Cannot access attribute "container_name" for class "None"
-     Attribute "container_name" is unknown (reportAttributeAccessIssue)
-   .../projects/prefect/src/integrations/prefect-azure/tests/test_credentials.py:52:19 - error: Cannot access attribute "container_name" for class "None"
-     Attribute "container_name" is unknown (reportAttributeAccessIssue)
-   .../projects/prefect/src/integrations/prefect-azure/tests/test_credentials.py:53:19 - error: Cannot access attribute "blob_name" for class "None"
-     Attribute "blob_name" is unknown (reportAttributeAccessIssue)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_cache.py:1460:16 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_cache.py:1462:16 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:479:28 - error: Cannot access attribute "keys" for class "None"
-     Attribute "keys" is unknown (reportAttributeAccessIssue)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:480:40 - error: Cannot access attribute "items" for class "None"
-     Attribute "items" is unknown (reportAttributeAccessIssue)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:501:13 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:502:13 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:505:13 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:506:13 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:508:24 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:528:28 - error: Cannot access attribute "keys" for class "None"
-     Attribute "keys" is unknown (reportAttributeAccessIssue)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:529:31 - error: Cannot access attribute "values" for class "None"
-     Attribute "values" is unknown (reportAttributeAccessIssue)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:562:16 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:563:16 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:565:16 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:566:16 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:567:16 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:584:40 - error: Cannot access attribute "items" for class "None"
-     Attribute "items" is unknown (reportAttributeAccessIssue)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:607:16 - error: Operator "not in" not supported for types "Literal['model.test_project.int_orders_enriched']" and "None" (reportOperatorIssue)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:626:40 - error: Cannot access attribute "items" for class "None"
-     Attribute "items" is unknown (reportAttributeAccessIssue)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:663:28 - error: Cannot access attribute "keys" for class "None"
-     Attribute "keys" is unknown (reportAttributeAccessIssue)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:664:40 - error: Cannot access attribute "items" for class "None"
-     Attribute "items" is unknown (reportAttributeAccessIssue)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:724:57 - error: Cannot access attribute "values" for class "None"
-     Attribute "values" is unknown (reportAttributeAccessIssue)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:733:56 - error: Cannot access attribute "values" for class "None"
-     Attribute "values" is unknown (reportAttributeAccessIssue)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:764:57 - error: Cannot access attribute "values" for class "None"
-     Attribute "values" is unknown (reportAttributeAccessIssue)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:783:69 - error: Cannot access attribute "values" for class "None"
-     Attribute "values" is unknown (reportAttributeAccessIssue)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:806:57 - error: Cannot access attribute "values" for class "None"
-     Attribute "values" is unknown (reportAttributeAccessIssue)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:813:57 - error: Cannot access attribute "values" for class "None"
-     Attribute "values" is unknown (reportAttributeAccessIssue)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:834:57 - error: Cannot access attribute "values" for class "None"
-     Attribute "values" is unknown (reportAttributeAccessIssue)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:847:56 - error: Cannot access attribute "values" for class "None"
-     Attribute "values" is unknown (reportAttributeAccessIssue)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:867:57 - error: Cannot access attribute "values" for class "None"
-     Attribute "values" is unknown (reportAttributeAccessIssue)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:874:57 - error: Cannot access attribute "values" for class "None"
-     Attribute "values" is unknown (reportAttributeAccessIssue)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:894:57 - error: Cannot access attribute "values" for class "None"
-     Attribute "values" is unknown (reportAttributeAccessIssue)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:903:57 - error: Cannot access attribute "values" for class "None"
-     Attribute "values" is unknown (reportAttributeAccessIssue)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:923:57 - error: Cannot access attribute "values" for class "None"
-     Attribute "values" is unknown (reportAttributeAccessIssue)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:927:57 - error: Cannot access attribute "values" for class "None"
-     Attribute "values" is unknown (reportAttributeAccessIssue)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:935:56 - error: Cannot access attribute "values" for class "None"
-     Attribute "values" is unknown (reportAttributeAccessIssue)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:957:57 - error: Cannot access attribute "values" for class "None"
-     Attribute "values" is unknown (reportAttributeAccessIssue)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:974:69 - error: Cannot access attribute "values" for class "None"
-     Attribute "values" is unknown (reportAttributeAccessIssue)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:1062:33 - error: "None" is not iterable
-     "__iter__" method not defined (reportGeneralTypeIssues)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:1063:32 - error: "None" is not iterable
-     "__iter__" method not defined (reportGeneralTypeIssues)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:1068:20 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:1069:39 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:1088:33 - error: "None" is not iterable
-     "__iter__" method not defined (reportGeneralTypeIssues)
-   .../projects/prefect/src/integrations/prefect-dbt/tests/core/test_orchestrator_integration.py:1089:32 - error: "None" is not iterable

... (truncated 180 lines) ...

core (https://github.com/home-assistant/core)
-   .../projects/core/homeassistant/components/bthome/__init__.py:201:34 - error: Argument of type "set[Never]" cannot be assigned to parameter "discovered_event_classes" of type "set[str]" in function "__init__"
-     "set[Never]" is not assignable to "set[str]"
-       Type parameter "_T@set" is invariant, but "Never" is not the same as "str"
-       Consider switching from "set" to "Container" which is covariant (reportArgumentType)
-   .../projects/core/homeassistant/components/esphome/climate.py:148:14 - error: Cannot assign to attribute "_attr_hvac_modes" for class "EsphomeClimateEntity*"
-     Expression of type "list[HVACMode | None]" cannot be assigned to attribute "_attr_hvac_modes" of class "EsphomeClimateEntity"
-       "list[HVACMode | None]" is not assignable to "list[HVACMode]"
-         Type parameter "_T@list" is invariant, but "HVACMode | None" is not the same as "HVACMode"
-         Consider switching from "list" to "Sequence" which is covariant (reportAttributeAccessIssue)
-   .../projects/core/homeassistant/components/esphome/climate.py:158:14 - error: Cannot assign to attribute "_attr_swing_modes" for class "EsphomeClimateEntity*"
-     Expression of type "list[str | None]" cannot be assigned to attribute "_attr_swing_modes" of class "EsphomeClimateEntity"
-       Type "list[str | None]" is not assignable to type "list[str] | None"
-         "list[str | None]" is not assignable to "list[str]"
-           Type parameter "_T@list" is invariant, but "str | None" is not the same as "str"
-           Consider switching from "list" to "Sequence" which is covariant
-         "list[str | None]" is not assignable to "None" (reportAttributeAccessIssue)
-   .../projects/core/homeassistant/components/esphome/manager.py:1523:27 - error: Argument of type "SupportsResponse | None" cannot be assigned to parameter "supports_response" of type "SupportsResponse" in function "async_register"
-     Type "SupportsResponse | None" is not assignable to type "SupportsResponse"
-       "None" is not assignable to "SupportsResponse" (reportArgumentType)
-   .../projects/core/homeassistant/components/esphome/number.py:56:31 - error: Cannot assign to attribute "_attr_mode" for class "EsphomeNumber*"
-     Type "NumberMode | None" is not assignable to type "NumberMode"
-       "None" is not assignable to "NumberMode" (reportAttributeAccessIssue)
-   .../projects/core/homeassistant/components/esphome/water_heater.py:67:18 - error: Cannot assign to attribute "_attr_operation_list" for class "EsphomeWaterHeater*"
-     Expression of type "list[str | None]" cannot be assigned to attribute "_attr_operation_list" of class "EsphomeWaterHeater"
-       Type "list[str | None]" is not assignable to type "list[str] | None"
-         "list[str | None]" is not assignable to "list[str]"
-           Type parameter "_T@list" is invariant, but "str | None" is not the same as "str"
-           Consider switching from "list" to "Sequence" which is covariant
-         "list[str | None]" is not assignable to "None" (reportAttributeAccessIssue)
- 37989 errors, 77 warnings, 0 informations
+ 37983 errors, 77 warnings, 0 informations

xarray (https://github.com/pydata/xarray)
-     Operator "+" not supported for types "_arrayfunction[Any, Any]" and "Literal[1]" when expected type is "NDArray[Any] | _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]"
+     Operator "+" not supported for types "_arrayfunction[Any, Any]" and "Literal[1]" when expected type is "ndarray[_AnyShape, dtype[Any]] | _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]"
-     Operator "+" not supported for types "_arrayapi[Any, Any]" and "Literal[1]" when expected type is "NDArray[Any] | _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]" (reportOperatorIssue)
+     Operator "+" not supported for types "_arrayapi[Any, Any]" and "Literal[1]" when expected type is "ndarray[_AnyShape, dtype[Any]] | _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]" (reportOperatorIssue)

cloud-init (https://github.com/canonical/cloud-init)
+   .../projects/cloud-init/cloudinit/config/cc_zypper_add_repo.py:47:30 - error: Argument of type "list[str | int]" cannot be assigned to parameter "iterable" of type "Iterable[str]" in function "join"
+     "list[str | int]" is not assignable to "Iterable[str]"
+       Type parameter "_T_co@Iterable" is covariant, but "str | int" is not a subtype of "str"
+         Type "str | int" is not assignable to type "str"
+           "int" is not assignable to "str" (reportArgumentType)
-   .../projects/cloud-init/cloudinit/config/cc_zypper_add_repo.py:47:30 - error: Argument of type "list[str | int]" cannot be assigned to parameter "iterable" of type "Iterable[str]" in function "join" (reportArgumentType)
+   .../projects/cloud-init/cloudinit/config/cc_zypper_add_repo.py:47:30 - error: Argument of type "list[Unknown | str | int]" cannot be assigned to parameter "iterable" of type "Iterable[str]" in function "join" (reportArgumentType)

... (truncated 122 lines) ...```

@rchiodo
Rich Chiodo (rchiodo) merged commit 25641ef into main Aug 10, 2026
20 checks passed

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved via Review Center.

@Dr-Irv

Copy link
Copy Markdown

Given the number of reports of the effects of this change at #11601 (comment) (which seems to be missing tests on pandas-stubs that used to be there??), I am surprised that this was approved and merged. Rich Chiodo (@rchiodo) can you explain?

@rchiodo

Rich Chiodo (rchiodo) commented Sep 10, 2026 •

Copy link
Copy Markdown
Collaborator Author

Given the number of reports of the effects of this change at #11601 (comment) (which seems to be missing tests on pandas-stubs that used to be there??), I am surprised that this was approved and merged. Rich Chiodo (Rich Chiodo (@rchiodo)) can you explain?

Simple. There's no test that prevents the PR from merging. I set it to auto merge. When I fix this regression, I'll add a test to prevent it in the future and see why there's no panda-stubs testing.

@rchiodo

Copy link
Copy Markdown
Collaborator Author

The pandas-stubs output was there in the mypy_primer differences, it was just cut off because there were so many

@rchiodo

Copy link
Copy Markdown
Collaborator Author

So yes it's still being tested.

@Dr-Irv

Copy link
Copy Markdown

So yes it's still being tested.

May I suggest that if that many errors are reported, a new version of pyright is not released? We've had to pin pyright to 1.1.411 in pandas-stubs due to this regression.

At least in the past, Eric Traut (@erictraut) used to let us know when there was a change that was made that would affect pandas-stubs, and then we could address it (and discuss whether what we were doing was considered correct). But in this case, it seems the change was incorrect and hopefully #11732 and other PRs will address that.

Note that we are testing pandas-stubs with mypy, pyright, ty and pyrefly so new errors reported on pandas-stubs via the mypy_primer test in pyright should be considered to most likely be a bug introduced by the PR that includes the change.

Thanks for your consideration and support.

@rchiodo

Copy link
Copy Markdown
Collaborator Author

Note that we are testing pandas-stubs with mypy, pyright, ty and pyrefly so new errors reported on pandas-stubs via the mypy_primer test in pyright should be considered to most likely be a bug introduced by the PR that includes the change.

This would be nice, but it's not always obvious if the mypy_primer differences are expected or not. I'm working on something that will hopefully make this more obvious to the reviewer.

At least in the future, we won't ignore mypy_primer differences (minus sympy, which seems to change on every run)

Rich Chiodo (rchiodo) added a commit that referenced this pull request Sep 11, 2026
…11739)

* Revert nested overload materialization and dependent checker fixes

Selectively roll back #11601, #11621, and checker-only #11732 while preserving primer-analysis tooling and independent subsequent fixes. Retain regression fixtures and document the restored conformance, constructor, and protocol-operation limitations in current-behavior expectations.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* Restore matching gh-aw compiler and runtime for primer analysis

Regenerate with v0.86.2, preserve current artifact action versions, and prevent standalone runtime bumps with a narrow Dependabot ignore and workflow consistency coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* Preserve constructor constraints and results across union branches

Replay each expanded argument using its own overload constraints and retain definitive constructed union branches. Fix the reproduced Werkzeug Mapping-to-dict regression without restoring nested overload materialization, and retain precise positive and negative regression coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@bschnurr

Copy link
Copy Markdown
Member

/benchmark

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-auto:approved Automated review: no blocking findings (approval posted).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants