{"record":{"id":"9fd087ef42ff397b","repo":"redis/redis-py","slug":"byfloat-and-byint-are-mutually-exclusive","errorCode":null,"errorMessage":"``byfloat`` and ``byint`` are mutually exclusive.","messagePattern":"``byfloat`` and ``byint`` are mutually exclusive\\.","errorType":"validation","errorClass":"DataError","httpStatus":null,"severity":"error","filePath":"redis/commands/core.py","lineNumber":3484,"sourceCode":"\n        ``lbound`` and ``ubound`` constrain the valid range of the result.\n\n        If ``saturate`` is True, out-of-bounds results are saturated to the\n        specified bound, or to the type limit when no bound is specified.\n        Otherwise, out-of-bounds results are rejected, leaving the value and\n        TTL unchanged and returning the current value and zero as the actual\n        increment.\n\n        ``enx`` applies the expiration only when the key does not already\n        have an expiration, and requires ``ex``, ``px``, ``exat``, or ``pxat``.\n        \"\"\"\n        if not at_most_one_value_set(\n            (\n                byfloat is not None,\n                byint is not None,\n            )\n        ):\n            raise DataError(\"``byfloat`` and ``byint`` are mutually exclusive.\")\n\n        if not at_most_one_value_set(\n            (\n                ex is not None,\n                px is not None,\n                exat is not None,\n                pxat is not None,\n                persist,\n            )\n        ):\n            raise DataError(\n                \"``ex``, ``px``, ``exat``, ``pxat``, \"\n                \"and ``persist`` are mutually exclusive.\"\n            )\n\n        if enx and ex is None and px is None and exat is None and pxat is None:\n            raise DataError(\n                \"``enx`` requires one of ``ex``, ``px``, ``exat``, or ``pxat``.\"","sourceCodeStart":3466,"sourceCodeEnd":3502,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/commands/core.py#L3466-L3502","documentation":"Raised as a `DataError` by `increx()` (redis/commands/core.py:3478) when both `byfloat` and `byint` are supplied. INCREX increments by either a float or an int (defaulting to +1 if neither is given); specifying both is contradictory.","triggerScenarios":"`r.increx('counter', byfloat=1.5, byint=2)` or any call passing both keyword args.","commonSituations":"Generic increment helpers that forward both kwargs from a config object; experimental API discovery (INCREX is new); logic that decides float-vs-int but forwards both.","solutions":["Pass either `byfloat` (for fractional increments) or `byint` (for integer increments), not both.","Omit both for a default +1 increment.","Resolve the increment type upstream and forward a single kwarg."],"exampleFix":"// before\nr.increx('c', byfloat=1.5, byint=2)\n// after\nr.increx('c', byint=2)  # integer increment by 2","handlingStrategy":"validation","validationCode":"if byfloat is not None and byint is not None:\n    raise ValueError('increx: pass byfloat OR byint, not both')\nr.increx('c', byfloat=byfloat, byint=byint)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Model the increment as one (mode, amount) pair.","Default to +1 by passing neither."],"tags":["increx","arguments","validation","dataerror"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}