Skip to content

release2.2

tagged this 04 Dec 22:53
- Compile regex patterns at module level for email validation and address
  formatting to avoid recompilation on every call
- Replace multiple chained .replace() calls with str.translate() for phone
  number cleaning (3-5x faster)
- Simplify and fix URL encoding logic in _make_request for GET requests
  using proper urllib.parse.quote_plus()
- Add explicit connection pool configuration (pool_connections=10,
  pool_maxsize=20) to HTTPAdapter for better resource management
- Optimize address formatting using pre-compiled regex patterns instead of
  compiling on each call

Code Quality Improvements:
- Update validation methods (_validate_email, _validate_phone, _validate_domain)
  to raise ValidationError with descriptive messages while maintaining
  backward compatibility via raise_error parameter
- Remove unused imports (io, urljoin, asdict) from client.py
- Add comprehensive type hints throughout codebase (Dict[str, Any], return
  types, parameter types)
- Support PhoneFormat enum while maintaining string compatibility for
  phone_format parameters
- Fix test assertion in test_client.py (max_retries default is 1, not 3)

Best Practices:
- Add __slots__ to frequently instantiated dataclasses (Address, Person,
  PhoneNumber, PricingInfo, BalanceInfo, AccessLog) with Python 3.10+
  compatibility using conditional decorator
- Enhance error messages with more context and actionable information
- Add request compression support (Accept-Encoding header with gzip, deflate, br)
- Optimize response parsing to reduce redundant operations and improve
  error handling with better exception chaining
- Add input sanitization for user inputs before API calls (remove null bytes,
  control characters)

TLO Enrichment Support:
- Add comprehensive support for TLO (TransUnion) enrichment data fields:
  * censored_numbers: Censored phone numbers for privacy
  * addresses_structured: Structured addresses with detailed components
  * alternative_names: Alternative name variations
  * all_names: Complete name history with date_first_seen and date_last_seen
  * all_dobs: All date of birth records with age calculations
  * related_persons: Related individuals with relationship information
  * criminal_records: Criminal record information with case details
  * phone_numbers_full: Full phone number details with carrier and line type
  * confirmed_numbers: Confirmed phone number associations
  * other_emails: Additional email addresses found
- Add TLO enrichment parameter support to search_email() and search_phone()
  methods with proper cost tracking
- Implement parsing for all TLO enrichment data structures (NameRecord,
  DOBRecord, RelatedPerson, CriminalRecord, Crime, PhoneNumberFull,
  StructuredAddress, StructuredAddressComponents)
- Add TLO enrichment fields to BaseSearchResult and all search result types
- Handle TLO enrichment response structure where data is nested under
  numeric keys ('0', '1', etc.) when TLO is enabled
- Update total_results calculation to include all TLO enrichment fields
- Add automatic disabling of TLO-only output fields in search.py when
  TLO_ENRICHMENT is False

Bug Fixes:
- Fix total_results calculation to count all data fields including TLO
  enrichment fields (addresses_structured, all_names, all_dobs, etc.)
- Fix search cost display to prioritize pricing.total_cost over search_cost
  field for accurate cost reporting
- Fix result filtering logic in search.py to check TLO enrichment fields
  when TLO is enabled, ensuring results with TLO data are properly detected
- Fix early return check to validate all fields (standard + TLO) before
  returning empty results

Additional Changes:
- Add debug logging for raw API responses when debug_mode is enabled
- Improve total_results calculation to use max(api_total, calculated_total)
  to handle cases where API doesn't count all TLO fields
- Add comprehensive logging for pricing mismatches and data parsing issues
- Update search.py to automatically disable TLO-only output fields when
  TLO_ENRICHMENT is False
- Add search cost to log output for better cost tracking visibility

All changes maintain backward compatibility - existing code will continue to
work without modifications.
Assets 2
Loading