facebook / pyre-check

Performant type-checking for python.
https://pyre-check.org/
MIT License
6.8k stars 434 forks source link

Fix nondeterministic test by using `dict.fromkeys ~= orderedset` #814

Closed stroxler closed 8 months ago

stroxler commented 8 months ago

Summary: For a number of weeks now I've been frustrated by github test failure notifications. I dug into the root cause for BE day, and it is that we are using list(set(_)) to deduplicate two lists of references in the find-references logic.

This is fine and correct, but also nondeterministic because set ordering isn't fixed. There's no ordered set in the python standard library, and it's not worth adding a dependency to get one. Instead, the standard trick to work around this is to use a dict of None so the keys act like a set, which solves the problem because in 3.7+ dict keys are ordered.

Differential Revision: D52662624

facebook-github-bot commented 8 months ago

This pull request was exported from Phabricator. Differential Revision: D52662624

facebook-github-bot commented 8 months ago

This pull request was exported from Phabricator. Differential Revision: D52662624

facebook-github-bot commented 8 months ago

This pull request was exported from Phabricator. Differential Revision: D52662624

facebook-github-bot commented 8 months ago

This pull request has been merged in facebook/pyre-check@f5a1d8e51815d85fb5857e6bc5187f19e54855fd.