Skip to content

Commit

Permalink
Fix YDoc client_id type and name
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart committed Mar 21, 2022
1 parent 6863eeb commit 9a22259
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/y_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ pub struct YDoc(pub Doc);

#[pymethods]
impl YDoc {
/// Creates a new Ypy document. If `id` parameter was passed it will be used as this document
/// globally unique identifier (it's up to caller to ensure that requirement). Otherwise it will
/// be assigned a randomly generated number.
/// Creates a new Ypy document. If `client_id` parameter was passed it will be used as this
/// document globally unique identifier (it's up to caller to ensure that requirement).
/// Otherwise it will be assigned a randomly generated number.
#[new]
pub fn new(
client_id: Option<u64>,
Expand Down Expand Up @@ -72,8 +72,8 @@ impl YDoc {

/// Gets globally unique identifier of this `YDoc` instance.
#[getter]
pub fn id(&self) -> f64 {
self.0.client_id as f64
pub fn client_id(&self) -> u64 {
self.0.client_id as u64
}

/// Returns a new transaction for this document. Ypy shared data types execute their
Expand Down
2 changes: 1 addition & 1 deletion tests/test_y_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_inserts_nested():

def test_delete():
d1 = YDoc(1)
assert d1.id == 1
assert d1.client_id == 1
x = d1.get_array("test")

d1.transact(lambda txn: x.insert(txn, 0, [1, 2, ["hello", "world"], True]))
Expand Down
2 changes: 1 addition & 1 deletion tests/test_y_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def test_constructor_options():
# Ensure that valid versions can be called without error
YDoc()
with_id = YDoc(1)
assert with_id.id == 1
assert with_id.client_id == 1
YDoc(1, "utf-8", True)
YDoc(client_id=2, offset_kind="utf-8", skip_gc=True)
YDoc(client_id=3)
Expand Down
8 changes: 4 additions & 4 deletions y_py.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ class YDoc:
print(output)
"""

id: float
client_id: int
def __init__(
self,
client_id: Optional[int],
offset_kind: Optional[str],
skip_gc: Optional[bool],
):
"""
Creates a new Ypy document. If `id` parameter was passed it will be used as this document
globally unique identifier (it's up to caller to ensure that requirement). Otherwise it will
be assigned a randomly generated number.
Creates a new Ypy document. If `client_id` parameter was passed it will be used as this
document globally unique identifier (it's up to caller to ensure that requirement).
Otherwise it will be assigned a randomly generated number.
"""
def begin_transaction(self) -> YTransaction:
"""
Expand Down

0 comments on commit 9a22259

Please sign in to comment.