Skip to content

Fallback to root pyproject.toml if project pyproject.toml doesnt contain [tool.pyright] - #11323

Merged
Rich Chiodo (rchiodo) merged 6 commits into
microsoft:mainfrom
thejcannon:jcannon/fix-11320
Mar 11, 2026
Merged

Rich Chiodo (rchiodo) merged 6 commits into
microsoft:mainfrom
thejcannon:jcannon/fix-11320

Conversation

@thejcannon

Copy link
Copy Markdown
Contributor

Fixes #11320 by having _getExtendedConfigurations take in a "search directory" to fallback to searching if we load the pyproject.toml and it doesn't contain a [tool.pyright] (which it then loads by calling _getExtendedConfigurations).

This makes it so we still only read/parse the config once, while being able to "fallback" correctly.

Comment thread packages/pyright/package-lock.json Resolved
@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/solvers/tests/test_solveset.py:445:30 - error: Cannot access attribute "limit_denominator" for class "NaN"
-     Attribute "limit_denominator" is unknown (reportAttributeAccessIssue)
-   .../projects/sympy/sympy/solvers/tests/test_solveset.py:445:30 - error: Cannot access attribute "limit_denominator" for class "ComplexInfinity"
-     Attribute "limit_denominator" is unknown (reportAttributeAccessIssue)
+   .../projects/sympy/sympy/solvers/tests/test_solveset.py:620:16 - error: No overloads for "__new__" match the provided arguments (reportCallIssue)
+   .../projects/sympy/sympy/solvers/tests/test_solveset.py:620:19 - error: Argument of type "Expr | Unknown | float" cannot be assigned to parameter "arg" of type "Expr" in function "__new__"
+     Type "Expr | Unknown | float" is not assignable to type "Expr"
+       "float" is not assignable to "Expr" (reportArgumentType)
+   .../projects/sympy/sympy/solvers/tests/test_solveset.py:625:16 - error: No overloads for "__new__" match the provided arguments (reportCallIssue)
+   .../projects/sympy/sympy/solvers/tests/test_solveset.py:625:19 - error: Argument of type "Expr | Unknown | float" cannot be assigned to parameter "arg" of type "Expr" in function "__new__"
+     Type "Expr | Unknown | float" is not assignable to type "Expr"
+       "float" is not assignable to "Expr" (reportArgumentType)
-   .../projects/sympy/sympy/stats/crv_types.py:2543:9 - error: Method "_cdf" overrides class "SingleContinuousDistribution" in an incompatible manner
-     Return type mismatch: base method returns type "None", override returns type "ComplexInfinity | NaN | Rational | Unknown"
-       Type "ComplexInfinity | NaN | Rational | Unknown" is not assignable to type "None"
-         "ComplexInfinity" is not assignable to "None" (reportIncompatibleMethodOverride)
-   .../projects/sympy/sympy/stats/crv_types.py:2722:9 - error: Method "_cdf" overrides class "SingleContinuousDistribution" in an incompatible manner
-     Return type mismatch: base method returns type "None", override returns type "Expr | NaN | ComplexInfinity | Rational | Unknown"
-       Type "Expr | NaN | ComplexInfinity | Rational | Unknown" is not assignable to type "None"
-         "Expr" is not assignable to "None" (reportIncompatibleMethodOverride)
-   .../projects/sympy/sympy/stats/frv_types.py:139:17 - error: Argument of type "NaN | ComplexInfinity | Rational | Unknown | Expr" cannot be assigned to parameter "value" of type "int" in function "__setitem__"
-     Type "NaN | ComplexInfinity | Rational | Unknown | Expr" is not assignable to type "int"
-       "Expr" is not assignable to "int" (reportArgumentType)
-   .../projects/sympy/sympy/stats/joint_rv_types.py:576:27 - error: Argument of type "One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Infinity | NegativeInfinity | Float | Number | Expr" cannot be assigned to parameter "stop" of type "SupportsIndex" in function "__new__"
+   .../projects/sympy/sympy/stats/joint_rv_types.py:576:27 - error: Argument of type "One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Unknown | Infinity | NegativeInfinity | Float | Number | Expr" cannot be assigned to parameter "stop" of type "SupportsIndex" in function "__new__"
-     Type "One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Infinity | NegativeInfinity | Float | Number | Expr" is not assignable to type "SupportsIndex"
+     Type "One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Unknown | Infinity | NegativeInfinity | Float | Number | Expr" is not assignable to type "SupportsIndex"
-   .../projects/sympy/sympy/stats/rv_interface.py:451:42 - error: Operator "-" not supported for types "Unknown | Basic | Any" and "Rational | NaN | ComplexInfinity"
+   .../projects/sympy/sympy/stats/rv_interface.py:451:42 - error: Operator "-" not supported for types "Unknown | Basic | Any" and "Rational | Unknown"
-     Operator "-" not supported for types "Basic" and "Rational"
-     Operator "-" not supported for types "Basic" and "NaN"
-     Operator "-" not supported for types "Basic" and "ComplexInfinity" (reportOperatorIssue)
+     Operator "-" not supported for types "Basic" and "Rational" (reportOperatorIssue)
-   .../projects/sympy/sympy/stats/tests/test_finite_rv.py:35:23 - error: Operator "/" not supported for types "Unknown | Any | One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Expr | MatMul | tuple[Unknown, ...] | Infinity | NegativeInfinity | int" and "Unknown | Any | BernoulliDistribution | Probability | Zero | One | tuple[Unknown, ...] | Sum | Expr | ZeroMatrix | NaN | Piecewise | Basic | ComplexInfinity | Float | Infinity | Integer | Lambda | Mul | NegativeInfinity | NegativeOne | Number | Rational | Integral | Literal[0]"
+   .../projects/sympy/sympy/stats/tests/test_finite_rv.py:35:23 - error: Operator "/" not supported for types "Unknown | Any | One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Expr | MatMul | Infinity | NegativeInfinity | Float | NotImplementedType | tuple[Unknown, ...] | int" and "Unknown | Any | BernoulliDistribution | Probability | Zero | One | tuple[Unknown, ...] | Sum | Expr | ZeroMatrix | NaN | Piecewise | Basic | ComplexInfinity | Float | Infinity | Integer | Lambda | Mul | NegativeInfinity | NegativeOne | Number | Rational | Integral | Literal[0]"
-   .../projects/sympy/sympy/stats/tests/test_finite_rv.py:247:19 - error: Argument of type "Rational | NaN | ComplexInfinity" cannot be assigned to parameter "p" of type "Half" in function "Coin"
+   .../projects/sympy/sympy/stats/tests/test_finite_rv.py:247:19 - error: Argument of type "Rational | Unknown" cannot be assigned to parameter "p" of type "Half" in function "Coin"
-     Type "Rational | NaN | ComplexInfinity" is not assignable to type "Half"
+     Type "Rational | Unknown" is not assignable to type "Half"
-       "ComplexInfinity" is not assignable to "Half" (reportArgumentType)
+       "Rational" is not assignable to "Half" (reportArgumentType)
+   .../projects/sympy/sympy/tensor/array/expressions/from_array_to_matrix.py:402:32 - error: Cannot access attribute "shape" for class "Infinity"
+     Attribute "shape" is unknown (reportAttributeAccessIssue)
+   .../projects/sympy/sympy/tensor/array/expressions/from_array_to_matrix.py:402:32 - error: Cannot access attribute "shape" for class "NegativeInfinity"
+     Attribute "shape" is unknown (reportAttributeAccessIssue)
+   .../projects/sympy/sympy/tensor/array/expressions/from_array_to_matrix.py:402:32 - error: Cannot access attribute "shape" for class "Float"
+     Attribute "shape" is unknown (reportAttributeAccessIssue)
+   .../projects/sympy/sympy/tensor/array/expressions/from_array_to_matrix.py:428:25 - error: Cannot access attribute "shape" for class "Infinity"
+     Attribute "shape" is unknown (reportAttributeAccessIssue)
+   .../projects/sympy/sympy/tensor/array/expressions/from_array_to_matrix.py:428:25 - error: Cannot access attribute "shape" for class "NegativeInfinity"
+     Attribute "shape" is unknown (reportAttributeAccessIssue)
+   .../projects/sympy/sympy/tensor/array/expressions/from_array_to_matrix.py:428:25 - error: Cannot access attribute "shape" for class "Float"
+     Attribute "shape" is unknown (reportAttributeAccessIssue)
-   .../projects/sympy/sympy/tensor/array/expressions/from_array_to_matrix.py:438:31 - error: Operator "*" not supported for types "Zero | ZeroArray | Unknown | ArrayContraction | Basic | PermuteDims | Any | Transpose | One | NegativeOne | Integer | NaN | ComplexInfinity | Rational | Expr | MatMul" and "Zero | ZeroArray | Unknown | ArrayContraction | Basic | PermuteDims | Any | Transpose | MatrixExpr"
+   .../projects/sympy/sympy/tensor/array/expressions/from_array_to_matrix.py:438:31 - error: Operator "*" not supported for types "Zero | ZeroArray | Unknown | ArrayContraction | Basic | PermuteDims | Any | Transpose | One | NegativeOne | Integer | NaN | ComplexInfinity | Rational | Infinity | NegativeInfinity | Float | NotImplementedType | Expr | MatMul" and "Zero | ZeroArray | Unknown | ArrayContraction | Basic | PermuteDims | Any | Transpose | MatrixExpr"
-     Return type mismatch: base method returns type "AssocOp", override returns type "Unknown | One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | TensExpr | TensMul"
+     Return type mismatch: base method returns type "AssocOp", override returns type "One | Zero | TensExpr | TensMul"
-       Type "Unknown | One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | TensExpr | TensMul" is not assignable to type "AssocOp"
+       Type "One | Zero | TensExpr | TensMul" is not assignable to type "AssocOp"
-         "ComplexInfinity" is not assignable to "AssocOp" (reportIncompatibleMethodOverride)
+         "One" is not assignable to "AssocOp" (reportIncompatibleMethodOverride)
-   .../projects/sympy/sympy/tensor/tensor.py:3639:37 - error: Operator "*" not supported for types "Unknown | One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational" and "Unknown | Basic"
-     Operator "*" not supported for types "ComplexInfinity" and "Basic" when expected type is "Unknown | One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational" (reportOperatorIssue)
-   .../projects/sympy/sympy/tensor/tensor.py:4358:42 - error: Operator "*" not supported for types "One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Unknown" and "Basic | Unknown"
-     Operator "*" not supported for types "ComplexInfinity" and "Basic" when expected type is "One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Unknown" (reportOperatorIssue)
-   .../projects/sympy/sympy/tensor/tensor.py:4409:39 - error: Cannot access attribute "_matches" for class "NegativeOne"
-     Attribute "_matches" is unknown (reportAttributeAccessIssue)

... (truncated 988 lines) ...

@rchiodo
Rich Chiodo (rchiodo) merged commit 8832b38 into microsoft:main Mar 11, 2026
16 checks passed
@thejcannon
Josh Cannon (thejcannon) deleted the jcannon/fix-11320 branch March 11, 2026 16:29
@thejcannon

Copy link
Copy Markdown
Contributor Author

I absolutely hate to be a bother, but I'd love to know if there's a release cadence or some ETA on the next Pyright release, so I can work on the upgrade locally. Thanks!

@rchiodo

Copy link
Copy Markdown
Collaborator

It usually depends upon there being enough fixes to bother. Right now it seems there's no bugs marked as addressed in next version? Oh this PR actually closed the bug. We usually just mark them as 'addressed in next version'. Let me check to see if there are others.

@rchiodo

Copy link
Copy Markdown
Collaborator

I think we want to fix a number of issues and after that release. Typeshed updated too. Hopefully in the next week

@thejcannon

Copy link
Copy Markdown
Contributor Author

Y'all's time and energy is very much appreciated ♥️

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--project as a directory should ignore pyproject.toml without tool.pyright

2 participants