Skip to content

Commit f99a254

Browse files
committed
Add misc doc strings
1 parent a1c5ad8 commit f99a254

File tree

6 files changed

+48
-3
lines changed

6 files changed

+48
-3
lines changed

examples/benchmark.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/python
2-
2+
"""Simple benchmarking script."""
33

44
import argparse
55
import contextlib
@@ -21,6 +21,7 @@
2121

2222

2323
def lookup_ip_address() -> None:
24+
"""Look up IP address."""
2425
ip = socket.inet_ntoa(struct.pack("!L", random.getrandbits(32)))
2526
with contextlib.suppress(geoip2.errors.AddressNotFoundError):
2627
reader.city(str(ip))

geoip2/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""geoip2 client library."""
2+
13
# pylint:disable=C0111
24

35
__title__ = "geoip2"

geoip2/database.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,12 @@ def _flat_model_for(
306306
def metadata(
307307
self,
308308
) -> maxminddb.reader.Metadata:
309-
"""The metadata for the open database.
309+
"""Get the metadata for the open database.
310310
311311
:returns: :py:class:`maxminddb.reader.Metadata` object
312312
"""
313313
return self._db_reader.metadata()
314314

315315
def close(self) -> None:
316-
"""Closes the GeoIP2 database."""
316+
"""Close the GeoIP2 database."""
317317
self._db_reader.close()

geoip2/errors.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ def __init__(
2929
ip_address: str | None = None,
3030
prefix_len: int | None = None,
3131
) -> None:
32+
"""Initialize self.
33+
34+
Arguments:
35+
message: A message describing the error.
36+
ip_address: The IP address that was not found.
37+
prefix_len: The prefix length for the network associated with
38+
the IP address.
39+
40+
"""
3241
super().__init__(message)
3342
self.ip_address = ip_address
3443
self._prefix_len = prefix_len
@@ -74,6 +83,15 @@ def __init__(
7483
uri: str | None = None,
7584
decoded_content: str | None = None,
7685
) -> None:
86+
"""Initialize self.
87+
88+
Arguments:
89+
message: A descriptive message for the error.
90+
http_status: The HTTP status code associated with the error, if any.
91+
uri: The URI that was being accessed when the error occurred.
92+
decoded_content: The decoded HTTP response body, if available.
93+
94+
"""
7795
super().__init__(message)
7896
self.http_status = http_status
7997
self.uri = uri

geoip2/records.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,11 +345,30 @@ class Subdivisions(tuple):
345345
This attribute is returned by ``city``, ``enterprise``, and ``insights``.
346346
"""
347347

348+
__slots__ = ("_locales",)
349+
348350
def __new__(
349351
cls: type[Self],
350352
locales: Sequence[str] | None,
351353
*subdivisions: dict,
352354
) -> Self:
355+
"""Create a new Subdivisions instance.
356+
357+
This method constructs the tuple with Subdivision objects created
358+
from the provided dictionaries.
359+
360+
Arguments:
361+
cls: The class to instantiate (Subdivisions).
362+
locales: A sequence of locale strings (e.g., ['en', 'fr'])
363+
or None, passed to each Subdivision object.
364+
*subdivisions: A variable number of dictionaries, where each
365+
dictionary contains the data for a single :py:class:`Subdivision`
366+
object (e.g., name, iso_code).
367+
368+
Returns:
369+
A new instance of Subdivisions containing :py:class:`Subdivision` objects.
370+
371+
"""
353372
subobjs = tuple(Subdivision(locales, **x) for x in subdivisions)
354373
return super().__new__(cls, subobjs)
355374

@@ -358,6 +377,7 @@ def __init__(
358377
locales: Sequence[str] | None,
359378
*_: dict,
360379
) -> None:
380+
"""Initialize the Subdivisions instance."""
361381
self._locales = locales
362382
super().__init__()
363383

geoip2/webservice.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@
6262

6363

6464
class BaseClient: # pylint: disable=missing-class-docstring, too-few-public-methods
65+
"""Base class for AsyncClient and Client."""
66+
6567
_account_id: str
6668
_host: str
6769
_license_key: str
@@ -291,6 +293,7 @@ def __init__( # pylint: disable=too-many-arguments,too-many-positional-argument
291293
timeout: float = 60,
292294
proxy: str | None = None,
293295
) -> None:
296+
"""Initialize AsyncClient."""
294297
super().__init__(
295298
account_id,
296299
license_key,
@@ -460,6 +463,7 @@ def __init__( # pylint: disable=too-many-arguments,too-many-positional-argument
460463
timeout: float = 60,
461464
proxy: str | None = None,
462465
) -> None:
466+
"""Initialize Client."""
463467
super().__init__(account_id, license_key, host, locales, timeout)
464468
self._session = requests.Session()
465469
self._session.auth = (self._account_id, self._license_key)

0 commit comments

Comments
 (0)