File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 44
44
from pprint36 import PrettyPrinter
45
45
from pprint36 ._pprint import _safe_key # type: ignore
46
46
47
+ supports_sort_dicts = True
48
+
47
49
except ImportError :
48
50
49
51
# stdlib
50
52
from pprint import PrettyPrinter , _safe_key # type: ignore
51
53
54
+ supports_sort_dicts = sys .version_info >= (3 , 8 )
55
+
52
56
__all__ = ["FancyPrinter" , "simple_repr" ]
53
57
54
58
@@ -63,7 +67,8 @@ class FancyPrinter(PrettyPrinter):
63
67
output stream available at construction will be used.
64
68
:param compact: If :py:obj:`True`, several items will be combined in one line.
65
69
:param sort_dicts: If :py:obj:`True`, dict keys are sorted.
66
- Only takes effect on Python 3.8 and later, or if ``pprint36`` is installed.
70
+ Only takes effect on Python 3.8 and later,
71
+ or if `pprint36 <https://pypi.org/project/pprint36/>`_ is installed.
67
72
"""
68
73
69
74
def __init__ (
@@ -76,13 +81,14 @@ def __init__(
76
81
compact : bool = False ,
77
82
sort_dicts : bool = True ,
78
83
):
79
- if sys . version_info < ( 3 , 8 ) :
84
+ if supports_sort_dicts :
80
85
super ().__init__ (
81
86
indent = indent ,
82
87
width = width ,
83
88
depth = depth ,
84
89
stream = stream ,
85
90
compact = compact ,
91
+ sort_dicts = sort_dicts ,
86
92
)
87
93
else :
88
94
super ().__init__ (
@@ -91,7 +97,6 @@ def __init__(
91
97
depth = depth ,
92
98
stream = stream ,
93
99
compact = compact ,
94
- sort_dicts = sort_dicts ,
95
100
)
96
101
97
102
_dispatch : MutableMapping [Callable , Callable ]
You can’t perform that action at this time.
0 commit comments