@@ -112,7 +112,7 @@ def __init__(
112112
113113 def __repr__ (self ) -> str :
114114 return (
115- f"{ self .__module__ } .{ self .__class__ .__name__ } ({ self ._locales } , "
115+ f"{ self .__module__ } .{ self .__class__ .__name__ } ({ repr ( self ._locales ) } , "
116116 f"{ ', ' .join (f'{ k } ={ repr (v )} ' for k , v in self .to_dict ().items ())} )"
117117 )
118118
@@ -359,13 +359,13 @@ class Enterprise(City):
359359class SimpleModel (Model , metaclass = ABCMeta ):
360360 """Provides basic methods for non-location models"""
361361
362- ip_address : str
362+ _ip_address : IPAddress
363363 _network : Optional [Union [ipaddress .IPv4Network , ipaddress .IPv6Network ]]
364- _prefix_len : int
364+ _prefix_len : Optional [ int ]
365365
366366 def __init__ (
367367 self ,
368- ip_address : Optional [ str ] ,
368+ ip_address : IPAddress ,
369369 network : Optional [str ],
370370 prefix_len : Optional [int ],
371371 ) -> None :
@@ -378,14 +378,26 @@ def __init__(
378378 # used.
379379 self ._network = None
380380 self ._prefix_len = prefix_len
381- self .ip_address = ip_address
381+ self ._ip_address = ip_address
382382
383383 def __repr__ (self ) -> str :
384+ d = self .to_dict ()
385+ d .pop ("ip_address" , None )
384386 return (
385- f"{ self .__module__ } .{ self .__class__ .__name__ } "
386- f"({ ', ' .join (f'{ k } ={ repr (v )} ' for k , v in self .to_dict ().items ())} )"
387+ f"{ self .__module__ } .{ self .__class__ .__name__ } ({ repr (str (self ._ip_address ))} , "
388+ + ", " .join (f"{ k } ={ repr (v )} " for k , v in d .items ())
389+ + ")"
387390 )
388391
392+ @property
393+ def ip_address (self ):
394+ """The IP address for the record"""
395+ if not isinstance (
396+ self ._ip_address , (ipaddress .IPv4Address , ipaddress .IPv6Address )
397+ ):
398+ self ._ip_address = ipaddress .ip_address (self ._ip_address )
399+ return self ._ip_address
400+
389401 @property
390402 def network (self ) -> Optional [Union [ipaddress .IPv4Network , ipaddress .IPv6Network ]]:
391403 """The network for the record"""
@@ -475,14 +487,14 @@ class AnonymousIP(SimpleModel):
475487
476488 def __init__ (
477489 self ,
490+ ip_address : IPAddress ,
478491 * ,
479492 is_anonymous : bool = False ,
480493 is_anonymous_vpn : bool = False ,
481494 is_hosting_provider : bool = False ,
482495 is_public_proxy : bool = False ,
483496 is_residential_proxy : bool = False ,
484497 is_tor_exit_node : bool = False ,
485- ip_address : Optional [str ] = None ,
486498 network : Optional [str ] = None ,
487499 prefix_len : Optional [int ] = None ,
488500 ** _ ,
@@ -535,10 +547,10 @@ class ASN(SimpleModel):
535547 # pylint:disable=too-many-arguments,too-many-positional-arguments
536548 def __init__ (
537549 self ,
550+ ip_address : IPAddress ,
538551 * ,
539552 autonomous_system_number : Optional [int ] = None ,
540553 autonomous_system_organization : Optional [str ] = None ,
541- ip_address : Optional [str ] = None ,
542554 network : Optional [str ] = None ,
543555 prefix_len : Optional [int ] = None ,
544556 ** _ ,
@@ -586,9 +598,9 @@ class ConnectionType(SimpleModel):
586598
587599 def __init__ (
588600 self ,
601+ ip_address : IPAddress ,
589602 * ,
590603 connection_type : Optional [str ] = None ,
591- ip_address : Optional [str ] = None ,
592604 network : Optional [str ] = None ,
593605 prefix_len : Optional [int ] = None ,
594606 ** _ ,
@@ -628,9 +640,9 @@ class Domain(SimpleModel):
628640
629641 def __init__ (
630642 self ,
643+ ip_address : IPAddress ,
631644 * ,
632645 domain : Optional [str ] = None ,
633- ip_address : Optional [str ] = None ,
634646 network : Optional [str ] = None ,
635647 prefix_len : Optional [int ] = None ,
636648 ** _ ,
@@ -708,14 +720,14 @@ class ISP(ASN):
708720 # pylint:disable=too-many-arguments,too-many-positional-arguments
709721 def __init__ (
710722 self ,
723+ ip_address : IPAddress ,
711724 * ,
712725 autonomous_system_number : Optional [int ] = None ,
713726 autonomous_system_organization : Optional [str ] = None ,
714727 isp : Optional [str ] = None ,
715728 mobile_country_code : Optional [str ] = None ,
716729 mobile_network_code : Optional [str ] = None ,
717730 organization : Optional [str ] = None ,
718- ip_address : Optional [str ] = None ,
719731 network : Optional [str ] = None ,
720732 prefix_len : Optional [int ] = None ,
721733 ** _ ,
0 commit comments