correlated condition analysis for simple guards #3185#3212
correlated condition analysis for simple guards #3185#3212jorenham wants to merge 2 commits intofacebook:mainfrom
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
… expexcted failing ones
|
Diff from mypy_primer, showing the effect of this PR on open source code: pip (https://github.com/pypa/pip)
- ERROR src/pip/_vendor/requests/utils.py:746:16-25: `old_value` may be uninitialized [unbound-name]
openlibrary (https://github.com/internetarchive/openlibrary)
- ERROR openlibrary/plugins/upstream/borrow.py:180:28-39: `ia_itemname` may be uninitialized [unbound-name]
- ERROR openlibrary/plugins/upstream/borrow.py:180:47-54: `s3_keys` may be uninitialized [unbound-name]
cloud-init (https://github.com/canonical/cloud-init)
- ERROR tests/unittests/test_util.py:614:27-35: `confd_fn` may be uninitialized [unbound-name]
egglog-python (https://github.com/egraphs-good/egglog-python)
- ERROR python/egglog/egraph.py:1244:17-24: `egraphs` may be uninitialized [unbound-name]
rotki (https://github.com/rotki/rotki)
- ERROR rotkehlchen/db/drivers/gevent.py:211:117-127: `identifier` may be uninitialized [unbound-name]
- ERROR rotkehlchen/db/drivers/gevent.py:482:98-108: `identifier` may be uninitialized [unbound-name]
- ERROR rotkehlchen/tests/api/test_database.py:55:29-45: `backup2_contents` may be uninitialized [unbound-name]
- ERROR rotkehlchen/tests/api/test_database.py:57:29-45: `backup1_contents` may be uninitialized [unbound-name]
cryptography (https://github.com/pyca/cryptography)
- ERROR src/cryptography/hazmat/primitives/serialization/ssh.py:1091:25-34: `cert_body` may be uninitialized [unbound-name]
- ERROR src/cryptography/hazmat/primitives/serialization/ssh.py:1105:13-18: `nonce` may be uninitialized [unbound-name]
scikit-learn (https://github.com/scikit-learn/scikit-learn)
- ERROR sklearn/ensemble/_gb.py:922:28-40: `y_oob_masked` may be uninitialized [unbound-name]
- ERROR sklearn/ensemble/_gb.py:924:35-59: `sample_weight_oob_masked` may be uninitialized [unbound-name]
- ERROR sklearn/ensemble/_gb.py:926:33-45: `initial_loss` may be uninitialized [unbound-name]
- ERROR sklearn/gaussian_process/_gpr.py:654:36-59: `log_likelihood_gradient` may be uninitialized [unbound-name]
- ERROR sklearn/linear_model/_coordinate_descent.py:182:34-40: `X_mean` may be uninitialized [unbound-name]
- ERROR sklearn/linear_model/_coordinate_descent.py:184:34-40: `X_mean` may be uninitialized [unbound-name]
- ERROR sklearn/linear_model/_huber.py:66:24-33: `intercept` may be uninitialized [unbound-name]
- ERROR sklearn/linear_model/_ridge.py:277:26-28: `sw` may be uninitialized [unbound-name]
- ERROR sklearn/linear_model/_ridge.py:294:27-29: `sw` may be uninitialized [unbound-name]
- ERROR sklearn/linear_model/_ridge.py:741:32-50: `sample_weight_sqrt` may be uninitialized [unbound-name]
- ERROR sklearn/linear_model/_ridge.py:754:32-50: `sample_weight_sqrt` may be uninitialized [unbound-name]
- ERROR sklearn/linear_model/_ridge.py:821:32-50: `sample_weight_sqrt` may be uninitialized [unbound-name]
- ERROR sklearn/linear_model/tests/test_base.py:834:41-50: `intercept` may be uninitialized [unbound-name]
- ERROR sklearn/linear_model/tests/test_base.py:866:41-52: `intercept_0` may be uninitialized [unbound-name]
- ERROR sklearn/linear_model/tests/test_coordinate_descent.py:1294:41-50: `intercept` may be uninitialized [unbound-name]
- ERROR sklearn/linear_model/tests/test_coordinate_descent.py:1326:41-52: `intercept_0` may be uninitialized [unbound-name]
- ERROR sklearn/linear_model/tests/test_coordinate_descent.py:1521:41-50: `intercept` may be uninitialized [unbound-name]
- ERROR sklearn/linear_model/tests/test_ridge.py:2415:41-50: `intercept` may be uninitialized [unbound-name]
- ERROR sklearn/neighbors/_base.py:382:16-26: `neigh_dist` may be uninitialized [unbound-name]
- ERROR sklearn/preprocessing/_data.py:266:19-24: `mean_` may be uninitialized [unbound-name]
- ERROR sklearn/preprocessing/_data.py:283:45-51: `scale_` may be uninitialized [unbound-name]
setuptools (https://github.com/pypa/setuptools)
- ERROR setuptools/_vendor/autocommand/autoasync.py:140:43-50: `new_sig` may be uninitialized [unbound-name]
psycopg (https://github.com/psycopg/psycopg)
- ERROR psycopg/psycopg/waiting.py:450:12-18: `wait_c` may be uninitialized [unbound-name]
mongo-python-driver (https://github.com/mongodb/mongo-python-driver)
- ERROR pymongo/asynchronous/pool.py:292:51-56: `start` may be uninitialized [unbound-name]
- ERROR pymongo/message.py:1142:39-53: `ns_doc_encoded` may be uninitialized [unbound-name]
- ERROR pymongo/synchronous/pool.py:292:51-56: `start` may be uninitialized [unbound-name]
stone (https://github.com/dropbox/stone)
- ERROR stone/backends/python_rsrc/stone_base.py:19:9-15: `typing` may be uninitialized [unbound-name]
websockets (https://github.com/aaugustin/websockets)
- ERROR src/websockets/frames.py:261:37-47: `mask_bytes` may be uninitialized [unbound-name]
- ERROR src/websockets/frames.py:327:42-52: `mask_bytes` may be uninitialized [unbound-name]
- ERROR src/websockets/legacy/framing.py:102:37-46: `mask_bits` may be uninitialized [unbound-name]
zulip (https://github.com/zulip/zulip)
- ERROR corporate/tests/test_stripe.py:731:13-23: `last_event` may be uninitialized [unbound-name]
- ERROR zerver/lib/import_realm.py:1280:17-41: `filename_to_has_original` may be uninitialized [unbound-name]
- ERROR zerver/lib/narrow.py:1323:16-28: `before_query` may be uninitialized [unbound-name]
- ERROR zerver/lib/narrow.py:1325:16-27: `after_query` may be uninitialized [unbound-name]
static-frame (https://github.com/static-frame/static-frame)
- ERROR static_frame/core/db_util.py:576:32-44: `query_create` may be uninitialized [unbound-name]
- ERROR static_frame/core/frame.py:1013:29-38: `fields_dc` may be uninitialized [unbound-name]
- ERROR static_frame/core/frame.py:6147:68-77: `drop_mask` may be uninitialized [unbound-name]
- ERROR static_frame/core/frame.py:6149:62-71: `drop_mask` may be uninitialized [unbound-name]
- ERROR static_frame/core/frame.py:9580:36-49: `columns_names` may be uninitialized [unbound-name]
- ERROR static_frame/core/type_blocks.py:175:48-57: `drop_mask` may be uninitialized [unbound-name]
- ERROR static_frame/core/type_blocks.py:180:45-54: `drop_mask` may be uninitialized [unbound-name]
- ERROR static_frame/core/type_blocks.py:271:48-57: `drop_mask` may be uninitialized [unbound-name]
- ERROR static_frame/core/type_blocks.py:276:45-54: `drop_mask` may be uninitialized [unbound-name]
- ERROR static_frame/core/util.py:1554:27-38: `is_not_none` may be uninitialized [unbound-name]
- ERROR static_frame/core/util.py:1563:20-31: `is_not_none` may be uninitialized [unbound-name]
- ERROR static_frame/core/util.py:3142:40-44: `cols` may be uninitialized [unbound-name]
- ERROR static_frame/core/util.py:3149:40-44: `cols` may be uninitialized [unbound-name]
- ERROR static_frame/core/util.py:3177:48-52: `cols` may be uninitialized [unbound-name]
- ERROR static_frame/core/util.py:3210:61-65: `cols` may be uninitialized [unbound-name]
pandas (https://github.com/pandas-dev/pandas)
- ERROR pandas/core/common.py:603:32-41: `old_value` may be uninitialized [unbound-name]
- ERROR pandas/tests/reshape/test_get_dummies.py:112:72-82: `fill_value` may be uninitialized [unbound-name]
mypy (https://github.com/python/mypy)
- ERROR mypy/test/testpep561.py:159:23-30: `program` may be uninitialized [unbound-name]
- ERROR mypyc/codegen/emitclass.py:419:64-82: `shadow_vtable_name` may be uninitialized [unbound-name]
- ERROR mypyc/irbuild/ll_builder.py:1093:28-32: `skip` may be uninitialized [unbound-name]
- ERROR mypyc/irbuild/ll_builder.py:2787:37-48: `false_block` may be uninitialized [unbound-name]
meson (https://github.com/mesonbuild/meson)
- ERROR mesonbuild/backend/ninjabackend.py:717:20-52: `captured_compile_args_per_target` may be uninitialized [unbound-name]
- ERROR mesonbuild/modules/_qt.py:760:38-45: `results` may be uninitialized [unbound-name]
- ERROR unittests/allplatformstests.py:5462:27-29: `cc` may be uninitialized [unbound-name]
core (https://github.com/home-assistant/core)
- ERROR homeassistant/components/bayesian/config_flow.py:557:25-34: `sub_entry` may be uninitialized [unbound-name]
- ERROR homeassistant/components/bayesian/config_flow.py:572:70-79: `sub_entry` may be uninitialized [unbound-name]
- ERROR homeassistant/components/opnsense/__init__.py:118:50-65: `interfaces_resp` may be uninitialized [unbound-name]
- ERROR homeassistant/components/recorder/util.py:126:49-60: `timer_start` may be uninitialized [unbound-name]
- ERROR homeassistant/components/tplink/config_flow.py:459:27-29: `un` may be uninitialized [unbound-name]
- ERROR homeassistant/components/tplink/config_flow.py:459:34-36: `pw` may be uninitialized [unbound-name]
- ERROR homeassistant/components/tplink/entity.py:678:45-64: `has_parent_entities` may be uninitialized [unbound-name]
- ERROR homeassistant/helpers/entity.py:1375:17-28: `update_warn` may be uninitialized [unbound-name]
paasta (https://github.com/yelp/paasta)
- ERROR paasta_tools/utils.py:2893:25-32: `service` may be uninitialized [unbound-name]
- ERROR paasta_tools/utils.py:2895:27-36: `component` may be uninitialized [unbound-name]
- ERROR paasta_tools/utils.py:2896:23-31: `loglevel` may be uninitialized [unbound-name]
- ERROR paasta_tools/utils.py:2897:25-32: `cluster` may be uninitialized [unbound-name]
- ERROR paasta_tools/utils.py:2898:26-34: `instance` may be uninitialized [unbound-name]
- ERROR paasta_tools/utils.py:2910:13-22: `proctimer` may be uninitialized [unbound-name]
spack (https://github.com/spack/spack)
- ERROR lib/spack/spack/config.py:728:34-42: `comments` may be uninitialized [unbound-name]
kornia (https://github.com/kornia/kornia)
- ERROR kornia/feature/disk/disk.py:117:39-40: `h` may be uninitialized [unbound-name]
- ERROR kornia/feature/disk/disk.py:117:43-44: `w` may be uninitialized [unbound-name]
spark (https://github.com/apache/spark)
- ERROR python/pyspark/pandas/groupby.py:350:56-61: `order` may be uninitialized [unbound-name]
- ERROR python/pyspark/pandas/groupby.py:351:75-82: `columns` may be uninitialized [unbound-name]
- ERROR python/pyspark/pandas/indexes/base.py:1597:57-69: `sequence_col` may be uninitialized [unbound-name]
- ERROR python/pyspark/pandas/tests/indexes/test_indexing_loc.py:263:32-38: `psser1` may be uninitialized [unbound-name]
- ERROR python/pyspark/pandas/tests/indexes/test_indexing_loc.py:263:40-45: `pser1` may be uninitialized [unbound-name]
- ERROR python/pyspark/pandas/tests/indexes/test_indexing_loc.py:264:32-38: `psser2` may be uninitialized [unbound-name]
- ERROR python/pyspark/pandas/tests/indexes/test_indexing_loc.py:264:40-45: `pser2` may be uninitialized [unbound-name]
- ERROR python/pyspark/pandas/tests/indexes/test_indexing_loc.py:332:32-38: `psser1` may be uninitialized [unbound-name]
- ERROR python/pyspark/pandas/tests/indexes/test_indexing_loc.py:332:40-45: `pser1` may be uninitialized [unbound-name]
- ERROR python/pyspark/pandas/tests/indexes/test_indexing_loc.py:333:32-38: `psser2` may be uninitialized [unbound-name]
- ERROR python/pyspark/pandas/tests/indexes/test_indexing_loc.py:333:40-45: `pser2` may be uninitialized [unbound-name]
prefect (https://github.com/PrefectHQ/prefect)
- ERROR src/prefect/cli/deployment.py:750:48-70: `parsed_interval_anchor` may be uninitialized [unbound-name]
- ERROR src/prefect/server/api/events.py:154:21-35: `backfilled_ids` may be uninitialized [unbound-name]
|
Primer Diff Classification✅ 23 improvement(s) | 23 project(s) total | -99 errors 23 improvement(s) across pip, openlibrary, cloud-init, egglog-python, rotki, cryptography, scikit-learn, setuptools, psycopg, mongo-python-driver, stone, websockets, zulip, static-frame, pandas, mypy, meson, core, paasta, spack, kornia, spark, prefect.
Detailed analysis✅ Improvement (23)pip (-1)
openlibrary (-2)
This directly fixes the false positives: cloud-init (-1)
egglog-python (-1)
rotki (-4)
cryptography (-2)
scikit-learn (-21)
setuptools (-1)
psycopg (-1)
mongo-python-driver (-3)
stone (-1)
websockets (-3)
This directly fixes the false positive where zulip (-4)
static-frame (-15)
pandas (-2)
Per-category reasoning:
For For
mypy (-4)
This directly eliminates the false positive meson (-3)
core (-8)
paasta (-6)
spack (-1)
kornia (-2)
spark (-11)
prefect (-2)
For For
Was this helpful? React with 👍 or 👎 Classification by primer-classifier (23 LLM) |
Summary
I had Claude Opus 4.7 take a stab at #3185, and to my (untrained) eyes it actually looks pretty decent. Since I'm not very familiar with this bit of the codebase, I opened it as a draft, with the intention of wanting to see mypy primer has to say about it, and to see if it's actually as easy
Fixes #3185
Test Plan
Added some tests, and
the failing test from 54cfb04 now passes.