@@ -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,28 @@ 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__ } ("
388+ + repr (str (self ._ip_address ))
389+ + ", "
390+ + ", " .join (f"{ k } ={ repr (v )} " for k , v in d .items ())
391+ + ")"
387392 )
388393
394+ @property
395+ def ip_address (self ):
396+ """The IP address for the record"""
397+ if not isinstance (
398+ self ._ip_address , (ipaddress .IPv4Address , ipaddress .IPv6Address )
399+ ):
400+ self ._ip_address = ipaddress .ip_address (self ._ip_address )
401+ return self ._ip_address
402+
389403 @property
390404 def network (self ) -> Optional [Union [ipaddress .IPv4Network , ipaddress .IPv6Network ]]:
391405 """The network for the record"""
@@ -475,14 +489,14 @@ class AnonymousIP(SimpleModel):
475489
476490 def __init__ (
477491 self ,
492+ ip_address : IPAddress ,
478493 * ,
479494 is_anonymous : bool = False ,
480495 is_anonymous_vpn : bool = False ,
481496 is_hosting_provider : bool = False ,
482497 is_public_proxy : bool = False ,
483498 is_residential_proxy : bool = False ,
484499 is_tor_exit_node : bool = False ,
485- ip_address : Optional [str ] = None ,
486500 network : Optional [str ] = None ,
487501 prefix_len : Optional [int ] = None ,
488502 ** _ ,
@@ -535,10 +549,10 @@ class ASN(SimpleModel):
535549 # pylint:disable=too-many-arguments,too-many-positional-arguments
536550 def __init__ (
537551 self ,
552+ ip_address : IPAddress ,
538553 * ,
539554 autonomous_system_number : Optional [int ] = None ,
540555 autonomous_system_organization : Optional [str ] = None ,
541- ip_address : Optional [str ] = None ,
542556 network : Optional [str ] = None ,
543557 prefix_len : Optional [int ] = None ,
544558 ** _ ,
@@ -586,9 +600,9 @@ class ConnectionType(SimpleModel):
586600
587601 def __init__ (
588602 self ,
603+ ip_address : IPAddress ,
589604 * ,
590605 connection_type : Optional [str ] = None ,
591- ip_address : Optional [str ] = None ,
592606 network : Optional [str ] = None ,
593607 prefix_len : Optional [int ] = None ,
594608 ** _ ,
@@ -628,9 +642,9 @@ class Domain(SimpleModel):
628642
629643 def __init__ (
630644 self ,
645+ ip_address : IPAddress ,
631646 * ,
632647 domain : Optional [str ] = None ,
633- ip_address : Optional [str ] = None ,
634648 network : Optional [str ] = None ,
635649 prefix_len : Optional [int ] = None ,
636650 ** _ ,
@@ -708,14 +722,14 @@ class ISP(ASN):
708722 # pylint:disable=too-many-arguments,too-many-positional-arguments
709723 def __init__ (
710724 self ,
725+ ip_address : IPAddress ,
711726 * ,
712727 autonomous_system_number : Optional [int ] = None ,
713728 autonomous_system_organization : Optional [str ] = None ,
714729 isp : Optional [str ] = None ,
715730 mobile_country_code : Optional [str ] = None ,
716731 mobile_network_code : Optional [str ] = None ,
717732 organization : Optional [str ] = None ,
718- ip_address : Optional [str ] = None ,
719733 network : Optional [str ] = None ,
720734 prefix_len : Optional [int ] = None ,
721735 ** _ ,
0 commit comments