Skip to content

Commit

Permalink
re-drop py3.9, make 3.10 work maybe
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBuchanan314 committed Dec 4, 2024
1 parent 3b6c4ad commit 8d7315c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13' ]
python-version: [ '3.10', '3.11', '3.12', '3.13' ]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ authors = [
]
description = "A lightweight atproto PDS"
readme = "README.md"
requires-python = ">=3.9" # currently untested, may update if CI fails
requires-python = ">=3.10"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
Expand Down
23 changes: 13 additions & 10 deletions src/millipds/repo_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"""

import io
from typing import List, TypedDict, Literal, NotRequired, Optional, Tuple, Set
from typing import List, TypedDict, Literal, TYPE_CHECKING, Optional, Tuple, Set
if TYPE_CHECKING:
from typing import NotRequired # not suppored <= py3.10
import apsw
import aiohttp.web
import base64
Expand Down Expand Up @@ -78,20 +80,21 @@ def get_record(db: Database, did: str, path: str) -> Optional[bytes]:


# https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/repo/applyWrites.json
WriteOp = TypedDict("WriteOp", {
"$type": Literal["com.atproto.repo.applyWrites#create", "com.atproto.repo.applyWrites#update", "com.atproto.repo.applyWrites#delete"],
"collection": str,
"rkey": NotRequired[str], # required for update, delete
"validate": NotRequired[bool],
"swapRecord": NotRequired[str],
"value": NotRequired[dict|str] # not required for delete - str is for base64-encoded dag-cbor
})
if TYPE_CHECKING:
WriteOp = TypedDict("WriteOp", {
"$type": Literal["com.atproto.repo.applyWrites#create", "com.atproto.repo.applyWrites#update", "com.atproto.repo.applyWrites#delete"],
"collection": str,
"rkey": NotRequired[str], # required for update, delete
"validate": NotRequired[bool],
"swapRecord": NotRequired[str],
"value": NotRequired[dict|str] # not required for delete - str is for base64-encoded dag-cbor
})

# This is perhaps the most complex function in the whole codebase.
# There's probably some scope for refactoring, but I like the "directness" of it.
# The work it does is inherently complex, i.e. the atproto MST record commit logic
# The MST logic itself is hidden away inside the `atmst` module.
def apply_writes(db: Database, repo: str, writes: List[WriteOp], swap_commit: Optional[str]) -> Tuple[bytes, int, bytes]:
def apply_writes(db: Database, repo: str, writes: List["WriteOp"], swap_commit: Optional[str]) -> Tuple[bytes, int, bytes]:
with db.new_con() as con: # one big transaction (we could perhaps work in two phases, prepare (via read-only conn) then commit?)
db_bs = DBBlockStore(con, repo)
mem_bs = MemoryBlockStore()
Expand Down

0 comments on commit 8d7315c

Please sign in to comment.