fix Pyrefly loses track of "is not None" information for a variable and-ed in a return condition #4919 - #4983
Open
asukaminato0721 wants to merge 1 commit into
Open
asukaminato0721 wants to merge 1 commit into
asukaminato0721 wants to merge 1 commit into
Conversation
Contributor
|
This pull request has been imported. If you are a Meta employee, you can view this in D120731861. (Because this pull request was imported automatically, there will not be any future comments.) |
|
Diff from mypy_primer, showing the effect of this PR on open source code: ============================================================
SUMMARY
============================================================
Total: +21 new errors, -20 fixed errors
By preset: +8/-9 (default), +8/-9 (strict)
Projects with changes (11):
cloud-init: +2 -0
spark: +2 -1
jax: +2 -5
colour: +0 -4
scikit-learn: +1 -2
streamlit: +1 -1
hydra-zen: +1 -0
static-frame: +0 -1
pandas: +5 -6
xarray: +6 -0
PyGithub: +1 -0
============================================================
FULL DIFF DETAILS
------------------------------------------------------------
cloud-init (https://github.com/canonical/cloud-init)
+ ERROR cloudinit/config/cc_write_files.py:154:17-20: The type of this argument is unknown [unknown-argument-type]
+ ERROR cloudinit/config/cc_write_files.py:165:17-20: The type of this argument is unknown [unknown-argument-type]
spark (https://github.com/apache/spark)
- ERROR python/pyspark/sql/connect/dataframe.py:2168:42-50: Implicit conversion of `bool | str | None` to `bool` is not allowed [implicit-bool]
+ ERROR python/pyspark/sql/connect/dataframe.py:2170:32-43: Redundant cast: `str` is the same type as `str` [redundant-cast]
+ ERROR python/pyspark/sql/connect/dataframe.py:2172:32-47: Redundant cast: `str` is the same type as `str` [redundant-cast]
jax (https://github.com/google/jax)
- ERROR jax/_src/pallas/mosaic_gpu/lowering.py:2588:37-46: The type of this argument is unknown [unknown-argument-type]
- ERROR jax/_src/pallas/mosaic_gpu/lowering.py:2601:35-44: The type of this argument is unknown [unknown-argument-type]
- ERROR jax/_src/pallas/mosaic_gpu/lowering.py:2602:35-44: The type of this argument is unknown [unknown-argument-type]
- ERROR jax/_src/state/primitives.py:927:20-57: The type of `out_bdim` is unknown; it is inferred as an implicit `Any` [unknown-variable-type]
+ ERROR jax/_src/state/primitives.py:927:20-57: `-` is not supported between `None` and `int` [unsupported-operation]
- ERROR jax/_src/state/primitives.py:956:45-52: The type of this argument is unknown [unknown-argument-type]
+ ERROR jax/_src/state/primitives.py:956:45-52: Argument `Unknown | None` is not assignable to parameter `dst` with type `Sequence[int] | int` in function `jax._src.util.moveaxis` [bad-argument-type]
colour (https://github.com/colour-science/colour)
- ERROR colour/quality/cqs.py:304:31-59: `MultiSpectralDistributions | SpectralDistribution` is not assignable to upper bound `MultiSpectralDistributions` of type variable `TypeMultiSpectralDistributions` [bad-specialization]
- ERROR colour/quality/cqs.py:311:29-57: `MultiSpectralDistributions | SpectralDistribution` is not assignable to upper bound `SpectralDistribution` of type variable `TypeSpectralDistribution` [bad-specialization]
- ERROR colour/quality/cri.py:254:31-59: `MultiSpectralDistributions | SpectralDistribution` is not assignable to upper bound `MultiSpectralDistributions` of type variable `TypeMultiSpectralDistributions` [bad-specialization]
- ERROR colour/quality/cri.py:261:29-57: `MultiSpectralDistributions | SpectralDistribution` is not assignable to upper bound `SpectralDistribution` of type variable `TypeSpectralDistribution` [bad-specialization]
scikit-learn (https://github.com/scikit-learn/scikit-learn)
- ERROR sklearn/neighbors/_nearest_centroid.py:252:29-43: The type of `dataset_centroid_` is unknown; it is inferred as an implicit `Any` [unknown-variable-type]
+ ERROR sklearn/neighbors/_nearest_centroid.py:252:29-35: Object of class `SparseABC` has no attribute `mean` [missing-attribute]
- ERROR sklearn/preprocessing/_data.py:2975:30-31: The type of this argument is unknown [unknown-argument-type]
streamlit (https://github.com/streamlit/streamlit)
- ERROR lib/streamlit/elements/widgets/slider.py:961:50-84: `Integral | Real | date | datetime | list[Integral | Real | date | datetime | list[Unknown] | time | tuple[Unknown, ...]] | list[Unknown] | time | tuple[Unknown, ...]` is not assignable to `Sequence[SliderScalar]` [bad-assignment]
+ ERROR lib/streamlit/elements/widgets/slider.py:961:50-84: `list[Integral | Real | date | datetime | time] | list[Unknown] | tuple[Unknown, ...]` is not assignable to `Sequence[SliderScalar]` [bad-assignment]
hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
+ ERROR src/hydra_zen/structured_configs/_implementations.py:2426:50-63: Unnecessary `bool()` call; argument is already of type `bool` [unnecessary-type-conversion]
static-frame (https://github.com/static-frame/static-frame)
- ERROR static_frame/core/util.py:1446:34-54: No matching overload found for function `numpy._core.multiarray.empty` called with arguments: (tuple[int, int | Unknown] | tuple[int, int] | None, dtype=dtype | None) [no-matching-overload]
pandas (https://github.com/pandas-dev/pandas)
+ ERROR pandas/core/apply.py:633:30-68: The type of `series` is unknown; it is inferred as an implicit `Any` [unknown-variable-type]
+ ERROR pandas/core/apply.py:634:44-50: The type of this argument is unknown [unknown-argument-type]
+ ERROR pandas/core/apply.py:638:34-71: The type of `series` is unknown; it is inferred as an implicit `Any` [unknown-variable-type]
+ ERROR pandas/core/apply.py:639:48-54: The type of this argument is unknown [unknown-argument-type]
- ERROR pandas/core/arrays/categorical.py:180:53-58: Argument `Hashable | Unknown` is not assignable to parameter `right` with type `ExtensionArray | Interval[Unknown] | NAType | Timedelta | Timestamp | bool | bytes | complex | complexfloating | date | datetime | datetime64 | float | floating | int | integer | list[Unknown] | ndarray | range | str | timedelta | timedelta64` in function `pandas.core.ops.invalid.invalid_comparison` [bad-argument-type]
+ ERROR pandas/core/arrays/categorical.py:180:53-58: Argument `Hashable` is not assignable to parameter `right` with type `ExtensionArray | Interval[Unknown] | NAType | Timedelta | Timestamp | bool | bytes | complex | complexfloating | date | datetime | datetime64 | float | floating | int | integer | list[Unknown] | ndarray | range | str | timedelta | timedelta64` in function `pandas.core.ops.invalid.invalid_comparison` [bad-argument-type]
- ERROR pandas/core/arrays/period.py:1554:20-30: Object of type `NaTType | Period | None` has no attribute `freq` [missing-attribute]
- ERROR pandas/core/arrays/period.py:1556:20-28: Object of type `NaTType | Period | None` has no attribute `freq` [missing-attribute]
- ERROR pandas/core/ops/missing.py:56:17-23: The type of `ymask` is unknown; it is inferred as an implicit `Any` [unknown-variable-type]
- ERROR pandas/tests/tools/test_to_datetime.py:4640:34-43: The type of this argument is unknown [unknown-argument-type]
- ERROR pandas/tests/tools/test_to_datetime.py:4640:57-66: The type of this argument is unknown [unknown-argument-type]
xarray (https://github.com/pydata/xarray)
+ ERROR xarray/coding/variables.py:299:77-79: The type of this argument is unknown [unknown-argument-type]
+ ERROR xarray/coding/variables.py:299:81-83: The type of this argument is unknown [unknown-argument-type]
+ ERROR xarray/coding/variables.py:308:76-78: The type of this argument is unknown [unknown-argument-type]
+ ERROR xarray/coding/variables.py:312:42-44: The type of this argument is unknown [unknown-argument-type]
+ ERROR xarray/coding/variables.py:322:21-329:22: The type of this argument is unknown [unknown-argument-type]
+ ERROR xarray/coding/variables.py:322:55-57: The type of this argument is unknown [unknown-argument-type]
PyGithub (https://github.com/PyGithub/PyGithub)
+ ERROR github/Repository.py:4115:91-92: Unused `# type: ignore` comment [unused-type-ignore] |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #4919
Saved boolean conditions now preserve narrowing through compound early-return guards.
Test Plan
add test