Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use parameter definition order for Python 3.6+ #238

Merged
merged 4 commits into from
Feb 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions panel/param.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from __future__ import absolute_import, division, unicode_literals

import os
import sys
import json
import types
import inspect
Expand Down Expand Up @@ -357,8 +358,11 @@ def _get_widgets(self):
filtered = [(k,p) for (k,p) in sorted_precedence
if ((p.precedence is None) or (p.precedence >= self.display_threshold))]
groups = itertools.groupby(filtered, key=key_fn)
sorted_groups = [sorted(grp) for (k,grp) in groups]
ordered_params = [el[0] for group in sorted_groups for el in group]
# Params preserve definition order in Python 3.6+
dict_ordered_py3 = (sys.version_info.major == 3 and sys.version_info.minor >= 6)
dict_ordered = dict_ordered_py3 or (sys.version_info.major > 3)
ordered_groups = [list(grp) if dict_ordered else sorted(grp) for (k,grp) in groups]
ordered_params = [el[0] for group in ordered_groups for el in group]
jbednar marked this conversation as resolved.
Show resolved Hide resolved

# Format name specially
ordered_params.pop(ordered_params.index('name'))
Expand Down