Skip to content

fix feature: Track relationships between narrows of different variables #997#4008

Open
asukaminato0721 wants to merge 1 commit into
facebook:mainfrom
asukaminato0721:997
Open

fix feature: Track relationships between narrows of different variables #997#4008
asukaminato0721 wants to merge 1 commit into
facebook:mainfrom
asukaminato0721:997

Conversation

@asukaminato0721

Copy link
Copy Markdown
Contributor

Summary

Fixes #997

This is an experiment.

Added guarded flow facts so if b == "bar": x = 3 records that x has the branch value when the same predicate is active again.

Applied matching guarded facts whenever narrowing ops are bound, recorded those facts from if branches and invalidated them on predicate/target reassignment.

Test Plan

Added regression test coverage for repeated predicates and predicate reassignment invalidation.

@meta-cla meta-cla Bot added the cla signed label Jul 1, 2026
@github-actions github-actions Bot added the size/l label Jul 1, 2026
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

Diff from mypy_primer, showing the effect of this PR on open source code:

dulwich (https://github.com/dulwich/dulwich)
+ ERROR dulwich/porcelain/subtree.py:324:34-49: Object of class `NoneType` has no attribute `id` [missing-attribute]

spark (https://github.com/apache/spark)
- ERROR python/pyspark/sql/tests/coercion/test_pandas_udf_input_type.py:73:21-23: `np` may be uninitialized [unbound-name]
- ERROR python/pyspark/sql/tests/coercion/test_pandas_udf_return_type.py:73:21-23: `np` may be uninitialized [unbound-name]
- ERROR python/pyspark/sql/tests/coercion/test_python_udf_input_type.py:73:21-23: `np` may be uninitialized [unbound-name]
- ERROR python/pyspark/sql/tests/coercion/test_python_udf_return_type.py:77:21-23: `np` may be uninitialized [unbound-name]
- ERROR python/pyspark/tests/upstream/pyarrow/test_pyarrow_array_cast.py:226:21-23: `np` may be uninitialized [unbound-name]

schemathesis (https://github.com/schemathesis/schemathesis)
+ ERROR src/schemathesis/openapi/checks.py:144:53-78: `in` is not supported between `str` and `Unresolvable` [not-iterable]
+ ERROR src/schemathesis/openapi/checks.py:144:53-78: `in` is not supported between `str` and `object` [not-iterable]
+ ERROR src/schemathesis/openapi/checks.py:146:38-61: Cannot index into `Unresolvable` [bad-index]
+ ERROR src/schemathesis/openapi/checks.py:146:38-61: Cannot index into `object` [bad-index]
+ ERROR src/schemathesis/openapi/checks.py:147:41-53: Object of class `Unresolvable` has no attribute `items`
+ Object of class `object` has no attribute `items` [missing-attribute]
+ ERROR src/schemathesis/openapi/checks.py:152:31-37: Argument `Unresolvable | bool | dict[str, Any] | dict[str, Unknown] | dict[Unknown, Unknown] | object` is not assignable to parameter `schema` with type `bool | dict[str, Any] | list[JsonSchema]` in function `schemathesis.core.jsonschema.bundler.unbundle` [bad-argument-type]

zulip (https://github.com/zulip/zulip)
+ ERROR zerver/views/auth.py:1013:41-50: Object of class `NoneType` has no attribute `url` [missing-attribute]

mypy (https://github.com/python/mypy)
- ERROR mypy/stubgenc.py:472:38-44: `output` may be uninitialized [unbound-name]
- ERROR mypy/stubtest.py:1288:9-17: `stub_sig` may be uninitialized [unbound-name]
- ERROR mypy/stubtest.py:1289:9-20: `runtime_sig` may be uninitialized [unbound-name]

sphinx (https://github.com/sphinx-doc/sphinx)
- ERROR sphinx/domains/cpp/__init__.py:1178:28-32: `decl` may be uninitialized [unbound-name]
+ ERROR sphinx/domains/cpp/__init__.py:1179:19-28: Object of class `NoneType` has no attribute `docname` [missing-attribute]

parso (https://github.com/davidhalter/parso)
- ERROR parso/python/tokenize.py:527:44-49: `token` may be uninitialized [unbound-name]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

1 participant