Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Test

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.12' ]
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- uses: dtolnay/rust-toolchain@stable

- name: Set up venv and install dependencies
run: |
python -m venv .venv
. .venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
pip install maturin

- name: Build and install package
run: |
. .venv/bin/activate
maturin develop --quiet

- name: Run tests
run: |
. .venv/bin/activate
pytest -q


4 changes: 2 additions & 2 deletions src/awareness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ impl Awareness {
Self(loro::awareness::Awareness::new(peer, timeout))
}

pub fn encode(&self, peers: Vec<PeerID>) -> Cow<[u8]> {
pub fn encode(&self, peers: Vec<PeerID>) -> Cow<'_, [u8]> {
let ans: Vec<u8> = self.0.encode(&peers);
Cow::Owned(ans)
}

pub fn encode_all(&self) -> Cow<[u8]> {
pub fn encode_all(&self) -> Cow<'_, [u8]> {
let ans: Vec<u8> = self.0.encode_all();
Cow::Owned(ans)
}
Expand Down
2 changes: 1 addition & 1 deletion src/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pub fn pyobject_to_loro_value(obj: &Bound<'_, PyAny>) -> PyResult<loro::LoroValu
Err(PyTypeError::new_err("Invalid LoroValue"))
}

pub fn loro_value_to_pyobject(py: Python, value: LoroValue) -> PyResult<Bound<'_, PyAny>> {
pub fn loro_value_to_pyobject(py: Python<'_>, value: LoroValue) -> PyResult<Bound<'_, PyAny>> {
match value.0 {
loro::LoroValue::Null => Ok(py.None().into_pyobject(py)?.into_any().into_bound()),
loro::LoroValue::Bool(b) => Ok(PyBool::new(py, b)
Expand Down
2 changes: 1 addition & 1 deletion src/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ impl LoroDoc {
}

/// Export the document in the given mode.
pub fn export(&self, mode: ExportMode) -> PyLoroResult<Cow<[u8]>> {
pub fn export(&self, mode: ExportMode) -> PyLoroResult<Cow<'_, [u8]>> {
let ans = self.doc.export(mode.into())?;
Ok(Cow::Owned(ans))
}
Expand Down
4 changes: 2 additions & 2 deletions src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl Frontiers {
))
}

pub fn encode(&self) -> Cow<[u8]> {
pub fn encode(&self) -> Cow<'_, [u8]> {
let ans: Vec<u8> = self.0.encode();
Cow::Owned(ans)
}
Expand Down Expand Up @@ -311,7 +311,7 @@ impl VersionVector {
}

#[inline(always)]
pub fn encode(&self) -> Cow<[u8]> {
pub fn encode(&self) -> Cow<'_, [u8]> {
let ans: Vec<u8> = self.0.encode();
Cow::Owned(ans)
}
Expand Down
5 changes: 1 addition & 4 deletions tests/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
from loro import LoroDoc, ExportMode, VersionVector, LORO_VERSION

def test_version():
assert LORO_VERSION == "1.4.2"
from loro import LoroDoc, ExportMode, VersionVector

def test_basic():
doc = LoroDoc()
Expand Down