Repository navigation
Preserve missing local definitions when other branches end in expressions - #5323
Closed
asukaminato0721 wants to merge 1 commit into
Closed
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 D126824523. (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: +53 new errors, -2 fixed errors
By preset: +53/-0 (default), +53/-0 (strict)
Projects with changes (24):
psycopg: +6 -0
apprise: +1 -0
pycryptodome: +1 -0
black: +1 -0
openlibrary: +2 -1
isort: +1 -0
jax: +1 -0
scikit-learn: +3 -0
prefect: +1 -0
scikit-build-core: +1 -0
freqtrade: +2 -0
manticore: +3 -0
cloud-init: +4 -0
zulip: +6 -0
static-frame: +1 -0
mypy: +1 -0
pandas: +5 -0
meson: +1 -0
pytensor: +1 -0
sphinx: +2 -0
core: +6 -1
spack: +1 -0
xarray: +1 -0
optuna: +1 -0
============================================================
FULL DIFF DETAILS
------------------------------------------------------------
psycopg (https://github.com/psycopg/psycopg)
+ ERROR tests/test_connection.py:804:40-45: `value` may be uninitialized [unbound-name]
+ ERROR tests/test_connection.py:819:40-45: `value` may be uninitialized [unbound-name]
+ ERROR tests/test_connection_async.py:819:40-45: `value` may be uninitialized [unbound-name]
+ ERROR tests/test_connection_async.py:836:40-45: `value` may be uninitialized [unbound-name]
+ ERROR tests/test_transaction.py:613:16-19: `tx3` may be uninitialized [unbound-name]
+ ERROR tests/test_transaction_async.py:620:16-19: `tx3` may be uninitialized [unbound-name]
apprise (https://github.com/caronc/apprise)
+ ERROR apprise/plugins/pushsafer.py:711:59-67: `filename` may be uninitialized [unbound-name]
pycryptodome (https://github.com/Legrandin/pycryptodome)
+ ERROR lib/Crypto/IO/_PBES.py:693:46-66: `hmac_hash_module_oid` may be uninitialized [unbound-name]
black (https://github.com/psf/black)
+ ERROR src/blib2to3/pgen2/driver.py:75:20-25: `token` may be uninitialized [unbound-name]
openlibrary (https://github.com/internetarchive/openlibrary)
- ERROR openlibrary/core/lending.py:205:16-57: The type of `data` is unknown because it comes from an error [unknown-from-error]
+ ERROR openlibrary/core/lending.py:205:16-24: `response` may be uninitialized [unbound-name]
+ ERROR openlibrary/coverstore/archive.py:408:32-36: `item` may be uninitialized [unbound-name]
isort (https://github.com/pycqa/isort)
+ ERROR isort/api.py:202:33-45: `file_content` may be uninitialized [unbound-name]
jax (https://github.com/google/jax)
+ ERROR jax/_src/lax/control_flow/conditionals.py:755:42-50: `inst_out` may be uninitialized [unbound-name]
scikit-learn (https://github.com/scikit-learn/scikit-learn)
+ ERROR sklearn/gaussian_process/kernels.py:1899:77-81: `base` may be uninitialized [unbound-name]
+ ERROR sklearn/metrics/_plot/precision_recall_curve.py:914:23-33: `pos_label_` may be uninitialized [unbound-name]
+ ERROR sklearn/metrics/_plot/roc_curve.py:735:23-33: `pos_label_` may be uninitialized [unbound-name]
prefect (https://github.com/PrefectHQ/prefect)
+ ERROR src/integrations/prefect-gcp/prefect_gcp/workers/vertex.py:664:16-23: `job_run` may be uninitialized [unbound-name]
scikit-build-core (https://github.com/scikit-build/scikit-build-core)
+ ERROR src/scikit_build_core/build/wheel.py:523:13-17: `path` may be uninitialized [unbound-name]
freqtrade (https://github.com/freqtrade/freqtrade)
+ ERROR freqtrade/exchange/binance_public_data.py:94:38-43: `start` may be uninitialized [unbound-name]
+ ERROR freqtrade/exchange/binance_public_data.py:94:61-64: `end` may be uninitialized [unbound-name]
manticore (https://github.com/trailofbits/manticore)
+ ERROR tests/auto_generators/make_VMTests.py:217:57-68: `blockheader` may be uninitialized [unbound-name]
+ ERROR tests/ethereum/test_general.py:1020:49-66: `symbolic_address1` may be uninitialized [unbound-name]
+ ERROR tests/ethereum/test_general.py:1021:49-66: `symbolic_address2` may be uninitialized [unbound-name]
cloud-init (https://github.com/canonical/cloud-init)
+ ERROR cloudinit/net/freebsd.py:43:51-61: `net_config` may be uninitialized [unbound-name]
+ ERROR tests/unittests/config/test_cc_ntp.py:542:47-50: `cfg` may be uninitialized [unbound-name]
+ ERROR tests/unittests/config/test_cc_ntp.py:561:51-54: `cfg` may be uninitialized [unbound-name]
+ ERROR tests/unittests/config/test_cc_ntp.py:579:51-54: `cfg` may be uninitialized [unbound-name]
zulip (https://github.com/zulip/zulip)
+ ERROR zerver/lib/cache.py:118:12-18: `prefix` may be uninitialized [unbound-name]
+ ERROR zerver/tests/test_markdown.py:2604:26-42: `rendering_result` may be uninitialized [unbound-name]
+ ERROR zerver/tests/test_push_notifications.py:1233:9-18: `time_sent` may be uninitialized [unbound-name]
+ ERROR zerver/tests/test_push_notifications.py:1245:13-25: `remote_realm` may be uninitialized [unbound-name]
+ ERROR zerver/tests/test_push_notifications.py:1282:9-21: `remote_realm` may be uninitialized [unbound-name]
+ ERROR zilencer/management/commands/render_messages.py:21:43-49: `msg_id` may be uninitialized [unbound-name]
static-frame (https://github.com/static-frame/static-frame)
+ ERROR static_frame/test/unit/test_container.py:15:13-14: `c` may be uninitialized [unbound-name]
mypy (https://github.com/python/mypy)
+ ERROR mypy/semanal_main.py:173:5-10: `state` may be uninitialized [unbound-name]
pandas (https://github.com/pandas-dev/pandas)
+ ERROR pandas/io/formats/csvs.py:315:30-38: `col_line` may be uninitialized [unbound-name]
+ ERROR pandas/io/formats/style_render.py:1013:28-42: `row_body_cells` may be uninitialized [unbound-name]
+ ERROR pandas/io/parsers/python_parser.py:1343:29-41: `len_new_rows` may be uninitialized [unbound-name]
+ ERROR pandas/io/pytables.py:4170:64-70: `_start` may be uninitialized [unbound-name]
+ ERROR pandas/io/pytables.py:4170:77-82: `_stop` may be uninitialized [unbound-name]
meson (https://github.com/mesonbuild/meson)
+ ERROR mesonbuild/interpreterbase/interpreterbase.py:743:27-38: `prev_subdir` may be uninitialized [unbound-name]
pytensor (https://github.com/pymc-devs/pytensor)
+ ERROR pytensor/d3viz/formatting.py:225:69-76: `vparams` may be uninitialized [unbound-name]
sphinx (https://github.com/sphinx-doc/sphinx)
+ ERROR sphinx/ext/autodoc/importer.py:286:38-46: `qualname` may be uninitialized [unbound-name]
+ ERROR sphinx/ext/autodoc/importer.py:298:30-38: `qualname` may be uninitialized [unbound-name]
core (https://github.com/home-assistant/core)
- ERROR homeassistant/components/aws_s3/__init__.py:69:9-22: The type of this argument is unknown because it comes from an error [unknown-from-error]
+ ERROR homeassistant/components/aws_s3/__init__.py:69:16-22: `client` may be uninitialized [unbound-name]
+ ERROR homeassistant/components/cloudflare_r2/__init__.py:72:26-32: `client` may be uninitialized [unbound-name]
+ ERROR homeassistant/components/knx/config_flow.py:506:36-44: `_host_ip` may be uninitialized [unbound-name]
+ ERROR homeassistant/components/knx/config_flow.py:525:26-31: `_host` may be uninitialized [unbound-name]
+ ERROR homeassistant/components/sql/config_flow.py:185:31-52: `db_url_for_validation` may be uninitialized [unbound-name]
+ ERROR homeassistant/helpers/intent.py:1228:35-42: `service` may be uninitialized [unbound-name]
spack (https://github.com/spack/spack)
+ ERROR lib/spack/spack/test/util/filesystem.py:357:32-38: `backup` may be uninitialized [unbound-name]
xarray (https://github.com/pydata/xarray)
+ ERROR xarray/structure/concat.py:920:47-51: `name` may be uninitialized [unbound-name]
optuna (https://github.com/optuna/optuna)
+ ERROR tests/samplers_tests/tpe_tests/test_sampler.py:395:59-64: `trial` may be uninitialized [unbound-name] |
connernilsen
approved these changes
Oct 23, 2026
connernilsen
left a comment
Contributor
There was a problem hiding this comment.
Looks good, thanks for splitting this out!
Contributor
|
This pull request has been merged in f95c8d9. |
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
A trailing expression in a
forbody can hide an uninitialized local when the iterable is empty. For example,for x in xs: y = x; time.sleep(1)can leaveyundefined, but the expression incorrectly supplies termination evidence for the zero-iteration path.Only count termination keys from branches that lack the variable. This also reports skipped
elifwalrus assignments and preserves the definite-uninitialized status of deleted exception targets.This changes the default-enabled
unbound-namediagnostic. It is independent of the attribute initialization check in #4326.Test Plan