-
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.
Added PK[T] annotations and update() without WHERE clause.
- Loading branch information
Showing
5 changed files
with
69 additions
and
9 deletions.
There are no files selected for viewing
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,2 +1,3 @@ | ||
from .database import Database | ||
from .keys import PK | ||
from .model import Model |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
class _PK: | ||
""" | ||
This class stands in for the _PK[T] annotation and contains | ||
the type specified by the user. | ||
""" | ||
|
||
_type: type = None | ||
|
||
def __init__(self, _type: type) -> None: | ||
""" | ||
Constructs a new _PK instance to be used in an annotation. | ||
Not intended to be called directly; use a PK[T] annotation instead. | ||
Parameters: | ||
_type: type | ||
The type that this key expects. | ||
Returns: | ||
Nothing. | ||
""" | ||
|
||
self._type = _type | ||
|
||
class _PK_Factory: | ||
""" | ||
Factory for _PK instances. Provides the PK[T] annotation syntax. | ||
""" | ||
|
||
def __getitem__(self, _type: type) -> _PK: | ||
return _PK(_type) | ||
|
||
PK = _PK_Factory() |
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