Repository navigation
Conversation
A name assigned only inside a `for` loop is unbound after the loop when the iterable is empty. Pyrefly reported this, but stopped reporting it as soon as the loop body contained a conditional `break` (meta#5566). After the loop, the fall-through flow and the `break` flow carry the same value for the name, but with different styles: the fall-through flow marks it as possibly uninitialized, while the `break` flow, which assigned it, does not. The merge deduplicated values by index alone, assuming equal indices imply equal styles, so whichever branch came first decided the style and the doubt was lost. Deduplicating values together with their style keeps every distinct style in the merge, so the possibly-uninitialized style survives. The same assumption was hiding a few repeat diagnostics. After pyrefly reports an unbound name it treats the name as initialized in that flow, which also reuses the value index with a different style. Two existing tests now report a genuinely possibly-unbound use again after a merge, or say "may be uninitialized" instead of "is uninitialized".
Note: this comment updates automatically after changes to the PR. Updates may take up to half an hour. |
Contributor
|
This pull request has been imported. If you are a Meta employee, you can view this in D130509497. (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: +145 new errors, -12 fixed errors
By preset: +145/-0 (default), +145/-0 (strict)
Projects with changes (31):
pip: +4 -0
tornado: +2 -0
mongo-python-driver: +5 -5
pycryptodome: +2 -0
apprise: +2 -0
mkosi: +1 -0
rotki: +3 -0
jax: +2 -0
urllib3: +2 -0
scikit-learn: +44 -1
prefect: +8 -3
cwltool: +1 -0
spark: +6 -3
manticore: +2 -0
cloud-init: +9 -0
pandera: +2 -0
zulip: +10 -0
ibis: +1 -0
static-frame: +3 -0
mypy: +3 -0
hydpy: +1 -0
pandas: +2 -0
pytensor: +7 -0
meson: +4 -0
websockets: +3 -0
dd-trace-py: +1 -0
core: +6 -0
jinja: +1 -0
spack: +4 -0
xarray: +2 -0
rich: +2 -0
============================================================
FULL DIFF DETAILS
------------------------------------------------------------
pip (https://github.com/pypa/pip)
+ ERROR src/pip/_vendor/rich/filesize.py:36:24-28: `unit` may be uninitialized [unbound-name]
+ ERROR src/pip/_vendor/rich/filesize.py:49:12-16: `unit` may be uninitialized [unbound-name]
+ ERROR src/pip/_vendor/urllib3/connectionpool.py:907:16-24: `response` may be uninitialized [unbound-name]
+ ERROR src/pip/_vendor/urllib3/connectionpool.py:961:32-40: `response` may be uninitialized [unbound-name]
tornado (https://github.com/tornadoweb/tornado)
+ ERROR tornado/test/asyncio_test.py:182:34-41: `threads` may be uninitialized [unbound-name]
+ ERROR tornado/test/web_test.py:2380:16-23: `abspath` may be uninitialized [unbound-name]
mongo-python-driver (https://github.com/mongodb/mongo-python-driver)
- ERROR bson/__init__.py:1052:21-41: The type of `_dict_to_bson` is unknown because it comes from an error [unknown-from-error]
+ ERROR bson/__init__.py:1052:21-27: `_cbson` may be uninitialized [unbound-name]
- ERROR bson/__init__.py:1165:19-37: The type of `_decode_all` is unknown because it comes from an error [unknown-from-error]
+ ERROR bson/__init__.py:1165:19-25: `_cbson` may be uninitialized [unbound-name]
- ERROR bson/__init__.py:1256:37-73: The type of `_array_of_documents_to_buffer` is unknown because it comes from an error [unknown-from-error]
+ ERROR bson/__init__.py:1256:37-43: `_cbson` may be uninitialized [unbound-name]
- ERROR pymongo/message.py:670:23-48: The type of `_batched_op_msg` is unknown because it comes from an error [unknown-from-error]
+ ERROR pymongo/message.py:670:23-32: `_cmessage` may be uninitialized [unbound-name]
- ERROR pymongo/message.py:1008:37-76: The type of `_encode_batched_write_command` is unknown because it comes from an error [unknown-from-error]
+ ERROR pymongo/message.py:1008:37-46: `_cmessage` may be uninitialized [unbound-name]
pycryptodome (https://github.com/Legrandin/pycryptodome)
+ ERROR lib/Crypto/PublicKey/DSA.py:434:19-20: `g` may be uninitialized [unbound-name]
+ ERROR lib/Crypto/PublicKey/DSA.py:434:22-26: `seed` may be uninitialized [unbound-name]
apprise (https://github.com/caronc/apprise)
+ ERROR apprise/conversion/html.py:781:33-39: `marker` may be uninitialized [unbound-name]
+ ERROR apprise/utils/format.py:150:28-36: `gt_index` may be uninitialized [unbound-name]
mkosi (https://github.com/systemd/mkosi)
+ ERROR mkosi/config.py:4821:13-18: `group` may be uninitialized [unbound-name]
rotki (https://github.com/rotki/rotki)
+ ERROR rotkehlchen/db/drivers/sqlite.py:1003:100-110: `identifier` may be uninitialized [unbound-name]
+ ERROR rotkehlchen/exchanges/gemini.py:241:16-24: `response` may be uninitialized [unbound-name]
+ ERROR rotkehlchen/exchanges/kucoin.py:294:16-24: `response` may be uninitialized [unbound-name]
jax (https://github.com/google/jax)
+ ERROR jax/experimental/jax2tf/tests/shape_poly_test.py:161:22-26: `args` may be uninitialized [unbound-name]
+ ERROR jax/experimental/jax2tf/tests/shape_poly_test.py:185:24-28: `args` may be uninitialized [unbound-name]
urllib3 (https://github.com/urllib3/urllib3)
+ ERROR src/urllib3/connectionpool.py:896:16-24: `response` may be uninitialized [unbound-name]
+ ERROR src/urllib3/connectionpool.py:950:32-40: `response` may be uninitialized [unbound-name]
scikit-learn (https://github.com/scikit-learn/scikit-learn)
+ ERROR sklearn/cluster/_affinity_propagation.py:135:24-25: `E` may be uninitialized [unbound-name]
+ ERROR sklearn/cluster/_bisect_k_means.py:363:46-58: `best_centers` may be uninitialized [unbound-name]
+ ERROR sklearn/cluster/_kmeans.py:1699:29-35: `X_mean` may be uninitialized [unbound-name]
+ ERROR sklearn/cross_decomposition/_pls.py:106:12-21: `x_weights` may be uninitialized [unbound-name]
+ ERROR sklearn/cross_decomposition/_pls.py:106:23-32: `y_weights` may be uninitialized [unbound-name]
+ ERROR sklearn/decomposition/_fastica.py:687:46-47: `W` may be uninitialized [unbound-name]
+ ERROR sklearn/decomposition/_fastica.py:687:49-50: `K` may be uninitialized [unbound-name]
+ ERROR sklearn/decomposition/_fastica.py:690:17-18: `W` may be uninitialized [unbound-name]
+ ERROR sklearn/decomposition/_fastica.py:692:39-40: `W` may be uninitialized [unbound-name]
+ ERROR sklearn/decomposition/_fastica.py:692:42-43: `K` may be uninitialized [unbound-name]
+ ERROR sklearn/decomposition/_fastica.py:696:32-33: `W` may be uninitialized [unbound-name]
+ ERROR sklearn/gaussian_process/_gpc.py:495:46-48: `pi` may be uninitialized [unbound-name]
+ ERROR sklearn/gaussian_process/_gpc.py:495:50-54: `W_sr` may be uninitialized [unbound-name]
+ ERROR sklearn/gaussian_process/_gpc.py:495:56-57: `L` may be uninitialized [unbound-name]
+ ERROR sklearn/gaussian_process/_gpc.py:495:59-60: `b` may be uninitialized [unbound-name]
+ ERROR sklearn/gaussian_process/_gpc.py:495:62-63: `a` may be uninitialized [unbound-name]
+ ERROR sklearn/gaussian_process/kernels.py:1907:42-46: `base` may be uninitialized [unbound-name]
+ ERROR sklearn/gaussian_process/kernels.py:2051:67-77: `sin_of_arg` may be uninitialized [unbound-name]
+ ERROR sklearn/linear_model/_base.py:269:29-38: `sw_matrix` may be uninitialized [unbound-name]
+ ERROR sklearn/linear_model/_bayes.py:350:17-22: `coef_` may be uninitialized [unbound-name]
+ ERROR sklearn/linear_model/_glm/_newton_solver.py:747:38-47: `n_classes` may be uninitialized [unbound-name]
- ERROR sklearn/linear_model/_glm/_newton_solver.py:1195:17-45: The type of `w` is unknown because it comes from an error [unknown-from-error]
+ ERROR sklearn/linear_model/_glm/_newton_solver.py:1195:31-40: `n_classes` may be uninitialized [unbound-name]
+ ERROR sklearn/linear_model/_glm/_newton_solver.py:1227:40-49: `n_classes` may be uninitialized [unbound-name]
+ ERROR sklearn/linear_model/_least_angle.py:669:33-37: `coef` may be uninitialized [unbound-name]
+ ERROR sklearn/linear_model/_least_angle.py:761:56-66: `prev_alpha` may be uninitialized [unbound-name]
+ ERROR sklearn/linear_model/_least_angle.py:835:34-44: `prev_alpha` may be uninitialized [unbound-name]
+ ERROR sklearn/linear_model/_least_angle.py:847:13-23: `prev_alpha` may be uninitialized [unbound-name]
+ ERROR sklearn/linear_model/_least_angle.py:906:17-22: `coefs` may be uninitialized [unbound-name]
+ ERROR sklearn/linear_model/_least_angle.py:914:35-39: `coef` may be uninitialized [unbound-name]
+ ERROR sklearn/linear_model/_least_angle.py:916:35-39: `coef` may be uninitialized [unbound-name]
+ ERROR sklearn/linear_model/tests/test_base.py:832:41-50: `intercept` may be uninitialized [unbound-name]
+ ERROR sklearn/linear_model/tests/test_base.py:844:41-50: `intercept` may be uninitialized [unbound-name]
+ ERROR sklearn/linear_model/tests/test_coordinate_descent.py:1385:41-50: `intercept` may be uninitialized [unbound-name]
+ ERROR sklearn/linear_model/tests/test_coordinate_descent.py:1397:41-50: `intercept` may be uninitialized [unbound-name]
+ ERROR sklearn/linear_model/tests/test_coordinate_descent.py:1612:41-50: `intercept` may be uninitialized [unbound-name]
+ ERROR sklearn/linear_model/tests/test_coordinate_descent.py:1619:41-50: `intercept` may be uninitialized [unbound-name]
+ ERROR sklearn/linear_model/tests/test_ridge.py:2512:41-50: `intercept` may be uninitialized [unbound-name]
+ ERROR sklearn/linear_model/tests/test_ridge.py:2522:42-51: `intercept` may be uninitialized [unbound-name]
+ ERROR sklearn/manifold/_mds.py:192:26-32: `stress` may be uninitialized [unbound-name]
+ ERROR sklearn/manifold/_mds.py:194:15-21: `stress` may be uninitialized [unbound-name]
+ ERROR sklearn/model_selection/_split.py:2479:8-15: `n_train` may be uninitialized [unbound-name]
+ ERROR sklearn/model_selection/_split.py:2479:18-24: `n_test` may be uninitialized [unbound-name]
+ ERROR sklearn/model_selection/_validation.py:875:22-32: `params_msg` may be uninitialized [unbound-name]
+ ERROR sklearn/neighbors/_base.py:1251:39-48: `neigh_ind` may be uninitialized [unbound-name]
prefect (https://github.com/PrefectHQ/prefect)
+ ERROR src/integrations/prefect-email/prefect_email/credentials.py:219:16-22: `server` may be uninitialized [unbound-name]
- ERROR src/prefect/cli/block.py:570:31-65: The type of `block_type_json` is unknown because it comes from an error [unknown-from-error]
+ ERROR src/prefect/cli/block.py:570:31-41: `block_type` may be uninitialized [unbound-name]
- ERROR src/prefect/cli/block.py:579:48-58: The type of this argument is unknown because it comes from an error [unknown-from-error]
+ ERROR src/prefect/cli/block.py:579:48-58: `block_type` may be uninitialized [unbound-name]
- ERROR src/prefect/cli/deployment.py:568:25-58: The type of `datetime_local_tz` is unknown because it comes from an error [unknown-from-error]
+ ERROR src/prefect/cli/deployment.py:568:37-57: `scheduled_start_time` may be uninitialized [unbound-name]
+ ERROR src/prefect/flow_runs.py:316:59-75: `run_input_keyset` may be uninitialized [unbound-name]
+ ERROR src/prefect/flow_runs.py:325:51-67: `run_input_keyset` may be uninitialized [unbound-name]
+ ERROR src/prefect/flow_runs.py:473:48-64: `run_input_keyset` may be uninitialized [unbound-name]
+ ERROR src/prefect/flow_runs.py:484:44-60: `run_input_keyset` may be uninitialized [unbound-name]
cwltool (https://github.com/common-workflow-language/cwltool)
+ ERROR cwltool/main.py:406:31-44: `input_basedir` may be uninitialized [unbound-name]
spark (https://github.com/apache/spark)
- ERROR python/pyspark/pandas/groupby.py:357:37-63: Unused `# type: ignore` comment [unused-type-ignore]
+ ERROR python/pyspark/pandas/groupby.py:356:25-30: `order` may be uninitialized [unbound-name]
+ ERROR python/pyspark/pandas/indexing.py:1194:46-61: `index_data_type` may be uninitialized [unbound-name]
- ERROR python/pyspark/pandas/indexing.py:1695:24-34: The type of `stop` is unknown because it comes from an error [unknown-from-error]
+ ERROR python/pyspark/pandas/indexing.py:1695:31-34: `cnt` may be uninitialized [unbound-name]
- ERROR python/pyspark/pandas/indexing.py:1704:25-43: The type of `start` is unknown because it comes from an error [unknown-from-error]
+ ERROR python/pyspark/pandas/indexing.py:1704:35-38: `cnt` may be uninitialized [unbound-name]
+ ERROR python/pyspark/sql/pandas/serializers.py:133:51-59: `start_ns` may be uninitialized [unbound-name]
+ ERROR python/pyspark/tests/upstream/pyarrow/test_pyarrow_array_cast.py:577:21-23: `np` may be uninitialized [unbound-name]
manticore (https://github.com/trailofbits/manticore)
+ ERROR manticore/core/smtlib/constraints.py:213:25-42: `constant_bindings` may be uninitialized [unbound-name]
+ ERROR manticore/platforms/decree.py:494:82-86: `data` may be uninitialized [unbound-name]
cloud-init (https://github.com/canonical/cloud-init)
+ ERROR cloudinit/config/cc_package_update_upgrade_install.py:107:56-72: `reboot_fn_exists` may be uninitialized [unbound-name]
+ ERROR cloudinit/distros/alpine.py:338:13-27: `new_line_parts` may be uninitialized [unbound-name]
+ ERROR cloudinit/distros/alpine.py:473:16-30: `new_line_parts` may be uninitialized [unbound-name]
+ ERROR cloudinit/sources/DataSourceLXD.py:317:37-45: `response` may be uninitialized [unbound-name]
+ ERROR cloudinit/util.py:2782:12-24: `match_devpth` may be uninitialized [unbound-name]
+ ERROR cloudinit/util.py:2782:29-36: `fs_type` may be uninitialized [unbound-name]
+ ERROR cloudinit/util.py:2782:63-76: `mount_options` may be uninitialized [unbound-name]
+ ERROR cloudinit/util.py:2785:12-24: `match_devpth` may be uninitialized [unbound-name]
+ ERROR cloudinit/util.py:2785:29-36: `fs_type` may be uninitialized [unbound-name]
pandera (https://github.com/pandera-dev/pandera)
+ ERROR pandera/api/extensions.py:252:31-33: `pd` may be uninitialized [unbound-name]
+ ERROR pandera/api/extensions.py:254:30-32: `ps` may be uninitialized [unbound-name]
zulip (https://github.com/zulip/zulip)
+ ERROR corporate/lib/stripe.py:5974:34-49: `billing_session` may be uninitialized [unbound-name]
+ ERROR corporate/lib/stripe.py:5980:13-28: `billing_session` may be uninitialized [unbound-name]
+ ERROR zerver/actions/create_user.py:638:28-53: `full_members_system_group` may be uninitialized [unbound-name]
+ ERROR zerver/actions/message_send.py:464:17-50: `wildcard_mentions_notify_user_ids` may be uninitialized [unbound-name]
+ ERROR zerver/actions/message_send.py:468:21-69: `followed_topic_wildcard_mentions_notify_user_ids` may be uninitialized [unbound-name]
+ ERROR zerver/lib/events.py:450:17-34: `realm_groups_data` may be uninitialized [unbound-name]
+ ERROR zerver/lib/events.py:843:44-80: `anonymous_group_membership_data_dict` may be uninitialized [unbound-name]
+ ERROR zerver/lib/events.py:846:51-87: `anonymous_group_membership_data_dict` may be uninitialized [unbound-name]
+ ERROR zerver/lib/events.py:891:44-80: `anonymous_group_membership_data_dict` may be uninitialized [unbound-name]
+ ERROR zerver/lib/events.py:899:24-60: `anonymous_group_membership_data_dict` may be uninitialized [unbound-name]
ibis (https://github.com/ibis-project/ibis)
+ ERROR ibis/backends/duckdb/__init__.py:241:70-75: `table` may be uninitialized [unbound-name]
static-frame (https://github.com/static-frame/static-frame)
+ ERROR static_frame/core/index_hierarchy.py:2035:29-40: `unmatchable` may be uninitialized [unbound-name]
+ ERROR static_frame/core/pivot.py:1078:27-39: `dtype_single` may be uninitialized [unbound-name]
+ ERROR static_frame/core/quilt.py:1194:24-43: `component_is_series` may be uninitialized [unbound-name]
mypy (https://github.com/python/mypy)
+ ERROR mypy/messages.py:3047:22-26: `strs` may be uninitialized [unbound-name]
+ ERROR mypy/messages.py:3049:52-56: `strs` may be uninitialized [unbound-name]
+ ERROR mypy/test/meta/_pytest.py:68:20-24: `proc` may be uninitialized [unbound-name]
hydpy (https://github.com/hydpy-dev/hydpy)
+ ERROR hydpy/models/hland/hland_control.py:776:29-33: `jdxs` may be uninitialized [unbound-name]
pandas (https://github.com/pandas-dev/pandas)
+ ERROR pandas/core/groupby/grouper.py:677:43-50: `na_code` may be uninitialized [unbound-name]
+ ERROR pandas/core/sorting.py:303:46-50: `lift` may be uninitialized [unbound-name]
pytensor (https://github.com/pymc-devs/pytensor)
+ ERROR pytensor/compile/debug/debugmode.py:924:33-42: `out_shape` may be uninitialized [unbound-name]
+ ERROR pytensor/link/c/basic.py:813:40-50: `params_var` may be uninitialized [unbound-name]
+ ERROR pytensor/link/c/cmodule.py:1494:20-27: `version` may be uninitialized [unbound-name]
+ ERROR pytensor/link/numba/dispatch/linalg/decomposition/qr.py:239:17-22: `RWORK` may be uninitialized [unbound-name]
+ ERROR pytensor/link/numba/dispatch/linalg/decomposition/qr.py:697:17-22: `RWORK` may be uninitialized [unbound-name]
+ ERROR pytensor/scalar/basic.py:181:16-18: `x_` may be uninitialized [unbound-name]
+ ERROR pytensor/tensor/elemwise.py:1696:18-26: `acc_type` may be uninitialized [unbound-name]
meson (https://github.com/mesonbuild/meson)
+ ERROR mesonbuild/dependencies/cmake.py:178:12-16: `ret1` may be uninitialized [unbound-name]
+ ERROR mesonbuild/dependencies/cmake.py:182:31-35: `err1` may be uninitialized [unbound-name]
+ ERROR mesonbuild/dependencies/cmake.py:394:12-16: `ret1` may be uninitialized [unbound-name]
+ ERROR mesonbuild/dependencies/cmake.py:398:36-40: `err1` may be uninitialized [unbound-name]
websockets (https://github.com/aaugustin/websockets)
+ ERROR src/websockets/client.py:334:39-47: `response` may be uninitialized [unbound-name]
+ ERROR src/websockets/client.py:336:17-25: `response` may be uninitialized [unbound-name]
+ ERROR src/websockets/server.py:633:32-39: `request` may be uninitialized [unbound-name]
dd-trace-py (https://github.com/DataDog/dd-trace-py)
+ ERROR ddtrace/appsec/_iast/_loader.py:57:66-77: `module_path` may be uninitialized [unbound-name]
core (https://github.com/home-assistant/core)
+ ERROR homeassistant/components/derivative/sensor.py:570:68-82: `new_derivative` may be uninitialized [unbound-name]
+ ERROR homeassistant/components/emulated_hue/hue_api.py:485:48-59: `color_modes` may be uninitialized [unbound-name]
+ ERROR homeassistant/components/incomfort/config_flow.py:208:25-42: `reconfigure_entry` may be uninitialized [unbound-name]
+ ERROR homeassistant/components/mqtt/config_flow.py:4355:21-38: `reconfigure_entry` may be uninitialized [unbound-name]
+ ERROR homeassistant/components/prometheus/__init__.py:1083:12-18: `metric` may be uninitialized [unbound-name]
+ ERROR homeassistant/helpers/frame.py:139:28-32: `path` may be uninitialized [unbound-name]
jinja (https://github.com/pallets/jinja)
+ ERROR src/jinja2/compiler.py:1287:34-53: `iteration_indicator` may be uninitialized [unbound-name]
spack (https://github.com/spack/spack)
+ ERROR lib/spack/spack/ci/__init__.py:1102:26-43: `mounted_repro_dir` may be uninitialized [unbound-name]
+ ERROR lib/spack/spack/cmd/blame.py:300:20-26: `author` may be uninitialized [unbound-name]
+ ERROR lib/spack/spack/cmd/gpg.py:158:49-57: `new_keys` may be uninitialized [unbound-name]
+ ERROR lib/spack/spack/solver/asp.py:1010:31-51: `concretization_stats` may be uninitialized [unbound-name]
xarray (https://github.com/pydata/xarray)
+ ERROR xarray/plot/facetgrid.py:265:13-17: `nrow` may be uninitialized [unbound-name]
+ ERROR xarray/plot/facetgrid.py:266:13-17: `ncol` may be uninitialized [unbound-name]
rich (https://github.com/Textualize/rich)
+ ERROR rich/filesize.py:36:24-28: `unit` may be uninitialized [unbound-name]
+ ERROR rich/filesize.py:49:12-16: `unit` may be uninitialized [unbound-name] |
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.
Fixes #5566.
Problem
If a name is only assigned inside a
forloop, it is unbound after the loop when the iterable is empty. Pyrefly reports this, but stopped reporting it once the loop body contained a conditionalbreak:Cause
After the loop, the fall-through flow and the
breakflow carry the same value index forlast, but with different flow styles:PossiblyUninitialized;breakflow, which just assigned it, marks itOther.merged_flow_infodeduplicated values by index alone, assuming that equal indices always have equal styles. As a result, whichever branch came first decided the style. Thebreakbranches come before the fall-through flow, so the doubt was dropped.Fix
Deduplicate values by (index, style) instead of by index alone. Each distinct style now reaches
FlowStyle::merged, soPossiblyUninitializedsurvives the merge. When two branches share both index and style, termination keys are still combined exactly as before.Changes to existing tests
The same wrong assumption was hiding some repeat diagnostics. After pyrefly reports an unbound name, it treats the name as initialized in that flow so the next use isn't reported. That flow keeps the value index but changes the style, so the old merge sometimes discarded the other branch's style:
test_guarded_initialization_repeated_use: the thirdprint(b)is now also reported. This is a true positive, becausebreally may be unbound there; it is just a repeat of the earlier report.test_exception_not_in_scope: two diagnostics change from "e3/e4is uninitialized" to "may be uninitialized". This now matches the existing expectations for thetry_except_elsecases in the same test. Both are still errors.Testing
test_possibly_unbound_after_loop_with_conditional_breakcovers the issue. It also checks that a loop that definitely runs (for x in [1, 2, 3]) is still not reported.cargo test -p pyrefly --libpasses, excepttest::cycles, which overflows the stack under a debug build onmaintoo.test.py --no-test ...).mypy_primer
This change adds
unbound-nameerrors. I expect most new ones to be true positives (names used after a loop withbreakthat may never run), plus a few repeats of possibly-unbound reports after a branch merge. I'll interpret the mypy_primer differential once CI posts it.