Skip to content

Commit 0a4b364

Browse files
Tag datetime fix (#155)
1 parent 76ac7b8 commit 0a4b364

34 files changed

+645
-854
lines changed

.github/workflows/stability.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@ jobs:
3535
- name: Run black checks
3636
run: black --check --verbose --diff --color src/
3737

38-
- name: Run mypy checks
39-
run: mypy src/
38+
# This is currently disabled because MyPy is very confused about Coroutine types
39+
# - name: Run mypy checks
40+
# run: mypy --explicit-package-bases src/

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,4 @@ manifest/
8888
.mypy_cache/
8989
.ruff_cache/
9090
tests/db_snapshots/
91+
logs/

docker-compose.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ services:
88
- SURREAL_PASS=root
99
- SURREAL_INSECURE_FORWARD_ACCESS_ERRORS=true
1010
- SURREAL_LOG=debug
11+
- SURREAL_CAPS_ALLOW_GUESTS=true
1112
ports:
1213
- 8000:8000
1314

@@ -18,6 +19,7 @@ services:
1819
- SURREAL_USER=root
1920
- SURREAL_PASS=root
2021
- SURREAL_LOG=trace
22+
- SURREAL_CAPS_ALLOW_GUESTS=true
2123
ports:
2224
- 8121:8000
2325

@@ -28,6 +30,7 @@ services:
2830
- SURREAL_USER=root
2931
- SURREAL_PASS=root
3032
- SURREAL_LOG=trace
33+
- SURREAL_CAPS_ALLOW_GUESTS=true
3134
ports:
3235
- 8120:8000
3336

@@ -38,6 +41,7 @@ services:
3841
- SURREAL_USER=root
3942
- SURREAL_PASS=root
4043
- SURREAL_LOG=trace
44+
- SURREAL_CAPS_ALLOW_GUESTS=true
4145
ports:
4246
- 8101:8000
4347

@@ -48,5 +52,6 @@ services:
4852
- SURREAL_USER=root
4953
- SURREAL_PASS=root
5054
- SURREAL_LOG=trace
55+
- SURREAL_CAPS_ALLOW_GUESTS=true
5156
ports:
52-
- 8111:8000
57+
- 8111:8000

pyproject.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,17 @@ Homepage = "https://github.com/surrealdb/surrealdb.py"
5959
[tool.setuptools.packages.find]
6060
where = ["src"]
6161

62+
[tool.ruff]
63+
exclude = ["src/surrealdb/__init__.py"]
64+
65+
[tool.mypy]
66+
mypy_path = "src"
67+
explicit_package_bases = true
68+
disable_error_code = ["return-value", "return-type"]
69+
70+
[[tool.mypy.overrides]]
71+
module = "cerberus.*"
72+
ignore_missing_imports = true
73+
6274
# [project.scripts]
6375
# sdblpy = "sblpy.cli.entrypoint:main"

scripts/run_stability_check.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
# navigate to directory
4+
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
5+
cd $SCRIPTPATH
6+
7+
cd ..
8+
9+
if [ -d ./logs ]; then
10+
echo "log directory exists being removed"
11+
rm -rf ./logs
12+
fi
13+
14+
mkdir logs
15+
16+
ruff check src/ > ./logs/ruff_check.log
17+
black src/
18+
black --check --verbose --diff --color src/ > ./logs/black_check.log
19+
mypy --explicit-package-bases src/ > ./logs/mypy_check.log

src/surrealdb/__init__.py

Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77

88
from surrealdb.data.types.table import Table
99
from surrealdb.data.types.constants import *
10-
from surrealdb.data.types.datetime import DateTimeCompact
1110
from surrealdb.data.types.duration import Duration
1211
from surrealdb.data.types.future import Future
1312
from surrealdb.data.types.geometry import Geometry
1413
from surrealdb.data.types.range import Range
1514
from surrealdb.data.types.record_id import RecordID
15+
from surrealdb.data.types.datetime import IsoDateTimeWrapper
16+
1617

1718
class AsyncSurrealDBMeta(type):
1819

@@ -28,12 +29,20 @@ def __call__(cls, *args, **kwargs):
2829

2930
constructed_url = Url(url)
3031

31-
if constructed_url.scheme == UrlScheme.HTTP or constructed_url.scheme == UrlScheme.HTTPS:
32+
if (
33+
constructed_url.scheme == UrlScheme.HTTP
34+
or constructed_url.scheme == UrlScheme.HTTPS
35+
):
3236
return AsyncHttpSurrealConnection(url=url)
33-
elif constructed_url.scheme == UrlScheme.WS or constructed_url.scheme == UrlScheme.WSS:
37+
elif (
38+
constructed_url.scheme == UrlScheme.WS
39+
or constructed_url.scheme == UrlScheme.WSS
40+
):
3441
return AsyncWsSurrealConnection(url=url)
3542
else:
36-
raise ValueError(f"Unsupported protocol in URL: {url}. Use 'ws://' or 'http://'.")
43+
raise ValueError(
44+
f"Unsupported protocol in URL: {url}. Use 'ws://' or 'http://'."
45+
)
3746

3847

3948
class BlockingSurrealDBMeta(type):
@@ -50,28 +59,57 @@ def __call__(cls, *args, **kwargs):
5059

5160
constructed_url = Url(url)
5261

53-
if constructed_url.scheme == UrlScheme.HTTP or constructed_url.scheme == UrlScheme.HTTPS:
62+
if (
63+
constructed_url.scheme == UrlScheme.HTTP
64+
or constructed_url.scheme == UrlScheme.HTTPS
65+
):
5466
return BlockingHttpSurrealConnection(url=url)
55-
elif constructed_url.scheme == UrlScheme.WS or constructed_url.scheme == UrlScheme.WSS:
67+
elif (
68+
constructed_url.scheme == UrlScheme.WS
69+
or constructed_url.scheme == UrlScheme.WSS
70+
):
5671
return BlockingWsSurrealConnection(url=url)
5772
else:
58-
raise ValueError(f"Unsupported protocol in URL: {url}. Use 'ws://' or 'http://'.")
73+
raise ValueError(
74+
f"Unsupported protocol in URL: {url}. Use 'ws://' or 'http://'."
75+
)
76+
5977

60-
def Surreal(url: Optional[str] = None) -> Union[BlockingWsSurrealConnection, BlockingHttpSurrealConnection]:
78+
def Surreal(
79+
url: Optional[str] = None,
80+
) -> Union[BlockingWsSurrealConnection, BlockingHttpSurrealConnection]:
6181
constructed_url = Url(url)
62-
if constructed_url.scheme == UrlScheme.HTTP or constructed_url.scheme == UrlScheme.HTTPS:
82+
if (
83+
constructed_url.scheme == UrlScheme.HTTP
84+
or constructed_url.scheme == UrlScheme.HTTPS
85+
):
6386
return BlockingHttpSurrealConnection(url=url)
64-
elif constructed_url.scheme == UrlScheme.WS or constructed_url.scheme == UrlScheme.WSS:
87+
elif (
88+
constructed_url.scheme == UrlScheme.WS
89+
or constructed_url.scheme == UrlScheme.WSS
90+
):
6591
return BlockingWsSurrealConnection(url=url)
6692
else:
67-
raise ValueError(f"Unsupported protocol in URL: {url}. Use 'ws://' or 'http://'.")
93+
raise ValueError(
94+
f"Unsupported protocol in URL: {url}. Use 'ws://' or 'http://'."
95+
)
6896

6997

70-
def AsyncSurreal(url: Optional[str] = None) -> Union[AsyncWsSurrealConnection, AsyncHttpSurrealConnection]:
98+
def AsyncSurreal(
99+
url: Optional[str] = None,
100+
) -> Union[AsyncWsSurrealConnection, AsyncHttpSurrealConnection]:
71101
constructed_url = Url(url)
72-
if constructed_url.scheme == UrlScheme.HTTP or constructed_url.scheme == UrlScheme.HTTPS:
102+
if (
103+
constructed_url.scheme == UrlScheme.HTTP
104+
or constructed_url.scheme == UrlScheme.HTTPS
105+
):
73106
return AsyncHttpSurrealConnection(url=url)
74-
elif constructed_url.scheme == UrlScheme.WS or constructed_url.scheme == UrlScheme.WSS:
107+
elif (
108+
constructed_url.scheme == UrlScheme.WS
109+
or constructed_url.scheme == UrlScheme.WSS
110+
):
75111
return AsyncWsSurrealConnection(url=url)
76112
else:
77-
raise ValueError(f"Unsupported protocol in URL: {url}. Use 'ws://' or 'http://'.")
113+
raise ValueError(
114+
f"Unsupported protocol in URL: {url}. Use 'ws://' or 'http://'."
115+
)

0 commit comments

Comments
 (0)