Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update deprecated pydantic model Config class to model_config attribute #103

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions pyodk/_endpoints/bases.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
from pydantic import BaseModel
from pydantic import BaseModel, ConfigDict

from pyodk._utils.session import Session


class Model(BaseModel):
"""Base configuration for data model classes."""

class Config:
arbitrary_types_allowed = True
validate_assignment = True
model_config = ConfigDict(arbitrary_types_allowed=True, validate_assignment=True)


class FrozenModel(Model):
"""Make the base configuration model faux-immutable.

NOTE in pydantic v2 inherited model_config are *merged*.
"""

model_config = ConfigDict(frozen=True)


class Manager:
Expand Down
5 changes: 1 addition & 4 deletions pyodk/_endpoints/comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ class Comment(bases.Model):
createdAt: datetime


class URLs(bases.Model):
class Config:
frozen = True

class URLs(bases.FrozenModel):
list: str = "projects/{project_id}/forms/{form_id}/submissions/{instance_id}/comments"
post: str = "projects/{project_id}/forms/{form_id}/submissions/{instance_id}/comments"

Expand Down
5 changes: 1 addition & 4 deletions pyodk/_endpoints/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ class Entity(bases.Model):
deletedAt: datetime | None = None


class URLs(bases.Model):
class Config:
frozen = True

class URLs(bases.FrozenModel):
_entity_name: str = "projects/{project_id}/datasets/{el_name}"
_entities: str = f"{_entity_name}/entities"
list: str = _entities
Expand Down
5 changes: 1 addition & 4 deletions pyodk/_endpoints/entity_list_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ class EntityListProperty(bases.Model):
forms: list[str]


class URLs(bases.Model):
class Config:
frozen = True

class URLs(bases.FrozenModel):
post: str = "projects/{project_id}/datasets/{entity_list_name}/properties"


Expand Down
5 changes: 1 addition & 4 deletions pyodk/_endpoints/entity_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ class EntityList(bases.Model):
properties: list[EntityListProperty] | None = None


class URLs(bases.Model):
class Config:
frozen = True

class URLs(bases.FrozenModel):
_entity_list = "projects/{project_id}/datasets"
list: str = _entity_list
post: str = _entity_list
Expand Down
5 changes: 1 addition & 4 deletions pyodk/_endpoints/form_assignments.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
log = logging.getLogger(__name__)


class URLs(bases.Model):
class Config:
frozen = True

class URLs(bases.FrozenModel):
_form: str = "projects/{project_id}/forms/{form_id}"
post: str = f"{_form}/assignments/{{role_id}}/{{user_id}}"

Expand Down
5 changes: 1 addition & 4 deletions pyodk/_endpoints/form_draft_attachments.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
log = logging.getLogger(__name__)


class URLs(bases.Model):
class Config:
frozen = True

class URLs(bases.FrozenModel):
_form: str = "projects/{project_id}/forms/{form_id}"
post: str = f"{_form}/draft/attachments/{{fname}}"

Expand Down
5 changes: 1 addition & 4 deletions pyodk/_endpoints/form_drafts.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,7 @@ def get_definition_data(
return definition_data, content_type, file_path_stem


class URLs(bases.Model):
class Config:
frozen = True

class URLs(bases.FrozenModel):
_form: str = "projects/{project_id}/forms/{form_id}"
post: str = f"{_form}/draft"
post_publish: str = f"{_form}/draft/publish"
Expand Down
5 changes: 1 addition & 4 deletions pyodk/_endpoints/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ class Form(bases.Model):
publishedAt: datetime | None


class URLs(bases.Model):
class Config:
frozen = True

class URLs(bases.FrozenModel):
forms: str = "projects/{project_id}/forms"
get: str = f"{forms}/{{form_id}}"

Expand Down
5 changes: 1 addition & 4 deletions pyodk/_endpoints/project_app_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ class ProjectAppUser(bases.Model):
deletedAt: datetime | None


class URLs(bases.Model):
class Config:
frozen = True

class URLs(bases.FrozenModel):
list: str = "projects/{project_id}/app-users"
post: str = "projects/{project_id}/app-users"

Expand Down
5 changes: 1 addition & 4 deletions pyodk/_endpoints/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ class Project(bases.Model):
deletedAt: datetime | None = None


class URLs(bases.Model):
class Config:
frozen = True

class URLs(bases.FrozenModel):
list: str = "projects"
get: str = "projects/{project_id}"
get_data: str = "projects/{project_id}/forms/{form_id}.svc/{table_name}"
Expand Down
5 changes: 1 addition & 4 deletions pyodk/_endpoints/submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ class Submission(bases.Model):
updatedAt: datetime | None = None


class URLs(bases.Model):
class Config:
frozen = True

class URLs(bases.FrozenModel):
_form: str = "projects/{project_id}/forms/{form_id}"
list: str = f"{_form}/submissions"
get: str = f"{_form}/submissions/{{instance_id}}"
Expand Down
Loading