Skip to content

Commit 7233045

Browse files
committed
Sort attrs of Traits and update docs
1 parent 945b6d6 commit 7233045

File tree

3 files changed

+19
-36
lines changed

3 files changed

+19
-36
lines changed

README.rst

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -514,21 +514,3 @@ Please report all issues with this code using the `GitHub issue tracker
514514
If you are having an issue with a MaxMind service that is not specific to the
515515
client API, please contact `MaxMind support
516516
<https://www.maxmind.com/en/support>`_ for assistance.
517-
518-
Testing
519-
-------
520-
521-
Get the repository and its submodule.
522-
523-
.. code-block:: bash
524-
525-
$ git clone https://github.com/maxmind/GeoIP2-python.git
526-
$ cd ./GeoIP2-python/
527-
$ git submodule update --init --recursive
528-
529-
Install and run ``tox``.
530-
531-
.. code-block:: bash
532-
533-
$ pip install tox
534-
$ tox

geoip2/records.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -634,14 +634,6 @@ class Traits(Record):
634634
635635
:type: str
636636
637-
.. attribute:: is_anycast
638-
639-
This is true if the IP address is anycast.
640-
This attribute is available from the Country, City Plus, Insights
641-
web services and the Country, City, Enterprise databases.
642-
643-
:type: bool
644-
645637
.. attribute:: is_anonymous
646638
647639
This is true if the IP address belongs to any sort of anonymous network.
@@ -673,6 +665,15 @@ class Traits(Record):
673665
674666
:type: bool
675667
668+
.. attribute:: is_anycast
669+
670+
This returns true if the IP address belongs to an
671+
`anycast network <https://en.wikipedia.org/wiki/Anycast>`_.
672+
This is available for the GeoIP2 Country, City Plus, and Insights
673+
web services and the GeoIP2 Country, City, and Enterprise databases.
674+
675+
:type: bool
676+
676677
.. attribute:: is_hosting_provider
677678
678679
This is true if the IP address belongs to a hosting or VPN provider
@@ -823,18 +824,18 @@ class Traits(Record):
823824
autonomous_system_organization: Optional[str]
824825
connection_type: Optional[str]
825826
domain: Optional[str]
826-
is_anycast: bool
827+
ip_address: Optional[str]
827828
is_anonymous: bool
828829
is_anonymous_proxy: bool
829830
is_anonymous_vpn: bool
831+
is_anycast: bool
830832
is_hosting_provider: bool
831833
is_legitimate_proxy: bool
832834
is_public_proxy: bool
833835
is_residential_proxy: bool
834836
is_satellite_provider: bool
835837
is_tor_exit_node: bool
836838
isp: Optional[str]
837-
ip_address: Optional[str]
838839
mobile_country_code: Optional[str]
839840
mobile_network_code: Optional[str]
840841
organization: Optional[str]
@@ -850,7 +851,6 @@ def __init__(
850851
autonomous_system_organization: Optional[str] = None,
851852
connection_type: Optional[str] = None,
852853
domain: Optional[str] = None,
853-
is_anycast: bool = False,
854854
is_anonymous: bool = False,
855855
is_anonymous_proxy: bool = False,
856856
is_anonymous_vpn: bool = False,
@@ -870,16 +870,17 @@ def __init__(
870870
user_type: Optional[str] = None,
871871
mobile_country_code: Optional[str] = None,
872872
mobile_network_code: Optional[str] = None,
873+
is_anycast: bool = False,
873874
**_,
874875
) -> None:
875876
self.autonomous_system_number = autonomous_system_number
876877
self.autonomous_system_organization = autonomous_system_organization
877878
self.connection_type = connection_type
878879
self.domain = domain
879-
self.is_anycast = is_anycast
880880
self.is_anonymous = is_anonymous
881881
self.is_anonymous_proxy = is_anonymous_proxy
882882
self.is_anonymous_vpn = is_anonymous_vpn
883+
self.is_anycast = is_anycast
883884
self.is_hosting_provider = is_hosting_provider
884885
self.is_legitimate_proxy = is_legitimate_proxy
885886
self.is_public_proxy = is_public_proxy

tests/models_test.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ def test_insights_full(self) -> None:
7575
"connection_type": "Cable/DSL",
7676
"domain": "example.com",
7777
"ip_address": "1.2.3.4",
78-
"is_anycast": True,
7978
"is_anonymous": True,
8079
"is_anonymous_proxy": True,
8180
"is_anonymous_vpn": True,
81+
"is_anycast": True,
8282
"is_hosting_provider": True,
8383
"is_public_proxy": True,
8484
"is_residential_proxy": True,
@@ -192,10 +192,10 @@ def test_insights_full(self) -> None:
192192
self.assertIs(model.registered_country.is_in_european_union, False)
193193
self.assertIs(model.represented_country.is_in_european_union, True)
194194

195-
self.assertIs(model.traits.is_anycast, True)
196195
self.assertIs(model.traits.is_anonymous, True)
197196
self.assertIs(model.traits.is_anonymous_proxy, True)
198197
self.assertIs(model.traits.is_anonymous_vpn, True)
198+
self.assertIs(model.traits.is_anycast, True)
199199
self.assertIs(model.traits.is_hosting_provider, True)
200200
self.assertIs(model.traits.is_public_proxy, True)
201201
self.assertIs(model.traits.is_residential_proxy, True)
@@ -325,14 +325,14 @@ def test_city_full(self) -> None:
325325
"registered_country name is correct",
326326
)
327327
self.assertEqual(
328-
model.traits.is_anycast,
328+
model.traits.is_anonymous_proxy,
329329
False,
330-
"traits is_anycast returns False by default",
330+
"traits is_anonymous_proxy returns False by default",
331331
)
332332
self.assertEqual(
333-
model.traits.is_anonymous_proxy,
333+
model.traits.is_anycast,
334334
False,
335-
"traits is_anonymous_proxy returns False by default",
335+
"traits is_anycast returns False by default",
336336
)
337337
self.assertEqual(
338338
model.traits.is_satellite_provider,

0 commit comments

Comments
 (0)