Skip to content

Commit eea2058

Browse files
authored
Bump dependencies and yarn (#151)
* Bump dep * Clean jest config * Switch to yarn 3 * Update yarn.lock for yarn 3 * Fix linter and doc warnings * Exclude .yarn files from trailing pre-commit hook * Fix testing * More test setup fixes * Update python on CI * Revert "More test setup fixes" We need to transpile as we don't use ts-jest * Test increasing the timeout * Wrong guess about timeout usage * Use more reasonable timeout
1 parent 8961aaf commit eea2058

17 files changed

+6332
-6880
lines changed

.github/workflows/test.yml

+7-8
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,18 @@ jobs:
4646
with:
4747
miniforge-variant: Mambaforge
4848
miniforge-version: latest
49-
python-version: "3.7"
49+
python-version: "3.11"
5050

5151
- name: Install dependencies
5252
run: |
53-
mamba install python=${{ matrix.python-version }} pip nodejs=16 yarn
54-
pip install .[test]
53+
mamba install pip nodejs=18
54+
pip install ".[test]"
5555
5656
- name: Build JavaScript assets
5757
working-directory: javascript
5858
run: |
5959
yarn
6060
yarn build
61-
cd ../tests; npm install
6261
6362
- name: Linter check
6463
if: ${{ !contains(matrix.os, 'windows') }}
@@ -78,12 +77,12 @@ jobs:
7877
exit 1
7978
fi
8079
81-
- name: Run Python tests
82-
run: |
83-
pytest -v
84-
8580
- name: Run JS tests
8681
working-directory: javascript
8782
run: |
8883
yarn build:test
8984
yarn test:cov
85+
86+
- name: Run Python tests
87+
run: |
88+
python -m pytest -v

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,12 @@ javascript/tsconfig.tsbuildinfo
136136
javascript/.eslintcache
137137
javascript/coverage/
138138
jupyter_ydoc/_version.py
139+
140+
# Yarn
141+
.pnp.*
142+
.yarn/*
143+
!.yarn/patches
144+
!.yarn/plugins
145+
!.yarn/releases
146+
!.yarn/sdks
147+
!.yarn/versions

.pre-commit-config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ repos:
1414
- id: forbid-new-submodules
1515
- id: check-builtin-literals
1616
- id: trailing-whitespace
17+
exclude: ^\.yarn
1718

1819
- repo: https://github.com/psf/black
1920
rev: 23.1.0

.yarn/releases/yarn-3.4.1.cjs

+873
Large diffs are not rendered by default.

.yarnrc.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
yarnPath: .yarn/releases/yarn-3.4.1.cjs
2+
nodeLinker: node-modules

javascript/jest.config.cjs

-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
* Distributed under the terms of the Modified BSD License.
44
*/
55

6-
const esModules = ['lib0', 'y-protocols', 'y-websocket', 'yjs'].join('|');
7-
86
module.exports = {
97
testEnvironment: 'node',
108
testRegex: 'lib/test/.*.spec.js[x]?$',
11-
129
};

javascript/package.json

+8-9
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040
"watch": "tsc -b --watch"
4141
},
4242
"dependencies": {
43-
"@jupyterlab/nbformat": "^3.0.0 || ^4.0.0-alpha.15",
44-
"@lumino/coreutils": "^1.11.0 || ^2.0.0-alpha.6",
45-
"@lumino/disposable": "^1.10.0 || ^2.0.0-alpha.6",
46-
"@lumino/signaling": "^1.10.0 || ^2.0.0-alpha.6",
43+
"@jupyterlab/nbformat": "^3.0.0 || ^4.0.0-alpha.21 || ^4.0.0",
44+
"@lumino/coreutils": "^1.11.0 || ^2.0.0",
45+
"@lumino/disposable": "^1.10.0 || ^2.0.0",
46+
"@lumino/signaling": "^1.10.0 || ^2.0.0",
4747
"y-protocols": "^1.0.5",
4848
"yjs": "^13.5.40"
4949
},
@@ -56,12 +56,11 @@
5656
"eslint-plugin-jest": "^27.0.0",
5757
"eslint-plugin-prettier": "^4.0.0",
5858
"jest": "^29.0.0",
59-
"prettier": "^2.6.0",
60-
"process": "0.11.10",
61-
"rimraf": "^3.0.0",
59+
"prettier": "^2.8.4",
60+
"rimraf": "^4.4.0",
61+
"tsc-esm-fix": "^2.20.0",
6262
"typedoc": "^0.23.21",
63-
"typescript": "^4.8.0",
64-
"tsc-esm-fix": "^2.20.0"
63+
"typescript": "^4.9.5"
6564
},
6665
"publishConfig": {
6766
"access": "public"

javascript/src/ycell.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export class YBaseCell<Metadata extends nbformat.IBaseCellMetadata>
152152
*
153153
* @param ymodel Cell map
154154
* @param ysource Cell source
155-
* @param options { notebook?: The notebook the cell is attached to }
155+
* @param options \{ notebook?: The notebook the cell is attached to \}
156156
* @param ymetadata Cell metadata
157157
*/
158158
constructor(
@@ -705,7 +705,8 @@ export class YCodeCell
705705
* @param ymodel Cell map
706706
* @param ysource Cell source
707707
* @param youtputs Code cell outputs
708-
* @param options { notebook?: The notebook the cell is attached to }
708+
* @param options \{ notebook?: The notebook the cell is attached to \}
709+
* @param ymetadata Cell metadata
709710
*/
710711
constructor(
711712
ymodel: Y.Map<any>,

javascript/src/ydocument.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,13 @@ export class YDocument<T extends DocumentChange> implements ISharedDocument {
202202
private _disposed = new Signal<this, void>(this);
203203
}
204204

205-
namespace YDocument {
205+
/**
206+
* YDocument namespace
207+
*/
208+
export namespace YDocument {
209+
/**
210+
* YDocument constructor options
211+
*/
206212
export interface IOptions {
207213
/**
208214
* The optional YJS document for YDocument.

javascript/src/ynotebook.ts

+18-16
Original file line numberDiff line numberDiff line change
@@ -485,22 +485,24 @@ export class YNotebook
485485
});
486486
break;
487487
case 'update':
488-
const newValue = ymetadata.get(key);
489-
const oldValue = change.oldValue;
490-
let equal = true;
491-
if (typeof oldValue == 'object' && typeof newValue == 'object') {
492-
equal = JSONExt.deepEqual(oldValue, newValue);
493-
} else {
494-
equal = oldValue === newValue;
495-
}
496-
497-
if (!equal) {
498-
this._metadataChanged.emit({
499-
key,
500-
type: 'change',
501-
oldValue,
502-
newValue
503-
});
488+
{
489+
const newValue = ymetadata.get(key);
490+
const oldValue = change.oldValue;
491+
let equal = true;
492+
if (typeof oldValue == 'object' && typeof newValue == 'object') {
493+
equal = JSONExt.deepEqual(oldValue, newValue);
494+
} else {
495+
equal = oldValue === newValue;
496+
}
497+
498+
if (!equal) {
499+
this._metadataChanged.emit({
500+
key,
501+
type: 'change',
502+
oldValue,
503+
newValue
504+
});
505+
}
504506
}
505507
break;
506508
}

javascript/test/ycell.spec.ts

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
import { IMapChange, YCodeCell, YNotebook } from '../src';
66

77
describe('@jupyter/ydoc', () => {
8+
// Fix awareness timeout open handle
9+
beforeEach(() => {
10+
jest.useFakeTimers();
11+
});
12+
afterEach(() => {
13+
jest.clearAllTimers();
14+
});
15+
816
describe('YCell standalone', () => {
917
test('should set source', () => {
1018
const codeCell = YCodeCell.create();

javascript/test/ynotebook.spec.ts

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ import type * as nbformat from '@jupyterlab/nbformat';
55
import { IMapChange, NotebookChange, YNotebook } from '../src';
66

77
describe('@jupyter/ydoc', () => {
8+
// Fix awareness timeout open handle
9+
beforeEach(() => {
10+
jest.useFakeTimers();
11+
});
12+
afterEach(() => {
13+
jest.clearAllTimers();
14+
});
15+
816
describe('YNotebook', () => {
917
describe('#constructor', () => {
1018
test('should create a notebook without arguments', () => {

package.json

+3-5
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
"tests"
99
],
1010
"scripts": {
11-
"build": "lerna run build",
12-
"test": "lerna run build:test && lerna run test"
11+
"build": "cd javascript && yarn run build",
12+
"test": "cd javascript && yarn run build:test && yarn run test"
1313
},
14-
"devDependencies": {
15-
"lerna": "^6.3.0"
16-
}
14+
"packageManager": "[email protected]"
1715
}

tests/conftest.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def yjs_client(request):
4242
client_id = request.param
4343
p = subprocess.Popen(
4444
[
45+
"yarn",
4546
"node",
46-
"--experimental-specifier-resolution=node",
4747
f"{here / 'yjs_client_'}{client_id}.js",
4848
]
4949
)

tests/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "@jupyter/ydoc-test",
33
"version": "0.0.1",
4-
"private": "true",
4+
"private": true,
55
"type": "module",
66
"dependencies": {
7-
"@jupyter/ydoc": "file:../javascript",
7+
"@jupyter/ydoc": "workspace:javascript",
88
"ws": "^8.5.0",
99
"y-websocket": "^1.4.1"
1010
}

tests/test_ypy_yjs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ async def test_ypy_yjs_0(yws_server, yjs_client):
5757
WebsocketProvider(ydoc, websocket)
5858
nb = stringify_source(json.loads((files_dir / "nb0.ipynb").read_text()))
5959
ynotebook.source = nb
60-
ytest = YTest(ydoc)
60+
ytest = YTest(ydoc, 3.0)
6161
await ytest.change()
6262
assert ytest.source == nb
6363

0 commit comments

Comments
 (0)