Repository navigation
Release 1.15.0
Added
-
Add generated country metadata, failure-reason and input-format guides, executed and strictly typed documentation
examples, and contributor/country workflow templates
(#328). -
Add primary-only
normalize_id(),format_id()andget_input_mask()with frozenInputMaskresults.
Metadata-driven formatting checks length, not validity; input patterns use ASCII uppercase letters/digits.
Swedish formatting preserves a significant+in both 10-digit and 12-digit forms; preferred mask patterns
remain literal minus layouts. Greece's primary metadata example now uses already-accepted Latin letters;
Greek validation and formatting remain unchanged (#321). -
Add
failure_reason(id_class, id_number)for primary and secondary ID types. Unified validation and parsing now
report best-effort length, format, checksum and embedded-calendar-date reasons; inconclusive checks and exceptions
retainVALIDATION_FAILED. Date tracing is isolated between nested calls, threads and async tasks, and country
validity, parser and checksum behavior is unchanged (#322). -
Add
idnumbers.parse_id_info(country, id_number)for a country's primaryNationalID, returning the frozen
ParseSuccess/ParseFailureunionParseIdInfoResult. Theokdiscriminator supports strict type narrowing;
success includes a fresh dictionary of the country parser's information. Lookup and validation failures match
validate(), while valid IDs without extractable information giveNOT_PARSABLE. Country parsers are unchanged
(#319). -
Add a country registry,
idnumbers.registry, which is re-exported fromidnumbers.get_validator('tw'),
get_country('TWN')andresolve_country('tw')find theNationalIDclass, aCountryEntry(alpha-3 and alpha-2
code, name,NationalIDand all ID types) or the alpha-3 code of a country by its alpha-2 or alpha-3 code in any
letter case, and giveNonefor anything unknown instead of raising.list_supported_countries()lists the 78
countries, andregister()adds a custom country. The names are the English names of Unicode CLDR 48.2.3. AUS and
GRC keep their currentNationalID, and a country module is imported on the first lookup of its country
(#318). -
Add
idnumbers.validate(country, id_number), which validates an ID number of any supported country and returns a
frozenValidationResultwithis_valid, the alpha-3country_code, theid_number, theextracted_infoof a
valid ID number (theparse()result,Nonewhen the ID type isn't parsable), areasonand anerror_message. It
never raises, and a result is truthy when it is valid. An unknown country gives the reasonunsupported_country,
other failures a best-effort diagnostic reason.validate_many()validates(country, id_number)pairs, and
FailureReasonlists the reasons, which later releases may extend. The country classes are unchanged
(#317). -
Describe every ID class with seven more
METADATAkeys:country_name,id_type,official_name(Nonefor an
ID with no local-language name),display_format,example(a synthetic number the class validates),
checksum_algorithm(Nonewithout a check digit) andmasks, the layouts the class accepts.METADATAis now an
IdMetadata, a typedSimpleNamespacesubclass inidnumbers.nationalid.metadata, so attribute access,vars(),
copy()andgetattr()work as before. A class made byalias_of, such asAUS.NationalID, now has the name,
module and docstring of its target instead ofAliasType, which changes itsrepr.CAN.SocialInsuranceNumber
gets thedeprecatedkey the other classes already had, andtools.scan_idslists the classes through the country
registry (#320).
Changed
-
Ship the PEP 561
py.typedmarker, so type checkers use the package's annotations, and correct the annotations
that disagreed with the runtime values: theCHECK_DIGITalias, the untypednormalizeandchecksumhelpers,
the COL and KAZchecksummethods that returnFalsefor malformed input, the AUS TFN and KWT civil-number
checksummethods, which can return 10, and the LTUextract_year_base_genderresult, which is neverNone
(#325). -
Move the build metadata from
setup.pyto a PEP 621pyproject.toml. The license is now the SPDX expressionMIT
instead of the deprecated license classifier (#465), and
building from source needs setuptools 77 or later, which pip and uv install automatically
(#325). -
CI type-checks the package with strict mypy for Python 3.9 and checks the built distributions with
twine check --strict(#325). -
Re-export the ID classes explicitly (
import X as X) from the country modules such asAUS, so strict type
checkers (mypy--strict, which disallows implicit re-exports) accept
from idnumbers.nationalid.AUS import MedicareNumberandAUS.MedicareNumber; nothing changes at runtime
(#326). -
Prepare isolated, guarded PyPI publication and opt-in Trusted Publishing with attestations; retain the working
default token route and existing secrets. External publisher setup and the first verified trusted release remain
pending maintainer action. Document release ordering and 1.14.0-to-1.15.0 migration
(#327). -
Add dev-only Hypothesis checks of arbitrary Unicode inputs for every registered ID type, metadata method
contracts, out-of-range lengths and checksum mutations, with explicit synthetic witnesses for checksum limits
(#324). -
CI lints with ruff, enforces a 97% line-and-branch coverage floor, runs the README Python examples and
informational benchmarks, keeps GitHub Actions updated with Dependabot, and reports a singleci-summaryresult
(#326). Formatting withruff formatand a coverage badge
await a decision in #485. -
Vendor the Node port's parity corpus (78 countries, 17,960 vectors) at a pinned port commit and record Python's own
validity for it, so a validity change on any shared vector fails a test and gets a port note;
scripts/sync_parity_corpus.pyrefreshes both (#323).