Skip to content

fix(no_NO): compute Norwegian MOD11 check digit so iban() passes stdnum validation - #2415

Open
CedricConday wants to merge 4 commits into
joke2k:masterfrom
CedricConday:fix/iban-no
Open

fix(no_NO): compute Norwegian MOD11 check digit so iban() passes stdnum validation#2415
CedricConday wants to merge 4 commits into
joke2k:masterfrom
CedricConday:fix/iban-no

Conversation

@CedricConday

@CedricConday CedricConday commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Norwegian account numbers end in a MOD11 check digit; the no_NO provider generated it randomly, failing validation. This computes it correctly.

Verified against python-stdnum (reference IBAN validator): 300/300 generated IBANs pass stdnum.iban.validate(). Existing tests/providers/test_bank.py suite passes. Includes a regression test.


AI disclosure: Prepared with AI assistance (Claude / Claude Code). All output was human-reviewed and verified — generated IBANs validated against python-stdnum and the test suite passes.

Comment thread tests/providers/test_bank.py Outdated

def test_iban_stdnum(self, faker, num_samples):
try:
from stdnum import iban as iban_validator

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather add stdnum to the dev requirements and avoid the try ... except block

Adds python-stdnum to dev-requirements and hoists the import, so the IBAN
validation test always runs rather than silently skipping on machines
without it. Per review feedback on joke2k#2415.

Co-Authored-By: Claude <noreply@anthropic.com>
Assisted-by: Claude Opus 5
@CedricConday

Copy link
Copy Markdown
Contributor Author

Done — python-stdnum is now in dev-requirements and the import is hoisted to the top of the module, so the IBAN validation test always runs instead of skipping silently when the package is absent.

One packaging note: the distribution is python-stdnum while the importable module is stdnum, so the requirement line reads python-stdnum>=1.20.

dev-requirements.txt is not what CI installs — the workflow runs tox, and
[testenv] carries its own deps list. Without this the module-level stdnum
import fails collection for the whole test_bank.py module.

Co-Authored-By: Claude <noreply@anthropic.com>
Assisted-by: Claude Opus 5
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.

2 participants