Registry / gcp / google-i18n-address

google-i18n-address

JSON →
library3.1.1pypypi✓ verified 83d ago

google-i18n-address provides address validation helpers leveraging Google's international address database. It helps in validating, normalizing, and latinizing addresses for various countries. The library is currently at version 3.1.1 and receives updates typically for database rule changes or minor packaging improvements.

pip install google-i18n-address
INSTALL
IMPORT
SIG · GOOGLE-I18N-ADDRES
G
google-i18n-address
gcppythonv3.1.1
Install
2.2s avg
Import
Disk
24MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.1.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 25.9MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 2.2s · import 0.000s · 26MB
24MB installed
● package 24MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

InvalidAddressError
from i18naddress import InvalidAddressError
from i18naddress import Address
normalize_address
from i18naddress import normalize_address
format_address
from i18naddress import format_address

This quickstart demonstrates how to validate an international address using Address, AddressValidator, and get_validation_rules. It also shows how to normalize an address object.

from i18naddress import Address, AddressValidator, get_validation_rules address_data = { 'country_code': 'US', 'street_address': '1600 Amphitheatre Pkwy', 'city': 'Mountain View', 'postal_code': '94043', 'country_area': 'CA' } # Create an Address object address = Address(**address_data) # Get validation rules for the address's country rules = get_validation_rules(address_data) # Validate the address errors = AddressValidator().validate(address, rules) if errors: print(f"Validation errors: {errors}") else: print("Address is valid.") # Example of getting normalized address normalized_address = address.normalize() print(f"Normalized address: {normalized_address.as_dict()}")
Debug
Known issues
breakingThe exception class `InvalidAddress` was renamed to `InvalidAddressError` for PEP8 compliance.
fix
Update your exception handling from `except InvalidAddress:` to `except InvalidAddressError:` and ensure you import `InvalidAddressError` from `i18naddress.errors`.
affects: >=3.0.0
breakingThe `ValidationRules.postal_code_examples` attribute changed its type from a string to a list of strings.
fix
If your code expects `postal_code_examples` to be a string, update it to handle a list, e.g., `rules.postal_code_examples[0]` for the first example or iterate over the list.
affects: >=2.2.0
gotchaThe Python package name is `google-i18n-address` on PyPI, but its top-level import is `i18naddress`.
fix
Always use `import i18naddress` or `from i18naddress import ...` in your code, not `google_i18n_address`.
affects: *
gotchaValidation logic for non-required fields changed. Empty fields that are not explicitly required will no longer be marked as invalid, even if a list of choices for that field exists.
fix
Review any custom validation logic that relies on empty non-required fields being flagged as invalid when a choice list is present. Adjust expectations or add explicit checks if needed.
affects: >=2.3.0
Upgrade
Version history
3.1.1latest on PyPI · released Sep 4, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
25 hits · last 30 days
node
20
OpenAI (training)
1
Resources
google-i18n-address — pip install google-i18n-address · libregistry