Skip to content

Commit 803631d

Browse files
Update python>=3.8, pycrdt>=0.8.11, pre-commit, README (#217)
1 parent abb51ba commit 803631d

10 files changed

+37
-53
lines changed

.pre-commit-config.yaml

+5-33
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,9 @@ repos:
1616
- id: trailing-whitespace
1717
exclude: ^\.yarn
1818

19-
- repo: https://github.com/psf/black
20-
rev: 24.2.0
19+
- repo: https://github.com/astral-sh/ruff-pre-commit
20+
rev: v0.2.1
2121
hooks:
22-
- id: black
23-
args: ["--line-length", "100"]
24-
25-
- repo: https://github.com/PyCQA/isort
26-
rev: 5.13.2
27-
hooks:
28-
- id: isort
29-
files: \.py$
30-
args: [--profile=black]
31-
32-
- repo: https://github.com/asottile/pyupgrade
33-
rev: v3.15.0
34-
hooks:
35-
- id: pyupgrade
36-
args: [--py37-plus]
37-
38-
- repo: https://github.com/PyCQA/doc8
39-
rev: v1.1.1
40-
hooks:
41-
- id: doc8
42-
args: [--max-line-length=200]
43-
exclude: docs/source/other/full-config.rst
44-
stages: [manual]
45-
46-
- repo: https://github.com/pycqa/flake8
47-
rev: 7.0.0
48-
hooks:
49-
- id: flake8
50-
additional_dependencies:
51-
["flake8-bugbear==22.6.22", "flake8-implicit-str-concat==0.2.0", "flake8-pyproject"]
52-
stages: [manual]
22+
- id: ruff
23+
args: [--fix, --show-fixes]
24+
- id: ruff-format

README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# jupyter_ydoc
77

8-
`jupyter_ydoc` provides [Ypy](https://github.com/y-crdt/ypy)-based data structures for various
8+
`jupyter_ydoc` provides [pycrdt](https://github.com/jupyter-server/pycrdt)-based data structures for various
99
documents used in the Jupyter ecosystem. Built-in documents include:
1010
- `YBlob`: a generic immutable binary document.
1111
- `YUnicode`: a generic UTF8-encoded text document (`YFile` is an alias to `YUnicode`).
@@ -29,9 +29,11 @@ print(ydocs)
2929
Which is just a shortcut to:
3030

3131
```py
32-
import pkg_resources
32+
from importlib.metadata import entry_points
33+
# for Python < 3.10, install importlib_metadata and do:
34+
# from importlib_metadata import entry_points
3335

34-
ydocs = {ep.name: ep.load() for ep in pkg_resources.iter_entry_points(group="jupyter_ydoc")}
36+
ydocs = {ep.name: ep.load() for ep in entry_points(group="jupyter_ydoc")}
3537
```
3638

3739
Or directly import them:

jupyter_ydoc/__init__.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
import sys
55

6-
from ._version import __version__ # noqa
7-
from .yblob import YBlob # noqa
8-
from .yfile import YFile # noqa
9-
from .ynotebook import YNotebook # noqa
10-
from .yunicode import YUnicode # noqa
6+
from ._version import __version__ as __version__
7+
from .yblob import YBlob as YBlob
8+
from .yfile import YFile as YFile
9+
from .ynotebook import YNotebook as YNotebook
10+
from .yunicode import YUnicode as YUnicode
1111

1212
# See compatibility note on `group` keyword in
1313
# https://docs.python.org/3/library/importlib.metadata.html#entry-points

jupyter_ydoc/ybasedoc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def __init__(self, ydoc: Optional[Doc] = None):
2626
self._ydoc = Doc()
2727
else:
2828
self._ydoc = ydoc
29-
self._ydoc["state"] = self._ystate = Map()
29+
self._ystate = self._ydoc.get("state", type=Map)
3030
self._subscriptions: Dict[Any, str] = {}
3131

3232
@property

jupyter_ydoc/yblob.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __init__(self, ydoc: Optional[Doc] = None):
3232
:type ydoc: :class:`pycrdt.Doc`, optional.
3333
"""
3434
super().__init__(ydoc)
35-
self._ydoc["source"] = self._ysource = Map()
35+
self._ysource = self._ydoc.get("source", type=Map)
3636

3737
@property
3838
def version(self) -> str:

jupyter_ydoc/ynotebook.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ def __init__(self, ydoc: Optional[Doc] = None):
5454
:type ydoc: :class:`pycrdt.Doc`, optional.
5555
"""
5656
super().__init__(ydoc)
57-
self._ydoc["meta"] = self._ymeta = Map()
58-
self._ydoc["cells"] = self._ycells = Array()
57+
self._ymeta = self._ydoc.get("meta", type=Map)
58+
self._ycells = self._ydoc.get("cells", type=Array)
5959

6060
@property
6161
def version(self) -> str:

jupyter_ydoc/yunicode.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def __init__(self, ydoc: Optional[Doc] = None):
3131
:type ydoc: :class:`pycrdt.Doc`, optional.
3232
"""
3333
super().__init__(ydoc)
34-
self._ydoc["source"] = self._ysource = Text()
34+
self._ysource = self._ydoc.get("source", type=Text)
3535

3636
@property
3737
def version(self) -> str:

pyproject.toml

+15-5
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ build-backend = "hatchling.build"
99
name = "jupyter-ydoc"
1010
dynamic = ["version"]
1111
description = "Document structures for collaborative editing using Ypy"
12-
requires-python = ">=3.7"
13-
keywords = ["jupyter", "ypy"]
12+
requires-python = ">=3.8"
13+
keywords = ["jupyter", "pycrdt", "yjs"]
1414
dependencies = [
1515
"importlib_metadata >=3.6; python_version<'3.10'",
16-
"pycrdt >=0.8.3,<0.9.0",
16+
"pycrdt >=0.8.11,<0.9.0",
1717
]
1818

1919
[[project.authors]]
@@ -82,5 +82,15 @@ before-bump-version = ["pip install -e .[dev]"]
8282
[tool.jupyter-releaser.options]
8383
version_cmd = "hatch version"
8484

85-
[tool.flake8]
86-
max-line-length = 100
85+
[tool.ruff]
86+
line-length = 100
87+
lint.select = [
88+
"ASYNC", # flake8-async
89+
"E", "F", "W", # default Flake8
90+
"G", # flake8-logging-format
91+
"I", # isort
92+
"ISC", # flake8-implicit-str-concat
93+
"PGH", # pygrep-hooks
94+
"RUF100", # unused noqa (yesqa)
95+
"UP", # pyupgrade
96+
]

tests/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import pytest
99
from pycrdt_websocket import WebsocketServer
10-
from websockets import serve # type: ignore
10+
from websockets import serve
1111

1212
# workaround until these PRs are merged:
1313
# - https://github.com/yjs/y-websocket/pull/104

tests/test_pycrdt_yjs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from anyio import Event, create_task_group, move_on_after
99
from pycrdt import Doc, Map
1010
from pycrdt_websocket import WebsocketProvider
11-
from websockets import connect # type: ignore
11+
from websockets import connect
1212

1313
from jupyter_ydoc import YNotebook
1414
from jupyter_ydoc.utils import cast_all

0 commit comments

Comments
 (0)