vat-utils
raw JSON → 0.3.1 verified Fri May 01 auth: no python
vat-utils is a Python library for working with VAT (Value Added Tax) numbers, including validation and formatting. Version 0.3.1 requires Python >=3.6,<4.0. Release cadence is irregular.
pip install vat-utils Common errors
error AttributeError: module 'vatutils' has no attribute 'validate_vat' ↓
cause The function `validate_vat` was removed in version 0.3.0.
fix
Use
vatutils.VatNumber(vat_number).is_valid() instead. error TypeError: 'bool' object is not subscriptable ↓
cause Trying to access tuple indexing on the result of `is_valid()` which now returns a bool.
fix
Change
valid, msg = vat.is_valid() to valid = vat.is_valid() and remove msg usage. Warnings
deprecated The function `vatutils.validate_vat` is deprecated and may be removed in future versions. Use `VatNumber.is_valid()` instead. ↓
fix Replace `vatutils.validate_vat(vat_number)` with `vatutils.VatNumber(vat_number).is_valid()`.
breaking Version 0.3.0 changed the return type of `VatNumber.is_valid()` from a tuple `(bool, str)` to a boolean. This breaks code expecting a tuple. ↓
fix Update code to check only the boolean: `if vat.is_valid():` instead of `valid, msg = vat.is_valid()`.
gotcha The library does not perform live checks against official VAT databases (e.g., VIES). It only validates the format. This may be misunderstood. ↓
fix Use additional services like vies for live validation.
Imports
- vatutils
import vatutils - VatNumber
from vatutils import VatNumber
Quickstart
import vatutils
# Validate a VAT number
vat = vatutils.VatNumber('GB123456789')
print(vat.is_valid())