1313# Licensed under the Eiffel Forum License 2.
1414from __future__ import generator_stop
1515
16+ from collections import OrderedDict
1617import functools
1718import itertools
1819import re
20+ from typing import Dict
1921
2022
2123def _optional (parser , default = None ):
@@ -97,7 +99,7 @@ def _parse_prefix(value):
9799 if len (modes ) != len (prefixes ):
98100 raise ValueError ('Mode list does not match for PREFIX: %r' % value )
99101
100- return tuple (sorted ( zip (modes , prefixes ) ))
102+ return tuple (zip (modes , prefixes ))
101103
102104
103105ISUPPORT_PARSERS = {
@@ -328,7 +330,7 @@ def MAXLIST(self):
328330 return dict (self ['MAXLIST' ])
329331
330332 @property
331- def PREFIX (self ):
333+ def PREFIX (self ) -> Dict [ str , str ] :
332334 """Expose ``PREFIX`` as a dict, if advertised by the server.
333335
334336 This exposes information about the modes and nick prefixes used for
@@ -343,6 +345,8 @@ def PREFIX(self):
343345 'v': '+',
344346 }
345347
348+ Entries are in order of descending privilege.
349+
346350 This attribute is not available if the server does not provide the
347351 right information, and accessing it will raise an
348352 :exc:`AttributeError`.
@@ -355,7 +359,10 @@ def PREFIX(self):
355359 if 'PREFIX' not in self :
356360 raise AttributeError ('PREFIX' )
357361
358- return dict (self ['PREFIX' ])
362+ # This can use a normal dict once we drop python 3.6, as 3.7 promises
363+ # `dict` maintains insertion order. Since `OrderedDict` subclasses
364+ # `dict`, we'll not promise to always return the former.
365+ return OrderedDict (self ['PREFIX' ])
359366
360367 @property
361368 def TARGMAX (self ):
0 commit comments