Skip to content

Commit d8be8e2

Browse files
committed
ChoiceSet cleanup
1 parent 1902ecb commit d8be8e2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

netbox/utilities/choices.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,18 @@ def __new__(mcs, name, bases, attrs):
3434
return super().__new__(mcs, name, bases, attrs)
3535

3636
def __call__(cls, *args, **kwargs):
37-
# Django will check if a 'choices' value is callable, and if so assume that it returns an iterable
37+
# django-filters will check if a 'choices' value is callable, and if so assume that it returns an iterable
3838
return getattr(cls, '_choices', ())
3939

4040
def __iter__(cls):
41-
choices = getattr(cls, '_choices', ())
42-
return iter(choices)
41+
return iter(getattr(cls, '_choices', ()))
4342

4443

4544
class ChoiceSet(metaclass=ChoiceSetMeta):
46-
45+
"""
46+
Holds an interable of choice tuples suitable for passing to a Django model or form field. Choices can be defined
47+
statically within the class as CHOICES and/or gleaned from the FIELD_CHOICES configuration parameter.
48+
"""
4749
CHOICES = list()
4850

4951
@classmethod

0 commit comments

Comments
 (0)