Skip to content

Update python>=3.8, pycrdt>=0.8.11, pre-commit, README #217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2024
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
38 changes: 5 additions & 33 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,9 @@ repos:
- id: trailing-whitespace
exclude: ^\.yarn

- repo: https://github.com/psf/black
rev: 24.2.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.1
hooks:
- id: black
args: ["--line-length", "100"]

- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
files: \.py$
args: [--profile=black]

- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py37-plus]

- repo: https://github.com/PyCQA/doc8
rev: v1.1.1
hooks:
- id: doc8
args: [--max-line-length=200]
exclude: docs/source/other/full-config.rst
stages: [manual]

- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies:
["flake8-bugbear==22.6.22", "flake8-implicit-str-concat==0.2.0", "flake8-pyproject"]
stages: [manual]
- id: ruff
args: [--fix, --show-fixes]
- id: ruff-format
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# jupyter_ydoc

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

```py
import pkg_resources
from importlib.metadata import entry_points
# for Python < 3.10, install importlib_metadata and do:
# from importlib_metadata import entry_points

ydocs = {ep.name: ep.load() for ep in pkg_resources.iter_entry_points(group="jupyter_ydoc")}
ydocs = {ep.name: ep.load() for ep in entry_points(group="jupyter_ydoc")}
```

Or directly import them:
Expand Down
10 changes: 5 additions & 5 deletions jupyter_ydoc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

import sys

from ._version import __version__ # noqa
from .yblob import YBlob # noqa
from .yfile import YFile # noqa
from .ynotebook import YNotebook # noqa
from .yunicode import YUnicode # noqa
from ._version import __version__ as __version__
from .yblob import YBlob as YBlob
from .yfile import YFile as YFile
from .ynotebook import YNotebook as YNotebook
from .yunicode import YUnicode as YUnicode

# See compatibility note on `group` keyword in
# https://docs.python.org/3/library/importlib.metadata.html#entry-points
Expand Down
2 changes: 1 addition & 1 deletion jupyter_ydoc/ybasedoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, ydoc: Optional[Doc] = None):
self._ydoc = Doc()
else:
self._ydoc = ydoc
self._ydoc["state"] = self._ystate = Map()
self._ystate = self._ydoc.get("state", type=Map)
self._subscriptions: Dict[Any, str] = {}

@property
Expand Down
2 changes: 1 addition & 1 deletion jupyter_ydoc/yblob.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, ydoc: Optional[Doc] = None):
:type ydoc: :class:`pycrdt.Doc`, optional.
"""
super().__init__(ydoc)
self._ydoc["source"] = self._ysource = Map()
self._ysource = self._ydoc.get("source", type=Map)

@property
def version(self) -> str:
Expand Down
4 changes: 2 additions & 2 deletions jupyter_ydoc/ynotebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def __init__(self, ydoc: Optional[Doc] = None):
:type ydoc: :class:`pycrdt.Doc`, optional.
"""
super().__init__(ydoc)
self._ydoc["meta"] = self._ymeta = Map()
self._ydoc["cells"] = self._ycells = Array()
self._ymeta = self._ydoc.get("meta", type=Map)
self._ycells = self._ydoc.get("cells", type=Array)

@property
def version(self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion jupyter_ydoc/yunicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self, ydoc: Optional[Doc] = None):
:type ydoc: :class:`pycrdt.Doc`, optional.
"""
super().__init__(ydoc)
self._ydoc["source"] = self._ysource = Text()
self._ysource = self._ydoc.get("source", type=Text)

@property
def version(self) -> str:
Expand Down
20 changes: 15 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ build-backend = "hatchling.build"
name = "jupyter-ydoc"
dynamic = ["version"]
description = "Document structures for collaborative editing using Ypy"
requires-python = ">=3.7"
keywords = ["jupyter", "ypy"]
requires-python = ">=3.8"
keywords = ["jupyter", "pycrdt", "yjs"]
dependencies = [
"importlib_metadata >=3.6; python_version<'3.10'",
"pycrdt >=0.8.3,<0.9.0",
"pycrdt >=0.8.11,<0.9.0",
]

[[project.authors]]
Expand Down Expand Up @@ -82,5 +82,15 @@ before-bump-version = ["pip install -e .[dev]"]
[tool.jupyter-releaser.options]
version_cmd = "hatch version"

[tool.flake8]
max-line-length = 100
[tool.ruff]
line-length = 100
lint.select = [
"ASYNC", # flake8-async
"E", "F", "W", # default Flake8
"G", # flake8-logging-format
"I", # isort
"ISC", # flake8-implicit-str-concat
"PGH", # pygrep-hooks
"RUF100", # unused noqa (yesqa)
"UP", # pyupgrade
]
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import pytest
from pycrdt_websocket import WebsocketServer
from websockets import serve # type: ignore
from websockets import serve

# workaround until these PRs are merged:
# - https://github.com/yjs/y-websocket/pull/104
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pycrdt_yjs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from anyio import Event, create_task_group, move_on_after
from pycrdt import Doc, Map
from pycrdt_websocket import WebsocketProvider
from websockets import connect # type: ignore
from websockets import connect

from jupyter_ydoc import YNotebook
from jupyter_ydoc.utils import cast_all
Expand Down