[ty] filter out pre-loop bindings from loop headers#23536
[ty] filter out pre-loop bindings from loop headers#23536oconnor663 wants to merge 1 commit intomainfrom
Conversation
Typing conformance resultsNo changes detected ✅ |
|
Memory usage reportSummary
Significant changesClick to expand detailed breakdowntrio
flake8
sphinx
prefect
|
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-await |
0 | 40 | 0 |
invalid-assignment |
0 | 1 | 0 |
invalid-return-type |
0 | 1 | 0 |
unsupported-operator |
0 | 0 | 1 |
| Total | 0 | 42 | 1 |
eab1bb6 to
495557c
Compare
|
Rebased and applied the cleanup described here. |
|
I think the two ecosystem changes are worth looking into. It took me a while to distill this MRE out of alerta, so I'm posting it here in case it's useful. It produces one additional diagnostic on class Alert: ...
def f(*args, **kwargs):
pass
def some_condition(*args, **kwargs) -> bool:
return False
def process_action(alert: Alert, action: str):
updated = None
while some_condition(alert):
if some_condition(1):
updated = f(alert, action)
elif some_condition(2):
updated = f(alert, action)
if isinstance(updated, Alert):
updated = updated, action, 1
if isinstance(updated, tuple):
if len(updated) == 3:
alert, action, timeout = updated
elif len(updated) == 2:
alert, action = updatedIt would be good to understand if that diagnostic should go away. And if that example is not strange enough, the diagnostic change in manticore is even weirder: - manticore/core/smtlib/visitors.py:641:58: error[unsupported-operator] Operator `-` is not supported between objects of type `None | Unknown` and `None | Unknown`
+ manticore/core/smtlib/visitors.py:641:58: error[unsupported-operator] Operator `-` is not supported between two objects of type `None | Unknown` |
sharkdp
left a comment
There was a problem hiding this comment.
Thank you — the change sounds very plausible and the implementation looks good. I can certainly imagine that this solves some bugs as well. It might therefore be interesting to understand the ecosystem changes better. Maybe there is a useful regression test that we could add?
If those cases seem too exotic though, I'm definitely in favor of merging this, even without a deep analysis. This definitely seems more correct.
Reading through @mtshiba's #23520 (specifically
if def != definitionhere) made it clear that the way I included pre-loop bindings in loop headers in #22794 is kind of gross. Apart from being fully redundant (loop headers don't shadow pre-existing bindings), it also means that loop headers tracks themselves, which presumably creates pointless cycles that need to be resolved. Since definition IDs are issued in source code order, it's relatively easy to filter out all the definitions that existed before the loop began, including the loop headers. Anecdotally this seems to give a ~10% speedup inisort, which is the repo that motivated #23520. I'll be curious to see if the ecosystem report shows changed diagnostics, but I'm not sure it will.Before landing this: