Skip to content

Commit

Permalink
Migrate to pydantic v2 (closes #85)
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjacob committed Sep 17, 2023
1 parent c49fea7 commit ee9db4e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion blackboard_sync/blackboard/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ def fetch_current_active_user(self, response):
return response

@property
def base_url(self):
def base_url(self) -> str:
"""API base URL."""
return self._base_url

Expand Down
10 changes: 3 additions & 7 deletions blackboard_sync/blackboard/blackboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,13 @@
from datetime import datetime
from typing import Union, Optional

from pydantic import BaseModel, validator
from pydantic import BaseModel, field_validator, ConfigDict
from pathvalidate import sanitize_filename


class ImmutableModel(BaseModel):
"""Model with const attributes."""

class Config:
"""Modify default configuration."""

allow_mutation = False
model_config = ConfigDict(frozen=True)


class BBLocale(ImmutableModel):
Expand Down Expand Up @@ -136,7 +132,7 @@ class BBContentHandler(ImmutableModel):
assessmentId: Optional[str] = None
proctoring: Optional[BBProctoring] = None

@validator('id')
@field_validator('id')
def resource_parser(cls, v: Union[BBResourceType, str]):
"""Validate and parse an id resource type."""
return BBResourceType(v.replace('resource/', ''))
Expand Down
2 changes: 1 addition & 1 deletion blackboard_sync/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def auth(self, cookie_jar: RequestsCookieJar) -> bool:
self._cookies = cookie_jar

try:
u_sess = BlackboardSession(self.university.api_url, cookie_jar)
u_sess = BlackboardSession(str(self.university.api_url), cookie_jar)
except ValueError:
self.logger.warning("Credentials are incorrect")
else:
Expand Down

0 comments on commit ee9db4e

Please sign in to comment.