Skip to content

Require both check digits for individual INNs - #525

Open
Doyoubelieveinfate wants to merge 1 commit into
python-validators:masterfrom
Doyoubelieveinfate:fix/individual-inn-check-digits
Open

Doyoubelieveinfate wants to merge 1 commit into
python-validators:masterfrom
Doyoubelieveinfate:fix/individual-inn-check-digits

Conversation

@Doyoubelieveinfate

Copy link
Copy Markdown

The nested conditional expression in ru_inn() can skip either check digit for a 12-digit individual INN. For example, 500100732266 passes even though its first check digit should be 5, and 100000001103 passes despite an incorrect second check digit.

Compare both remainders, each modulo 10, with their corresponding digits using and. This retains the existing remainder-10-to-zero rule and leaves the 10-digit company path unchanged. Tests cover each incorrect digit and valid controls with ordinary remainders and remainder 10.

Validation on macOS:

  • Two new rejection cases fail before the fix; all six new cases pass afterward.
  • Full suite: 1,177 tests pass on Python 3.11.14 and Python 3.13.5.
  • Repository tox -e lint,type,sast,py313 passes (Ruff, Pyright, Bandit and tests).
  • Changed-file Ruff formatting and git diff --check pass.
  • Reviewed conditional-expression precedence, the modulo range, both check-digit comparisons and the unchanged company-INN branch.

Prepared, tested and reviewed with Codex at the account owner's request.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant