-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #315 from vipyrsec/revert-better-match-info
Revert better match info
- Loading branch information
Showing
9 changed files
with
4 additions
and
190 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,4 +132,3 @@ omit = [ | |
|
||
[tool.coverage.report] | ||
fail_under = 100 | ||
exclude_also = ["if TYPE_CHECKING:"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1 @@ | ||
"""Database models.""" | ||
|
||
from typing import Optional, Any, Type | ||
from pydantic import BaseModel | ||
from sqlalchemy import Dialect, TypeDecorator | ||
from sqlalchemy.dialects.postgresql import JSONB | ||
|
||
|
||
class Pydantic[T: BaseModel](TypeDecorator[T]): | ||
"""TypeDecorator to convert between Pydantic models and JSONB.""" | ||
|
||
impl = JSONB | ||
cache_ok = True | ||
|
||
def __init__(self, pydantic_type: Type[T]): | ||
super().__init__() | ||
self.pydantic_type = pydantic_type | ||
|
||
def process_bind_param(self, value: Optional[T], dialect: Dialect) -> dict[str, Any]: | ||
if value: | ||
return value.model_dump() | ||
else: | ||
return {} | ||
|
||
def process_result_value(self, value: Any, dialect: Dialect) -> Optional[T]: | ||
if value: | ||
return self.pydantic_type.model_validate(value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters