Skip to content

Commit 3eb5f26

Browse files
committed
Modernize attribute docs
Place the documentation on the attributes directly. This was not previously possible due to how the attributes were constructed. This also allows us to eliminate duplicate documentation for inherited attributes.
1 parent a62c6e2 commit 3eb5f26

File tree

4 files changed

+346
-1080
lines changed

4 files changed

+346
-1080
lines changed

docs/index.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,33 @@ Modules
1414

1515
.. automodule:: geoip2
1616
:members:
17+
:inherited-members:
18+
:show-inheritance:
1719

1820
.. automodule:: geoip2.database
1921
:members:
22+
:inherited-members:
23+
:show-inheritance:
2024

2125
.. automodule:: geoip2.webservice
2226
:members:
27+
:inherited-members:
28+
:show-inheritance:
2329

2430
.. automodule:: geoip2.models
2531
:members:
32+
:inherited-members:
33+
:show-inheritance:
2634

2735
.. automodule:: geoip2.records
2836
:members:
37+
:inherited-members:
38+
:show-inheritance:
2939

3040
.. automodule:: geoip2.errors
3141
:members:
42+
:inherited-members:
43+
:show-inheritance:
3244

3345
==================
3446
Indices and tables

geoip2/errors.py

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,12 @@ class GeoIP2Error(RuntimeError):
1919

2020

2121
class AddressNotFoundError(GeoIP2Error):
22-
"""The address you were looking up was not found.
23-
24-
.. attribute:: ip_address
25-
26-
The IP address used in the lookup. This is only available for database
27-
lookups.
28-
29-
:type: str
30-
31-
.. attribute:: network
32-
33-
The network associated with the error. In particular, this is the
34-
largest network where no address would be found. This is only
35-
available for database lookups.
36-
37-
:type: ipaddress.IPv4Network or ipaddress.IPv6Network
38-
39-
"""
22+
"""The address you were looking up was not found."""
4023

4124
ip_address: Optional[str]
25+
"""The IP address used in the lookup. This is only available for database
26+
lookups.
27+
"""
4228
_prefix_len: Optional[int]
4329

4430
def __init__(
@@ -53,7 +39,11 @@ def __init__(
5339

5440
@property
5541
def network(self) -> Optional[Union[ipaddress.IPv4Network, ipaddress.IPv6Network]]:
56-
"""The network for the error."""
42+
"""The network associated with the error.
43+
44+
In particular, this is the largest network where no address would be
45+
found. This is only available for database lookups.
46+
"""
5747
if self.ip_address is None or self._prefix_len is None:
5848
return None
5949
return ipaddress.ip_network(f"{self.ip_address}/{self._prefix_len}", False)
@@ -69,12 +59,15 @@ class HTTPError(GeoIP2Error):
6959
This class represents an HTTP transport error. It extends
7060
:py:exc:`GeoIP2Error` and adds attributes of its own.
7161
72-
:ivar http_status: The HTTP status code returned
73-
:ivar uri: The URI queried
74-
:ivar decoded_content: The decoded response content
75-
7662
"""
7763

64+
http_status: Optional[int]
65+
"""The HTTP status code returned"""
66+
uri: Optional[str]
67+
"""The URI queried"""
68+
decoded_content: Optional[str]
69+
"""The decoded response content"""
70+
7871
def __init__(
7972
self,
8073
message: str,

0 commit comments

Comments
 (0)