Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into chore/pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
fantix committed Jan 11, 2024
2 parents dbb3b3e + c916eef commit 2ea2509
Show file tree
Hide file tree
Showing 16 changed files with 64 additions and 21 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ jobs:
LOOP_IMPL: ${{ matrix.loop }}
SERVER_VERSION: ${{ matrix.edgedb-version }}
run: |
if [ "${SERVER_VERSION}" = "nightly" ]; then
export EDGEDB_TEST_CODEGEN_ASSERT_SUFFIX=.assert4
fi
if [ "${LOOP_IMPL}" = "uvloop" ]; then
env USE_UVLOOP=1 python -m unittest -v tests.suite
else
Expand Down
4 changes: 2 additions & 2 deletions docs/api/asyncio_client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,8 @@ Python code. Here is an example:
)
In the above example, the execution of the HTTP request would be retried
too. The core of the issue is that whenever transaction is interrupted
user might have the email changed (as the result of concurrent
too. The core of the issue is that whenever a transaction is interrupted
the user's email might have been changed (as the result of a concurrent
transaction), so we have to redo all the work done.

Generally it's recommended to not execute any long running
Expand Down
4 changes: 2 additions & 2 deletions docs/api/blocking_client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,8 @@ Python code. Here is an example:
)
In the above example, the execution of the HTTP request would be retried
too. The core of the issue is that whenever transaction is interrupted
user might have the email changed (as the result of concurrent
too. The core of the issue is that whenever a transaction is interrupted
the user's email might have been changed (as the result of a concurrent
transaction), so we have to redo all the work done.

Generally it's recommended to not execute any long running
Expand Down
2 changes: 1 addition & 1 deletion docs/api/types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Objects

.. versionchanged:: 1.0

``edgedb.Object.__hash__`` is just ``object.__hash__` in version 1.0.
``edgedb.Object.__hash__`` is just ``object.__hash__`` in version 1.0.
Similarly, ``==`` is equivalent to the ``is`` operator comparing
``edgedb.Object`` instances, and ``<``, ``<=``, ``>``, ``>=`` are not
allowed on ``edgedb.Object`` instances.
Expand Down
7 changes: 7 additions & 0 deletions edgedb/codegen/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,15 @@

PYDANTIC_MIXIN = """\
class NoPydanticValidation:
@classmethod
def __get_pydantic_core_schema__(cls, _source_type, _handler):
# Pydantic 2.x
from pydantic_core.core_schema import any_schema
return any_schema()
@classmethod
def __get_validators__(cls):
# Pydantic 1.x
from pydantic.dataclasses import dataclass as pydantic_dataclass
pydantic_dataclass(cls)
cls.__pydantic_model__.__get_validators__ = lambda: []
Expand Down
12 changes: 4 additions & 8 deletions edgedb/datatypes/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,6 @@ EdgeObject_New(PyObject *desc)
return NULL;
}

if (EdgeRecordDesc_IDPos(desc) < 0) {
PyErr_SetString(
PyExc_ValueError,
"Cannot create Object without 'id' field");
return NULL;
}

Py_ssize_t size = EdgeRecordDesc_GetSize(desc);

if (size > EDGE_MAX_TUPLE_SIZE) {
Expand Down Expand Up @@ -137,7 +130,10 @@ EdgeObject_GetID(PyObject *ob)
assert(EdgeObject_Check(ob));
EdgeObject *o = (EdgeObject *)ob;
Py_ssize_t i = EdgeRecordDesc_IDPos(o->desc);
if (i < 0 || i >= Py_SIZE(o)) {
if (i < 0) {
Py_RETURN_NONE;
}
if (i >= Py_SIZE(o)) {
PyErr_BadInternalCall();
return NULL;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ import uuid


class NoPydanticValidation:
@classmethod
def __get_pydantic_core_schema__(cls, _source_type, _handler):
# Pydantic 2.x
from pydantic_core.core_schema import any_schema
return any_schema()

@classmethod
def __get_validators__(cls):
# Pydantic 1.x
from pydantic.dataclasses import dataclass as pydantic_dataclass
pydantic_dataclass(cls)
cls.__pydantic_model__.__get_validators__ = lambda: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@ import uuid


class NoPydanticValidation:
@classmethod
def __get_pydantic_core_schema__(cls, _source_type, _handler):
# Pydantic 2.x
from pydantic_core.core_schema import any_schema
return any_schema()

@classmethod
def __get_validators__(cls):
# Pydantic 1.x
from pydantic.dataclasses import dataclass as pydantic_dataclass
pydantic_dataclass(cls)
cls.__pydantic_model__.__get_validators__ = lambda: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ import uuid


class NoPydanticValidation:
@classmethod
def __get_pydantic_core_schema__(cls, _source_type, _handler):
# Pydantic 2.x
from pydantic_core.core_schema import any_schema
return any_schema()

@classmethod
def __get_validators__(cls):
# Pydantic 1.x
from pydantic.dataclasses import dataclass as pydantic_dataclass
pydantic_dataclass(cls)
cls.__pydantic_model__.__get_validators__ = lambda: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ import uuid


class NoPydanticValidation:
@classmethod
def __get_pydantic_core_schema__(cls, _source_type, _handler):
# Pydantic 2.x
from pydantic_core.core_schema import any_schema
return any_schema()

@classmethod
def __get_validators__(cls):
# Pydantic 1.x
from pydantic.dataclasses import dataclass as pydantic_dataclass
pydantic_dataclass(cls)
cls.__pydantic_model__.__get_validators__ = lambda: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ import uuid


class NoPydanticValidation:
@classmethod
def __get_pydantic_core_schema__(cls, _source_type, _handler):
# Pydantic 2.x
from pydantic_core.core_schema import any_schema
return any_schema()

@classmethod
def __get_validators__(cls):
# Pydantic 1.x
from pydantic.dataclasses import dataclass as pydantic_dataclass
pydantic_dataclass(cls)
cls.__pydantic_model__.__get_validators__ = lambda: []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@ MyScalar = int


class NoPydanticValidation:
@classmethod
def __get_pydantic_core_schema__(cls, _source_type, _handler):
# Pydantic 2.x
from pydantic_core.core_schema import any_schema
return any_schema()

@classmethod
def __get_validators__(cls):
# Pydantic 1.x
from pydantic.dataclasses import dataclass as pydantic_dataclass
pydantic_dataclass(cls)
cls.__pydantic_model__.__get_validators__ = lambda: []
Expand Down
4 changes: 2 additions & 2 deletions tests/datatypes/test_datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,8 @@ def test_object_5(self):
f = private.create_object_factory(
a="property", lb="link-property", c="property"
)
with self.assertRaisesRegex(ValueError, "without 'id' field"):
f(1, 2, 3)
x = f(1, 2, 3)
self.assertFalse(hasattr(x, 'id'))

def test_object_6(self):
User = private.create_object_factory(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_async_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,7 @@ async def test_dup_link_prop_name(self):
)

async def test_transaction_state(self):
with self.assertRaisesRegex(edgedb.QueryError, "cannot assign to id"):
with self.assertRaisesRegex(edgedb.QueryError, "cannot assign to.*id"):
async for tx in self.client.transaction():
async with tx:
await tx.execute(
Expand Down
3 changes: 2 additions & 1 deletion tests/test_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
from edgedb import _testbase as tb


ASSERT_SUFFIX = os.environ.get("EDGEDB_TEST_CODEGEN_ASSERT_SUFFIX", ".assert")
# Use ".assert" for EdgeDB 3.x and lower
ASSERT_SUFFIX = os.environ.get("EDGEDB_TEST_CODEGEN_ASSERT_SUFFIX", ".assert4")


class TestCodegen(tb.AsyncQueryTestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_sync_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ def test_sync_banned_transaction(self):
self.client.execute("start transaction")

def test_transaction_state(self):
with self.assertRaisesRegex(edgedb.QueryError, "cannot assign to id"):
with self.assertRaisesRegex(edgedb.QueryError, "cannot assign to.*id"):
for tx in self.client.transaction():
with tx:
tx.execute(
Expand Down

0 comments on commit 2ea2509

Please sign in to comment.