Conversation
This comment has been minimized.
This comment has been minimized.
| }); | ||
| }); | ||
|
|
||
| // For guaranteed loops, add post-body exit path. |
There was a problem hiding this comment.
Copilot generated:
Bug (High): Unconditional break in a guaranteed loop defeats the optimization. Traced flow: (1) preForLabel ← entry state (y unbound), (2) zero-iteration path correctly skipped, (3) loop body assigns y = 1 then break sends y=1 to postForLabel and sets _currentFlowNode unreachable, (4) fallback branch adds preForLabel (y unbound) to preElseLabel, (5) postForLabel merges break-path (y=1) + else-path (y unbound) = y possibly unbound.
The zero-iteration path was removed, but the fallback re-introduces an equivalent pre-loop-state path. Net effect: no improvement for for x in [1]: y = 1; break; print(y).
Consider distinguishing break-unreachable from continue-unreachable: when all paths break, preElseLabel should get no antecedent (Python: else doesn't run after break). When all paths continue, preForLabel is a reasonable approximation. When all paths return/raise, both should be unreachable.
| @@ -0,0 +1,100 @@ | |||
| # This sample tests that for loops over non-empty literal list or tuple | |||
There was a problem hiding this comment.
Copilot generated:
Missing critical test scenarios: The test file covers happy paths well but omits the most practically important edge cases that would reveal the break bug:
breakin guaranteed loop (most common control flow variant — currently broken)- Conditional
break(if cond: break) — tests the non-unreachable branch of the new code for...elsewith guaranteed loop — tests interaction with Python's else-after-loop semanticsreturnin guaranteed loop — tests reachability of post-loop coderaisein guaranteed loop — same class as break/return- Nested guaranteed loops (
for x in [1]: for y in [2]: z = 1)
Adding these would have caught the break bug before review.
|
Diff from mypy_primer, showing the effect of this PR on open source code: ibis (https://github.com/ibis-project/ibis)
- .../projects/ibis/ibis/backends/sql/datatypes.py:80:5 - error: "_attr" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/ibis/ibis/backends/sql/datatypes.py:80:12 - error: "_ibis_type" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/ibis/ibis/backends/sql/datatypes.py:80:24 - error: "_sg_type" is possibly unbound (reportPossiblyUnboundVariable)
- 7567 errors, 262 warnings, 0 informations
+ 7564 errors, 262 warnings, 0 informations
black (https://github.com/psf/black)
- .../projects/black/src/black/linegen.py:909:12 - error: "matching_bracket" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/black/src/black/linegen.py:909:36 - error: "tail_leaves" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/black/src/black/linegen.py:913:9 - error: "head_leaves" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/black/src/black/linegen.py:916:9 - error: "body_leaves" is possibly unbound (reportPossiblyUnboundVariable)
- 36 errors, 12 warnings, 0 informations
+ 32 errors, 12 warnings, 0 informations
sympy (https://github.com/sympy/sympy)
- .../projects/sympy/sympy/combinatorics/tests/test_perm_groups.py:195:5 - error: "G" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/sympy/sympy/combinatorics/tests/test_perm_groups.py:196:32 - error: "G" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/sympy/sympy/combinatorics/tests/test_perm_groups.py:196:35 - error: "G" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/sympy/sympy/concrete/tests/test_sums_products.py:792:12 - error: "func" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/sympy/sympy/concrete/tests/test_sums_products.py:793:12 - error: "func" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/sympy/sympy/concrete/tests/test_sums_products.py:794:12 - error: "func" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/sympy/sympy/concrete/tests/test_sums_products.py:795:12 - error: "func" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/sympy/sympy/printing/pretty/pretty.py:1498:11 - error: "baseline" is not a known attribute of "None" (reportOptionalMemberAccess)
- .../projects/sympy/sympy/printing/pretty/pretty.py:1498:24 - error: "height" is not a known attribute of "None" (reportOptionalMemberAccess)
- .../projects/sympy/sympy/printing/pretty/pretty.py:1502:27 - error: "right" is not a known attribute of "None" (reportOptionalMemberAccess)
- .../projects/sympy/sympy/series/residues.py:61:17 - error: "s" is possibly unbound (reportPossiblyUnboundVariable)
+ .../projects/sympy/sympy/solvers/diophantine/diophantine.py:176:44 - error: Cannot access attribute "expand" for class "Basic"
+ Attribute "expand" is unknown (reportAttributeAccessIssue)
+ .../projects/sympy/sympy/solvers/diophantine/tests/test_diophantine.py:314:30 - error: Cannot access attribute "as_independent" for class "Basic"
+ Attribute "as_independent" is unknown (reportAttributeAccessIssue)
+ .../projects/sympy/sympy/solvers/diophantine/tests/test_diophantine.py:383:30 - error: Cannot access attribute "as_independent" for class "Basic"
+ Attribute "as_independent" is unknown (reportAttributeAccessIssue)
+ .../projects/sympy/sympy/solvers/ode/lie_group.py:619:61 - error: Operator "-" not supported for type "Unknown | Basic" (reportOperatorIssue)
+ .../projects/sympy/sympy/solvers/ode/nonhomogeneous.py:225:45 - error: Cannot access attribute "has" for class "tuple[Expr, int]"
+ Attribute "has" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/solvers/ode/nonhomogeneous.py:223:22 - error: No overloads for "__new__" match the provided arguments (reportCallIssue)
- .../projects/sympy/sympy/solvers/ode/nonhomogeneous.py:223:25 - error: Argument of type "CRootOf | tuple[Expr, int]" cannot be assigned to parameter "arg" of type "Expr" in function "__new__"
- Type "CRootOf | tuple[Expr, int]" is not assignable to type "Expr"
- "tuple[Expr, int]" is not assignable to "Expr" (reportArgumentType)
- .../projects/sympy/sympy/solvers/ode/nonhomogeneous.py:238:40 - error: No overloads for "__new__" match the provided arguments (reportCallIssue)
- .../projects/sympy/sympy/solvers/ode/nonhomogeneous.py:238:50 - error: Argument of type "CRootOf | tuple[Expr, int]" cannot be assigned to parameter "arg" of type "Expr" in function "__new__"
- Type "CRootOf | tuple[Expr, int]" is not assignable to type "Expr"
- "tuple[Expr, int]" is not assignable to "Expr" (reportArgumentType)
- .../projects/sympy/sympy/solvers/ode/single.py:867:9 - error: Expression with type "tuple[ComplexInfinity | Unknown | Any, list[tuple[Unknown, Unknown]] | list[Unknown]] | tuple[ComplexInfinity | Unknown | Any, list[tuple[Unknown, Unknown]] | list[Unknown], list[tuple[Unknown, Unknown]] | list[Unknown]]" cannot be assigned to target tuple
- Type "tuple[ComplexInfinity | Unknown | Any, list[tuple[Unknown, Unknown]] | list[Unknown], list[tuple[Unknown, Unknown]] | list[Unknown]]" is incompatible with target tuple
- Tuple size mismatch; expected 2 but received 3 (reportAssignmentType)
+ .../projects/sympy/sympy/solvers/ode/single.py:2646:27 - error: Argument of type "One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Infinity | NegativeInfinity | Float | Number | Expr | Unknown | int" 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 | Unknown | int" is not assignable to type "SupportsIndex"
+ "Expr" is incompatible with protocol "SupportsIndex"
+ "__index__" is not present (reportArgumentType)
- .../projects/sympy/sympy/solvers/ode/single.py:2652:9 - error: Operator "+=" not supported for types "Unknown | Any | Zero | One | NegativeOne | Integer | NaN | ComplexInfinity | Rational | Infinity | NegativeInfinity | Float | Number | Expr" and "Basic | Any | Unknown"
+ .../projects/sympy/sympy/solvers/ode/single.py:2652:9 - error: Operator "+=" not supported for types "One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Infinity | NegativeInfinity | Float | Number | Expr | Any | Unknown" and "Basic | Any | Unknown"
- .../projects/sympy/sympy/solvers/ode/systems.py:1214:26 - error: Argument of type "dict[str, str | Unknown | Expr | bool | Symbol]" cannot be assigned to parameter "m" of type "Iterable[tuple[str, str]]" in function "update"
+ .../projects/sympy/sympy/solvers/ode/systems.py:1214:26 - error: Argument of type "dict[str, str | Unknown | Pow | bool | Symbol]" cannot be assigned to parameter "m" of type "Iterable[tuple[str, str]]" in function "update"
- .../projects/sympy/sympy/solvers/solveset.py:776:18 - error: Argument of type "Unknown | None" cannot be assigned to parameter "expr" of type "Expr" in function "together"
+ .../projects/sympy/sympy/solvers/solveset.py:776:18 - error: Argument of type "Expr | Unknown | None" cannot be assigned to parameter "expr" of type "Expr" in function "together"
- Type "Unknown | None" is not assignable to type "Expr"
+ Type "Expr | Unknown | None" is not assignable to type "Expr"
- .../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 | Unknown"
- Type "ComplexInfinity | 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 | Unknown"
- Type "Expr | Unknown" is not assignable to type "None"
- "Expr" is not assignable to "None" (reportIncompatibleMethodOverride)
- .../projects/sympy/sympy/stats/symbolic_probability.py:75:9 - error: Method "doit" overrides class "Basic" in an incompatible manner
- Return type mismatch: base method returns type "Basic", override returns type "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]"
- Type "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]" is not assignable to type "Basic"
- "Literal[0]" is not assignable to "Basic" (reportIncompatibleMethodOverride)
- .../projects/sympy/sympy/stats/tests/test_continuous_rv.py:1543:12 - error: No overloads for "simplify" match the provided arguments (reportCallIssue)
- .../projects/sympy/sympy/stats/tests/test_continuous_rv.py:1543:21 - error: Argument of type "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]" cannot be assigned to parameter "expr" of type "Basic" in function "simplify"
- Type "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]" is not assignable to type "Basic"
- "Literal[0]" is not assignable to "Basic" (reportArgumentType)
- .../projects/sympy/sympy/stats/tests/test_continuous_rv.py:1545:12 - error: No overloads for "simplify" match the provided arguments (reportCallIssue)
- .../projects/sympy/sympy/stats/tests/test_continuous_rv.py:1545:21 - error: Argument of type "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]" cannot be assigned to parameter "expr" of type "Basic" in function "simplify"
- Type "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]" is not assignable to type "Basic"
... (truncated 1126 lines) ...
scikit-learn (https://github.com/scikit-learn/scikit-learn)
- .../projects/scikit-learn/sklearn/covariance/tests/test_graphical_lasso.py:66:40 - error: "covs" is possibly unbound (reportPossiblyUnboundVariable)
+ ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:350:9 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
- ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:342:9 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
+ ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:352:9 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
- ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:347:5 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
- ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:350:63 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
- ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:352:63 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
- ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:354:64 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
+ ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:354:9 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
- ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:361:24 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
+ ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:357:20 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
- ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:362:26 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
+ ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:362:9 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
- ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:363:23 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
+ ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:363:9 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
- ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:365:47 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
+ ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:365:9 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
- ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:368:29 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
+ ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:366:9 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
+ ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:370:9 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
+ ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:376:9 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
+ ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:377:9 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
- ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:374:29 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
+ ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:379:29 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
- ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:376:26 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
- ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:377:23 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
- ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:381:9 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
- ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:384:27 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
+ ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:384:16 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
+ ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:386:12 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
+ ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:574:55 - error: Cannot access attribute "data" for class "tuple[Any | list[str] | list[str | Unknown | Any] | list[Unknown | Any] | Unknown | list[Unknown], ndarray[_AnyShape, dtype[intp]] | Unknown | Any | ndarray[_AnyShape, dtype[Unknown]]]"
- ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:573:44 - error: Argument of type "int16" cannot be assigned to parameter "dtype" of type "int64" in function "__init__"
- "int16" is not assignable to "int64"
- Type "int16" is not assignable to type "int64"
- Type parameter "_NBit@signedinteger" is invariant, but "_16Bit" is not the same as "_64Bit" (reportArgumentType)
- ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:574:61 - error: Cannot access attribute "tocsr" for class "tuple[Unknown, set[Unknown]]"
+ ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:574:61 - error: Cannot access attribute "tocsr" for class "SparseABC"
- ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:575:49 - error: Cannot access attribute "data" for class "tuple[Any | list[str] | list[str | Unknown | Any] | list[Unknown | Any] | Unknown | list[Unknown], ndarray[_AnyShape, dtype[intp]] | Unknown | Any | ndarray[_AnyShape, dtype[Unknown]]]"
+ ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:575:55 - error: Cannot access attribute "tocsr" for class "SparseABC"
+ Attribute "tocsr" is unknown (reportAttributeAccessIssue)
- ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:588:31 - error: Cannot access attribute "target_names" for class "tuple[Any | list[str] | list[str | Unknown | Any] | list[Unknown | Any] | Unknown | list[Unknown], ndarray[_AnyShape, dtype[intp]] | Unknown | Any | ndarray[_AnyShape, dtype[Unknown]]]"
- Attribute "target_names" is unknown (reportAttributeAccessIssue)
- ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:595:28 - error: Cannot access attribute "target" for class "tuple[Any | list[str] | list[str | Unknown | Any] | list[Unknown | Any] | Unknown | list[Unknown], ndarray[_AnyShape, dtype[intp]] | Unknown | Any | ndarray[_AnyShape, dtype[Unknown]]]"
+ ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:592:29 - error: Cannot access attribute "target" for class "tuple[Any | list[str] | list[str | Unknown | Any] | list[Unknown | Any] | Unknown | list[Unknown], ndarray[_AnyShape, dtype[intp]] | Unknown | Any | ndarray[_AnyShape, dtype[Unknown]]]"
- ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:598:63 - error: Cannot access attribute "target" for class "tuple[Any | list[str] | list[str | Unknown | Any] | list[Unknown | Any] | Unknown | list[Unknown], ndarray[_AnyShape, dtype[intp]] | Unknown | Any | ndarray[_AnyShape, dtype[Unknown]]]"
+ ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:598:45 - error: Cannot access attribute "target" for class "tuple[Any | list[str] | list[str | Unknown | Any] | list[Unknown | Any] | Unknown | list[Unknown], ndarray[_AnyShape, dtype[intp]] | Unknown | Any | ndarray[_AnyShape, dtype[Unknown]]]"
- ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:609:13 - error: "target" is possibly unbound (reportPossiblyUnboundVariable)
+ ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:608:13 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
- ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:616:22 - error: "target" is possibly unbound (reportPossiblyUnboundVariable)
+ ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:616:16 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
- ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:620:16 - error: "target" is possibly unbound (reportPossiblyUnboundVariable)
+ ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/_twenty_newsgroups.py:619:14 - error: "data" is possibly unbound (reportPossiblyUnboundVariable)
+ ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/tests/test_20news.py
- ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/tests/test_20news.py:9:8 - error: Import "pytest" could not be resolved (reportMissingImports)
+ ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/tests/test_20news.py:10:8 - warning: Import "scipy.sparse" could not be resolved from source (reportMissingModuleSource)
+ ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/tests/test_20news.py:69:23 - error: Cannot access attribute "shape" for class "SparseABC"
+ Attribute "shape" is unknown (reportAttributeAccessIssue)
- ...tmp/mypy_primer/projects/scikit-learn/sklearn/datasets/tests/test_20news.py:68:51 - error: Cannot access attribute "format" for class "SparseABC"
... (truncated 24 lines) ...
tornado (https://github.com/tornadoweb/tornado)
- .../projects/tornado/tornado/test/httpclient_test.py:664:34 - error: "resp" is possibly unbound (reportPossiblyUnboundVariable)
- 190 errors, 60 warnings, 0 informations
+ 189 errors, 60 warnings, 0 informations
core (https://github.com/home-assistant/core)
- .../projects/core/homeassistant/components/opower/coordinator.py:290:24 - error: "stats" is possibly unbound (reportPossiblyUnboundVariable)
- 28963 errors, 254 warnings, 0 informations
+ 28962 errors, 254 warnings, 0 informations
dd-trace-py (https://github.com/DataDog/dd-trace-py)
- .../projects/dd-trace-py/ddtrace/contrib/internal/pytest/_plugin_v2.py:851:12 - error: Type "_TestOutcome | None" is not assignable to return type "_TestOutcome"
- Type "_TestOutcome | None" is not assignable to type "_TestOutcome"
- "None" is not assignable to "_TestOutcome" (reportReturnType)
- 13832 errors, 685 warnings, 0 informations
+ 13831 errors, 685 warnings, 0 informations
xarray (https://github.com/pydata/xarray)
- .../projects/xarray/xarray/tests/test_dataset.py:6372:35 - error: Argument of type "Unknown | Hashable" cannot be assigned to parameter "q" of type "ArrayLike" in function "quantile"
+ .../projects/xarray/xarray/tests/test_dataset.py:6372:35 - error: Argument of type "Hashable | Unknown" cannot be assigned to parameter "q" of type "ArrayLike" in function "quantile"
- Type "Unknown | Hashable" is not assignable to type "ArrayLike"
+ Type "Hashable | Unknown" is not assignable to type "ArrayLike"
psycopg (https://github.com/psycopg/psycopg)
- .../projects/psycopg/tools/update_error_prefixes.py:75:22 - error: "default_pgroot" is possibly unbound (reportPossiblyUnboundVariable)
- 1862 errors, 114 warnings, 0 informations
+ 1861 errors, 114 warnings, 0 informations
werkzeug (https://github.com/pallets/werkzeug)
- .../projects/werkzeug/tests/test_test.py:697:50 - error: Argument of type "((environ: Unknown, start_response: Unknown) -> Iterable) | ((environ: Unknown, start_response: Unknown) -> list[str]) | ((environ: Unknown, start_response: Unknown) -> Generator[Literal['Hello ', 'World!'], Any, None]) | ((environ: Unknown, start_response: Unknown) -> Generator[Literal['Hello ', 'World', '!'], Any, None]) | ((environ: Unknown, start_response: Unknown) -> Rv)" cannot be assigned to parameter "app" of type "WSGIApplication" in function "run_wsgi_app"
- Type "((environ: Unknown, start_response: Unknown) -> Iterable) | ((environ: Unknown, start_response: Unknown) -> list[str]) | ((environ: Unknown, start_response: Unknown) -> Generator[Literal['Hello ', 'World!'], Any, None]) | ((environ: Unknown, start_response: Unknown) -> Generator[Literal['Hello ', 'World', '!'], Any, None]) | ((environ: Unknown, start_response: Unknown) -> Rv)" is not assignable to type "WSGIApplication"
+ .../projects/werkzeug/tests/test_test.py:697:50 - error: Argument of type "((environ: Unknown, start_response: Unknown) -> Iterable) | ((environ: Unknown, start_response: Unknown) -> list[str])" cannot be assigned to parameter "app" of type "WSGIApplication" in function "run_wsgi_app"
+ Type "((environ: Unknown, start_response: Unknown) -> Iterable) | ((environ: Unknown, start_response: Unknown) -> list[str])" is not assignable to type "WSGIApplication"
- Type "(environ: Unknown, start_response: Unknown) -> Rv" is not assignable to type "WSGIApplication"
+ Type "(environ: Unknown, start_response: Unknown) -> list[str]" is not assignable to type "WSGIApplication"
- Function return type "Rv" is incompatible with type "Iterable[bytes]"
+ Function return type "list[str]" is incompatible with type "Iterable[bytes]"
- "Rv" is incompatible with protocol "Iterable[bytes]" (reportArgumentType)
+ "list[str]" is not assignable to "Iterable[bytes]"
+ Type parameter "_T_co@Iterable" is covariant, but "str" is not a subtype of "bytes" (reportArgumentType)
cryptography (https://github.com/pyca/cryptography)
- .../projects/cryptography/tests/hazmat/primitives/test_ssh.py:225:30 - error: "private_key" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/cryptography/tests/hazmat/primitives/test_ssh.py:242:26 - error: "private_key" is possibly unbound (reportPossiblyUnboundVariable)
- 400 errors, 22 warnings, 0 informations
+ 398 errors, 22 warnings, 0 informations
spark (https://github.com/apache/spark)
- .../projects/spark/python/pyspark/ml/tests/connect/test_legacy_mode_evaluation.py:133:13 - error: "auprc_evaluator" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/spark/python/pyspark/mllib/tests/test_feature.py:153:26 - error: "mat" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/spark/python/pyspark/pandas/tests/frame/test_reindexing.py:551:42 - error: "keep" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/spark/python/pyspark/pandas/tests/frame/test_reindexing.py:552:43 - error: "keep" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/spark/python/pyspark/pandas/tests/frame/test_reindexing.py:555:48 - error: "keep" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/spark/python/pyspark/pandas/tests/frame/test_reindexing.py:556:49 - error: "keep" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/spark/python/pyspark/pandas/tests/groupby/test_aggregate.py:110:40 - error: "as_index" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/spark/python/pyspark/sql/tests/test_functions.py:1534:59 - error: "aq" is possibly unbound (reportPossiblyUnboundVariable)
- 31719 errors, 931 warnings, 0 informations
+ 31711 errors, 931 warnings, 0 informations
spack (https://github.com/spack/spack)
- .../projects/spack/lib/spack/spack/package_prefs.py
- .../projects/spack/lib/spack/spack/package_prefs.py:149:27 - error: "variants" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/spack/lib/spack/spack/package_prefs.py:150:33 - error: "variants" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/spack/lib/spack/spack/package_prefs.py:225:8 - error: "readable" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/spack/lib/spack/spack/package_prefs.py:227:8 - error: "readable" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/spack/lib/spack/spack/package_prefs.py:230:8 - error: "writable" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/spack/lib/spack/spack/package_prefs.py:231:12 - error: "readable" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/spack/lib/spack/spack/package_prefs.py:238:8 - error: "writable" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/spack/lib/spack/spack/package_prefs.py:239:12 - error: "readable" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/spack/lib/spack/spack/package_prefs.py:261:12 - error: "group" is possibly unbound (reportPossiblyUnboundVariable)
- 2058 errors, 24 warnings, 0 informations
+ 2049 errors, 24 warnings, 0 informations
cloud-init (https://github.com/canonical/cloud-init)
- .../projects/cloud-init/tests/unittests/sources/test_init.py:737:26 - error: "filename" is possibly unbound (reportPossiblyUnboundVariable)
- 1136 errors, 90 warnings, 0 informations
+ 1135 errors, 90 warnings, 0 informations
poetry (https://github.com/python-poetry/poetry)
- .../projects/poetry/src/poetry/repositories/link_sources/html.py:59:77 - error: "metadata" is possibly unbound (reportPossiblyUnboundVariable)
- 1182 errors, 41 warnings, 0 informations
+ 1181 errors, 41 warnings, 0 informations
vision (https://github.com/pytorch/vision)
- .../projects/vision/test/test_transforms.py:1949:26 - error: "mean" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/vision/test/test_transforms.py:1949:32 - error: "std" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/vision/torchvision/models/feature_extraction.py:601:87 - error: "name" is possibly unbound (reportPossiblyUnboundVariable)
- 1719 errors, 51 warnings, 0 informations
+ 1716 errors, 51 warnings, 0 informations
jax (https://github.com/google/jax)
- .../projects/jax/jax/_src/internal_test_util/test_harnesses.py:1840:11 - error: "shape" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/jax/jax/_src/internal_test_util/test_harnesses.py:1841:11 - error: "shape" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/jax/jax/_src/internal_test_util/test_harnesses.py:1841:31 - error: "shape" is possibly unbound (reportPossiblyUnboundVariable)
- .../projects/jax/jax/_src/internal_test_util/test_harnesses.py:1845:19 - error: "shape" is possibly unbound (reportPossiblyUnboundVariable)
- 3005 errors, 83 warnings, 0 informations
... (truncated 9 lines) ...``` |
rchiodo
left a comment
There was a problem hiding this comment.
Approved via Review Center.
When iterating over a non-empty literal, we can assume that the loop body is executed at least once and base inference on that.