File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import itertools
4
4
import fnmatch
5
+ import sys
5
6
from contextlib import contextmanager
6
7
7
8
from typing import (
@@ -4497,6 +4498,14 @@ class Color(Enum):
4497
4498
if not isinstance (symbol .node , Var ):
4498
4499
continue
4499
4500
new_items .append (LiteralType (name , typ ))
4501
+ # SymbolTables are really just dicts, and dicts are guaranteed to preserve
4502
+ # insertion order only starting with Python 3.7. So, we sort these for older
4503
+ # versions of Python to help make tests deterministic.
4504
+ #
4505
+ # We could probably skip the sort for Python 3.6 since people probably run mypy
4506
+ # only using CPython, but we might as well for the sake of full correctness.
4507
+ if sys .version_info < (3 , 7 ):
4508
+ new_items .sort (key = lambda lit : lit .value )
4500
4509
return UnionType .make_simplified_union (new_items )
4501
4510
else :
4502
4511
return typ
You can’t perform that action at this time.
0 commit comments