Commit graph

20 commits

Author SHA1 Message Date
Maarten ter Huurne
713a3fec88 Make type aliases compatible with old Python versions 2024-06-13 12:02:05 +02:00
Maarten ter Huurne
2b0b4827a5 Annotate the choices module
The `Choices` constructor actually only accepts lists and tuples, not
arbitrary sequences. However, using `list` in the annotation opens
a can of worms related to type variance.
2024-06-13 12:02:05 +02:00
Maarten ter Huurne
0043fedf46 Enable postponed evaluation of annotations for all source modules
This allows using the latest annotation syntax supported by the type
checker regardless of the runtime Python version.
2024-06-13 12:02:05 +02:00
Adam Dobrawy
ffa1a85dc7 Modernize Python syntax, add Python 3.8 (#398)
* Modernize Python syntax, add Python 3.8

* Update Python version & dist in TravisCI

* Add postgresql as addon

* Switch to psycopg2-binary

* Drop django.utils.six
2019-11-14 22:50:04 +06:00
Hasan Ramezani
aa94194dbc Drop Python 2 support. (#394) 2019-09-30 14:08:52 +06:00
asday
383740e8ab Added Choices().subset(). 2019-08-19 22:33:08 +01:00
Éric Araujo
764b7ea78d Add support for reverse iteration of Choices (#314) 2018-12-08 11:47:54 +06:00
Lucas Wiman
0859508a64 Fix E123 closing bracket does not match indentation of opening bracket's line 2018-07-02 12:57:14 -07:00
Lucas Wiman
654e13235e Fix E303 too many blank lines. 2018-07-02 11:47:19 -07:00
Carl Meyer
3211c92a4d Merge branch 'master' into fix-choices-deepcopy
* master: (23 commits)
  only accepting iterables to the when field
  adding 'when' parameter to MonitorField
  Update AUTHORS and changelog.
  Add test to verify get_subclass() on QuerySet
  Refactor to make sure get_subclass() is on QuerySet
  Fixed indexing into Choices so its useful.
  Fix bug with child/grandchild select_subclasses in Django 1.6+; thanks Keryn Knight.
  fixed code block
  Bump version for dev.
  Bump version for 1.5.0 release.
  Add option-groups capability to Choices.
  Add Changelog note about Choices equality/addition.
  Added tests to improve coverage
  Alphabetised authors
  Removed redundant inequality method on Choices
  Moved documentation for Choices field to the right place
  Corrected typo
  Added self to Authors file
  Added equality methods to Choices objects, and overrode + for Choices for easy concatenation with other Choices and choice-like iterables. Also wrote tests for them, and extended the readme to reflect this
  Fix typo noted by @silonov
  ...

Conflicts:
	model_utils/choices.py
2013-10-11 13:23:56 -06:00
Carl Meyer
5a33ff760a Fixed indexing into Choices so its useful. 2013-09-24 15:13:27 -06:00
Carl Meyer
2e44f1c2c0 Add option-groups capability to Choices. 2013-08-29 22:00:53 -06:00
Tony Aldridge
b706aee4a9 Added tests to improve coverage 2013-08-25 08:29:10 +01:00
Tony Aldridge
1a6d9a193e Removed redundant inequality method on Choices 2013-08-24 10:51:25 +01:00
Tony Aldridge
3485df15f2 Merge remote-tracking branch 'upstream/master'
Conflicts:
	README.rst
2013-08-24 10:36:21 +01:00
Tony Aldridge
003ad70805 Added equality methods to Choices objects, and overrode + for Choices
for easy concatenation with other Choices and choice-like iterables.
Also wrote tests for them, and extended the readme to reflect this
2013-08-23 16:58:10 +01:00
Den Lesnov
5f291a6a4a Implemented __deepcopy__ to avoid infinite recursion in __getattr__ while deepcopying a Choices instance 2013-08-15 15:01:09 +04:00
Keryn Knight
f89369f9ac Implement __contains__ ('x' in Choices('x')) for Choices objects.
In Choices, `_choice_dict` appears to be a definitive location of all
internal/DB representations, so it seems the best target for finding
out if the given item is part of the sequences.
2013-08-02 12:23:48 +01:00
Trey Hunner
4f2673e6a4 Fix str/unicode problems in Python 3
Changes:
- Use unicode_literals from the future for Python 2.6.5+
- Use six's text_type for proper unicode use in Python 2/3
2013-04-12 14:16:42 -07:00
Carl Meyer
a9ac3685fb Removed deprecated ChoiceEnum; moved Choices out of __init__.py. 2013-01-27 13:19:45 -08:00