Skip to content

Commit caed609

Browse files
committed
Fix various documentation layout issues
1 parent d18df25 commit caed609

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

pydantic_extra_types/pendulum_dt.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,8 @@ def to_iso8601_string(self) -> str:
200200
201201
In addition to the standard ISO 8601 format, this method also supports the representation of fractions of a second and negative durations.
202202
203-
Args:
204-
duration (Duration): The Duration object.
205-
206203
Returns:
207-
str: The ISO 8601 string representation of the duration.
204+
The ISO 8601 string representation of the duration.
208205
"""
209206
# Extracting components from the Duration object
210207
years = self.years

pydantic_extra_types/phone_numbers.py

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"""The `pydantic_extra_types.phone_numbers` module provides the
22
[`PhoneNumber`][pydantic_extra_types.phone_numbers.PhoneNumber] data type.
33
4-
This class depends on the [phonenumbers] package, which is a Python port of Google's [libphonenumber].
4+
This class depends on the [phonenumbers](https://pypi.orgt/phonenumbers/) package,
5+
which is a Python port of Google's [libphonenumber](https://github.com/google/libphonenumber/).
56
"""
67

78
from __future__ import annotations
@@ -25,15 +26,14 @@
2526

2627

2728
class PhoneNumber(str):
28-
"""A wrapper around [phonenumbers](https://pypi.org/project/phonenumbers/) package, which
29-
is a Python port of Google's [libphonenumber](https://github.com/google/libphonenumber/).
30-
"""
31-
32-
supported_regions: list[str] = []
33-
"""The supported regions. If empty, all regions are supported."""
29+
"""A wrapper around the `phonenumbers.PhoneNumber` object."""
3430

3531
default_region_code: ClassVar[str | None] = None
3632
"""The default region code to use when parsing phone numbers without an international prefix."""
33+
34+
supported_regions: list[str] = []
35+
"""The supported regions. If empty, all regions are supported."""
36+
3737
phone_format: str = 'RFC3966'
3838
"""The format of the phone number."""
3939

@@ -78,21 +78,16 @@ def __hash__(self) -> int:
7878

7979
@dataclass(frozen=True)
8080
class PhoneNumberValidator:
81-
"""A pydantic before validator for phone numbers using the [phonenumbers](https://pypi.org/project/phonenumbers/) package,
82-
a Python port of Google's [libphonenumber](https://github.com/google/libphonenumber/).
81+
"""An annotation to validate `phonenumbers.PhoneNumber` objects.
8382
84-
Intended to be used to create custom pydantic data types using the `typing.Annotated` type construct.
85-
86-
Args:
87-
default_region (str | None): The default region code to use when parsing phone numbers without an international prefix.
88-
If `None` (default), the region must be supplied in the phone number as an international prefix.
89-
number_format (str): The format of the phone number to return. See `phonenumbers.PhoneNumberFormat` for valid values.
90-
supported_regions (list[str]): The supported regions. If empty, all regions are supported (default).
83+
Example:
84+
```python
85+
from typing import Annotated, Union
9186
92-
Returns:
93-
The formatted phone number.
87+
import phonenumbers
88+
from pydantic import BaseModel
89+
from pydantic_extra_types.phone_numbers import PhoneNumberValidator
9490
95-
Example:
9691
MyNumberType = Annotated[
9792
Union[str, phonenumbers.PhoneNumber],
9893
PhoneNumberValidator()
@@ -105,11 +100,20 @@ class PhoneNumberValidator:
105100
class SomeModel(BaseModel):
106101
phone_number: MyNumberType
107102
us_number: USNumberType
103+
```
108104
"""
109105

110106
default_region: str | None = None
107+
"""The default region code to use when parsing phone numbers without an international prefix.
108+
109+
If `None` (the default), the region must be supplied in the phone number as an international prefix.
110+
"""
111+
111112
number_format: str = 'RFC3966'
113+
"""The format of the phone number to return. See `phonenumbers.PhoneNumberFormat` for valid values."""
114+
112115
supported_regions: Sequence[str] | None = None
116+
"""The supported regions. If empty (the default), all regions are supported."""
113117

114118
def __post_init__(self) -> None:
115119
if self.default_region and self.default_region not in phonenumbers.SUPPORTED_REGIONS:

0 commit comments

Comments
 (0)