Validate the combination of *cmp*, *eq*, and *order*. Derive the effective values of eq and order. If *eq* is None, set it to *default_eq*.
(cmp, eq, order, default_eq)
| 1226 | |
| 1227 | |
| 1228 | def _determine_attrs_eq_order(cmp, eq, order, default_eq): |
| 1229 | """ |
| 1230 | Validate the combination of *cmp*, *eq*, and *order*. Derive the effective |
| 1231 | values of eq and order. If *eq* is None, set it to *default_eq*. |
| 1232 | """ |
| 1233 | if cmp is not None and any((eq is not None, order is not None)): |
| 1234 | msg = "Don't mix `cmp` with `eq' and `order`." |
| 1235 | raise ValueError(msg) |
| 1236 | |
| 1237 | # cmp takes precedence due to bw-compatibility. |
| 1238 | if cmp is not None: |
| 1239 | return cmp, cmp |
| 1240 | |
| 1241 | # If left None, equality is set to the specified default and ordering |
| 1242 | # mirrors equality. |
| 1243 | if eq is None: |
| 1244 | eq = default_eq |
| 1245 | |
| 1246 | if order is None: |
| 1247 | order = eq |
| 1248 | |
| 1249 | if eq is False and order is True: |
| 1250 | msg = "`order` can only be True if `eq` is True too." |
| 1251 | raise ValueError(msg) |
| 1252 | |
| 1253 | return eq, order |
| 1254 | |
| 1255 | |
| 1256 | def _determine_attrib_eq_order(cmp, eq, order, default_eq): |
no outgoing calls