Skip to content

Commit

Permalink
Revert v1 namespace (#10)
Browse files Browse the repository at this point in the history
* Revert "update readme"

This reverts commit 454df21.

* Revert "update readme"

This reverts commit a28d949.

* Revert "feat: add v1 namespace (#8)"

This reverts commit 33b2662.

* redo field stuff

* undo change
  • Loading branch information
tlambert03 authored Oct 24, 2023
1 parent 89dd343 commit d9ff739
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 33 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,18 @@ pydantic version installed (without deprecation warnings):
| `Model.__fields__` | `Model.model_fields` |
| `Model.__fields_set__` | `Model.model_fields_set` |


## `Field` notes

- `pydantic_compat.Field` will remove outdated fields (`const`) and translate
fields with new names:
| v1 name | v2 name |
| v1 name | v2 name |
| ---------------- | ------------------- |
| `min_items` | `min_length` |
| `max_items` | `max_length` |
| `regex` | `pattern` |
| `allow_mutation` | `not frozen` |
| `metadata` | `json_schema_extra` |
| `min_items` | `min_length` |
| `max_items` | `max_length` |
| `regex` | `pattern` |
| `allow_mutation` | `not frozen` |
| `metadata` | `json_schema_extra` |
- Don't use `var = Field(..., const='val')`, use `var: Literal['val'] = 'val'`
it works in both v1 and v2
- No attempt is made to convert between v1's `unique_items` and v2's `Set[]`
Expand Down
1 change: 0 additions & 1 deletion src/pydantic_compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"BaseModel",
]


from ._shared import PYDANTIC2

if TYPE_CHECKING:
Expand Down
16 changes: 0 additions & 16 deletions src/pydantic_compat/v1.py

This file was deleted.

10 changes: 0 additions & 10 deletions tests/test_base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,3 @@ class Model(PydanticCompatMixin, pydantic.BaseModel):
# test extra
with pytest.raises((ValueError, TypeError)): # (v1, v2)
Model(extra=1)


def test_v1_namespace() -> None:
from pydantic_compat.v1 import BaseModel

class Model(BaseModel):
x: int = 1

m = Model()
assert m.dict() == {"x": 1} # no warning

0 comments on commit d9ff739

Please sign in to comment.