-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
Warn when concrete_descendents clobbers classes #1035
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1035 +/- ##
==========================================
+ Coverage 87.26% 87.28% +0.01%
==========================================
Files 9 9
Lines 4939 4945 +6
==========================================
+ Hits 4310 4316 +6
Misses 629 629 ☔ View full report in Codecov by Sentry. |
@jlstevens the PyPy tests have failed which raised an interesting question. I feel like if we want to fix this for good, we need to update
What do you think? class ClassSelector(Parameter):
...
def get_range(self):
"""
Return the possible types for this parameter's value.
(I.e. return `{name: <class>}` for all classes that are
concrete_descendents() of `self.class_`.)
Only classes from modules that have been imported are added
(see concrete_descendents()).
"""
classes = self.class_ if isinstance(self.class_, tuple) else (self.class_,)
all_classes = {}
for cls in classes:
all_classes.update(concrete_descendents(cls))
d = OrderedDict((name, class_) for name,class_ in all_classes.items())
if self.allow_None:
d['None'] = None
return d EDIT: This is following a discussion started here #1027 (comment) |
I don't know the cleanest way to get out of this mess, but presumably it's also worth (briefly) considering a multidict, which would preserve the interface but allow duplicate keys? That might well cause other problems later, of course, if someone tries to use the multidict as a regular dict. |
True, I didn't consider multidict until now. I'll chat with Jean-Luc this week more about all this! |
No description provided.