Skip to content

Commit

Permalink
move whoop_pydantic_v2 dir v2
Browse files Browse the repository at this point in the history
  • Loading branch information
JTunis committed Jul 21, 2024
1 parent 1f3cf93 commit db010d5
Show file tree
Hide file tree
Showing 315 changed files with 2,993 additions and 2,943 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ repos:
- id: usage_docs
name: Usage docs links
entry: pdm run ./tests/check_usage_docs.py
files: '^pydantic/'
files: '^whoop_pydantic_v2/'
types: [python]
language: system
- id: typecheck
name: Typecheck
entry: pdm run pyright pydantic
entry: pdm run pyright whoop_pydantic_v2
types: [python]
language: node
pass_filenames: false
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,22 @@ see the [Install](https://docs.pydantic.dev/install/) section in the documentati
```py
from datetime import datetime
from typing import List, Optional
from pydantic import BaseModel
from whoop_pydantic_v2 import BaseModel


class User(BaseModel):
id: int
name: str = 'John Doe'
signup_ts: Optional[datetime] = None
friends: List[int] = []


external_data = {'id': '123', 'signup_ts': '2017-06-01 12:22', 'friends': [1, '2', b'3']}
user = User(**external_data)
print(user)
#> User id=123 name='John Doe' signup_ts=datetime.datetime(2017, 6, 1, 12, 22) friends=[1, 2, 3]
# > User id=123 name='John Doe' signup_ts=datetime.datetime(2017, 6, 1, 12, 22) friends=[1, 2, 3]
print(user.id)
#> 123
# > 123
```

## Contributing
Expand Down
68 changes: 34 additions & 34 deletions docs/api/standard_library_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ A standard `bool` field will raise a `ValidationError` if the value is not one o
Here is a script demonstrating some of these behaviors:

```py
from pydantic import BaseModel, ValidationError
from whoop_pydantic_v2 import BaseModel, ValidationError


class BooleanModel(BaseModel):
bool_value: bool


print(BooleanModel(bool_value=False))
#> bool_value=False
# > bool_value=False
print(BooleanModel(bool_value='False'))
#> bool_value=False
# > bool_value=False
print(BooleanModel(bool_value=1))
#> bool_value=True
# > bool_value=True
try:
BooleanModel(bool_value=[])
except ValidationError as e:
Expand Down Expand Up @@ -66,7 +66,7 @@ types:
```py
from datetime import datetime

from pydantic import BaseModel
from whoop_pydantic_v2 import BaseModel


class Event(BaseModel):
Expand All @@ -93,7 +93,7 @@ print(event.model_dump())
```py
from datetime import date

from pydantic import BaseModel
from whoop_pydantic_v2 import BaseModel


class Birthday(BaseModel):
Expand All @@ -103,7 +103,7 @@ class Birthday(BaseModel):
my_birthday = Birthday(d=1679616000.0)

print(my_birthday.model_dump())
#> {'d': datetime.date(2023, 3, 24)}
# > {'d': datetime.date(2023, 3, 24)}
```

### [`datetime.time`][]
Expand All @@ -116,7 +116,7 @@ print(my_birthday.model_dump())
```py
from datetime import time

from pydantic import BaseModel
from whoop_pydantic_v2 import BaseModel


class Meeting(BaseModel):
Expand All @@ -126,7 +126,7 @@ class Meeting(BaseModel):
m = Meeting(t=time(4, 8, 16))

print(m.model_dump())
#> {'t': datetime.time(4, 8, 16)}
# > {'t': datetime.time(4, 8, 16)}
```

### [`datetime.timedelta`][]
Expand All @@ -142,7 +142,7 @@ print(m.model_dump())
```py
from datetime import timedelta

from pydantic import BaseModel
from whoop_pydantic_v2 import BaseModel


class Model(BaseModel):
Expand Down Expand Up @@ -178,14 +178,14 @@ Pydantic supports the following numeric types from the Python standard library:

* Validation: Pydantic attempts to convert the value to a string, then passes the string to `Decimal(v)`.
* Serialization: Pydantic serializes [`Decimal`][decimal.Decimal] types as strings.
You can use a custom serializer to override this behavior if desired. For example:
You can use a custom serializer to override this behavior if desired. For example:

```py
from decimal import Decimal

from typing_extensions import Annotated

from pydantic import BaseModel, PlainSerializer
from whoop_pydantic_v2 import BaseModel, PlainSerializer


class Model(BaseModel):
Expand Down Expand Up @@ -222,7 +222,7 @@ Subclass of `enum.Enum` checks that the value is a valid member of the enum.
```py
from enum import Enum, IntEnum

from pydantic import BaseModel, ValidationError
from whoop_pydantic_v2 import BaseModel, ValidationError


class FruitEnum(str, Enum):
Expand Down Expand Up @@ -269,7 +269,7 @@ Handled the same as `list` above.
```py
from typing import List, Optional

from pydantic import BaseModel
from whoop_pydantic_v2 import BaseModel


class Model(BaseModel):
Expand All @@ -295,7 +295,7 @@ Handled the same as `tuple` above.
```py
from typing import Optional, Tuple

from pydantic import BaseModel
from whoop_pydantic_v2 import BaseModel


class Model(BaseModel):
Expand All @@ -319,7 +319,7 @@ all fields are treated as having type [`Any`][typing.Any].
```py
from typing import NamedTuple

from pydantic import BaseModel, ValidationError
from whoop_pydantic_v2 import BaseModel, ValidationError


class Point(NamedTuple):
Expand Down Expand Up @@ -356,7 +356,7 @@ Handled the same as `deque` above.
```py
from typing import Deque, Optional

from pydantic import BaseModel
from whoop_pydantic_v2 import BaseModel


class Model(BaseModel):
Expand All @@ -381,7 +381,7 @@ Handled the same as `set` above.
```py
from typing import Optional, Set

from pydantic import BaseModel
from whoop_pydantic_v2 import BaseModel


class Model(BaseModel):
Expand Down Expand Up @@ -409,7 +409,7 @@ Handled the same as `frozenset` above.
```py
from typing import FrozenSet, Optional

from pydantic import BaseModel
from whoop_pydantic_v2 import BaseModel


class Model(BaseModel):
Expand Down Expand Up @@ -454,7 +454,7 @@ Here is a simple example using [`typing.Sequence`][]:
```py
from typing import Sequence

from pydantic import BaseModel
from whoop_pydantic_v2 import BaseModel


class Model(BaseModel):
Expand All @@ -479,7 +479,7 @@ generator or a remote data loader), you can use a field of type [`Iterable`][typ
```py
from typing import Iterable

from pydantic import BaseModel
from whoop_pydantic_v2 import BaseModel


class Model(BaseModel):
Expand Down Expand Up @@ -527,7 +527,7 @@ Though the yielded values are not validated eagerly, they are still validated wh
```python
from typing import Iterable

from pydantic import BaseModel, ValidationError
from whoop_pydantic_v2 import BaseModel, ValidationError


class Model(BaseModel):
Expand Down Expand Up @@ -563,7 +563,7 @@ except ValidationError as e:
`dict(v)` is used to attempt to convert a dictionary. see [`typing.Dict`][] below for sub-type constraints.

```py
from pydantic import BaseModel, ValidationError
from whoop_pydantic_v2 import BaseModel, ValidationError


class Model(BaseModel):
Expand All @@ -590,7 +590,7 @@ except ValidationError as e:
```py
from typing import Dict

from pydantic import BaseModel, ValidationError
from whoop_pydantic_v2 import BaseModel, ValidationError


class Model(BaseModel):
Expand Down Expand Up @@ -628,7 +628,7 @@ It is same as [`dict`][] but Pydantic will validate the dictionary since keys ar
```py
from typing_extensions import TypedDict

from pydantic import TypeAdapter, ValidationError
from whoop_pydantic_v2 import TypeAdapter, ValidationError


class User(TypedDict):
Expand Down Expand Up @@ -660,7 +660,7 @@ from typing import Optional

from typing_extensions import TypedDict

from pydantic import ConfigDict, TypeAdapter, ValidationError
from whoop_pydantic_v2 import ConfigDict, TypeAdapter, ValidationError


# `total=False` means keys are non-required
Expand Down Expand Up @@ -734,7 +734,7 @@ Fields can also be of type [`Callable`][typing.Callable]:
```py
from typing import Callable

from pydantic import BaseModel
from whoop_pydantic_v2 import BaseModel


class Foo(BaseModel):
Expand Down Expand Up @@ -793,7 +793,7 @@ Handled the same as `type` above.
```py
from typing import Type

from pydantic import BaseModel, ValidationError
from whoop_pydantic_v2 import BaseModel, ValidationError


class Foo:
Expand Down Expand Up @@ -830,7 +830,7 @@ You may also use `Type` to specify that any class is allowed.
```py upgrade="skip"
from typing import Type

from pydantic import BaseModel, ValidationError
from whoop_pydantic_v2 import BaseModel, ValidationError


class Foo:
Expand Down Expand Up @@ -861,7 +861,7 @@ except ValidationError as e:
```py
from typing import TypeVar

from pydantic import BaseModel
from whoop_pydantic_v2 import BaseModel

Foobar = TypeVar('Foobar')
BoundFloat = TypeVar('BoundFloat', bound=float)
Expand Down Expand Up @@ -904,7 +904,7 @@ Enum`s inheriting from `str` are converted using `v.value`. All other types caus
```py
from typing import Optional, Sequence

from pydantic import BaseModel, ValidationError
from whoop_pydantic_v2 import BaseModel, ValidationError


class Model(BaseModel):
Expand Down Expand Up @@ -954,7 +954,7 @@ Pydantic supports the use of [`typing.Literal`][] as a lightweight way to specif
```py
from typing import Literal

from pydantic import BaseModel, ValidationError
from whoop_pydantic_v2 import BaseModel, ValidationError


class Pie(BaseModel):
Expand All @@ -980,7 +980,7 @@ without needing to declare custom validators:
```py requires="3.8"
from typing import ClassVar, List, Literal, Union

from pydantic import BaseModel, ValidationError
from whoop_pydantic_v2 import BaseModel, ValidationError


class Cake(BaseModel):
Expand Down Expand Up @@ -1019,7 +1019,7 @@ With proper ordering in an annotated `Union`, you can use this to parse types of
```py requires="3.8"
from typing import Literal, Optional, Union

from pydantic import BaseModel
from whoop_pydantic_v2 import BaseModel


class Dessert(BaseModel):
Expand Down
Loading

0 comments on commit db010d5

Please sign in to comment.