Skip to content

Commit

Permalink
Update pre-commit to use jlpm lint
Browse files Browse the repository at this point in the history
.github workflow changed from Python3.8 to Python3.10
  • Loading branch information
Alan Fleming committed Feb 1, 2024
1 parent 2f34cab commit ca386a7
Show file tree
Hide file tree
Showing 17 changed files with 223 additions and 165 deletions.
109 changes: 55 additions & 54 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,81 +2,82 @@ name: Build

on:
push:
branches: main
branches:
- main
pull_request:
branches: '*'
branches:
- '*'

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3

- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Install dependencies
run: python -m pip install -U "jupyterlab>=4.0.0,<5"
- name: Install dependencies
run: python -m pip install -U "jupyterlab>=4.0.0,<5"

- name: Lint the extension
run: |
set -eux
jlpm
jlpm run lint:check
- name: Lint the extension
run: |
set -eux
jlpm
jlpm run lint:check
- name: Build the extension
run: |
set -eux
python -m pip install .[test]
- name: Build the extension
run: |
set -eux
python -m pip install .[test]
jupyter labextension list
jupyter labextension list 2>&1 | grep -ie "ipylab.*OK"
python -m jupyterlab.browser_check
jupyter labextension list
jupyter labextension list 2>&1 | grep -ie "ipylab.*OK"
python -m jupyterlab.browser_check
- name: Package the extension
run: |
set -eux
- name: Package the extension
run: |
set -eux
pip install build
python -m build
pip uninstall -y "ipylab" jupyterlab
pip install build
python -m build
pip uninstall -y "ipylab" jupyterlab
- name: Upload extension packages
uses: actions/upload-artifact@v3
with:
name: extension-artifacts
path: dist/ipylab*
if-no-files-found: error
- name: Upload extension packages
uses: actions/upload-artifact@v3
with:
name: extension-artifacts
path: dist/ipylab*
if-no-files-found: error

test_isolated:
needs: build
runs-on: ubuntu-latest

steps:
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
architecture: 'x64'
- uses: actions/download-artifact@v3
with:
name: extension-artifacts
- name: Install and Test
run: |
set -eux
# Remove NodeJS, twice to take care of system and locally installed node versions.
sudo rm -rf $(which node)
sudo rm -rf $(which node)
pip install "jupyterlab>=4.0.0,<5" ipylab*.whl
jupyter labextension list
jupyter labextension list 2>&1 | grep -ie "ipylab.*OK"
python -m jupyterlab.browser_check --no-browser-test
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
architecture: 'x64'
- uses: actions/download-artifact@v3
with:
name: extension-artifacts
- name: Install and Test
run: |
set -eux
# Remove NodeJS, twice to take care of system and locally installed node versions.
sudo rm -rf $(which node)
sudo rm -rf $(which node)
pip install "jupyterlab>=4.0.0,<5" ipylab*.whl
jupyter labextension list
jupyter labextension list 2>&1 | grep -ie "ipylab.*OK"
python -m jupyterlab.browser_check --no-browser-test
check_links:
name: Check Links
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
name: Check Release
on:
push:
branches: ["main"]
branches:
- main
pull_request:
branches: ["*"]
branches:
- '*'

jobs:
check_release:
Expand All @@ -16,7 +18,6 @@ jobs:
- name: Check Release
uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v2
with:

token: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Distributions
Expand Down
44 changes: 23 additions & 21 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,36 @@ name: Lint

on:
push:
branches: [ main ]
branches:
- main
pull_request:
branches: '*'
branches:
- '*'

jobs:
lint_ts:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- name: Install JupyterLab
run: python -m pip install 'jupyterlab >=3.1,<4'
- name: Lint TypeScript
run: |
jlpm
jlpm run lint:check
- name: Checkout
uses: actions/checkout@v3
- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- name: Install JupyterLab
run: python -m pip install 'jupyterlab >=4,<5'
- name: Lint TypeScript
run: |
jlpm
jlpm run lint:check
lint_python:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- name: Install black
run: python -m pip install black
- name: Lint Python
run: |
black --check .
- name: Checkout
uses: actions/checkout@v3
- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- name: Install ruff
run: python -m pip install ruff
- name: Lint Python
run: |
ruff --check .
56 changes: 29 additions & 27 deletions .github/workflows/packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ name: Packaging

on:
push:
branches: [ main ]
branches:
- main
pull_request:
branches: '*'
branches:
- '*'

env:
PIP_DISABLE_PIP_VERSION_CHECK: 1
Expand All @@ -17,29 +19,29 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- name: Install dependencies
run: |
python -m pip install "jupyterlab>=4,<5" build
- name: Build pypi distributions
run: |
python -m build
- name: Build npm distributions
run: |
npm pack
cp *.tgz dist
- name: Build checksum file
run: |
cd dist
sha256sum * | tee SHA256SUMS
- name: Upload distributions
uses: actions/upload-artifact@v3
with:
name: dist ${{ github.run_number }}
path: ./dist
- name: Checkout
uses: actions/checkout@v3
- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1
- name: Install dependencies
run: |
python -m pip install "jupyterlab>=4,<5" build
- name: Build pypi distributions
run: |
python -m build
- name: Build npm distributions
run: |
npm pack
cp *.tgz dist
- name: Build checksum file
run: |
cd dist
sha256sum * | tee SHA256SUMS
- name: Upload distributions
uses: actions/upload-artifact@v3
with:
name: dist ${{ github.run_number }}
path: ./dist

install:
runs-on: ${{ matrix.os }}-latest
Expand All @@ -48,9 +50,9 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
python: ['3.8', '3.11']
python: ['3.10', '3.11']
include:
- python: '3.8'
- python: '3.10'
dist: 'ipylab*.tar.gz'
- python: '3.11'
dist: 'ipylab*.whl'
Expand Down
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ci:
- prettier
- eslint
- stylelint
- jlpm-lint
- ruff-format-hatch-settings
default_language_version:
node: system
repos:
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
},
"editor.formatOnSave": true,
"python.terminal.activateEnvInCurrentTerminal": true,
"python.createEnvironment.trigger": "prompt",
"python.createEnvironment.trigger": "prompt"
}
9 changes: 5 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

### Enhancements made

- Upgraded to provide asynchronous bi-directional comms for performing operations
- Upgraded to provide asynchronous bi-directional comms for performing operations
in the Frontend. Each operation returns a task that when complete returns the response or raise an error if unsuccessful.
- On the Python side `JupyterFrontEnd`, `CommandRegistry`, & `CommandPalette`
are all derived from `AsyncWidgetBase` and are now single instance objects.
- On the Python side `JupyterFrontEnd`, `CommandRegistry`, & `CommandPalette`
are all derived from `AsyncWidgetBase` and are now single instance objects.
- On the JavaScript frontend side `JupyterFrontendModel`, `CommandRegistryModel`,
`CommandPalletModel`, extend the new `IpylabModel`.
`CommandPalletModel`, extend the new `IpylabModel`.

### Added

Expand All @@ -24,6 +24,7 @@ are all derived from `AsyncWidgetBase` and are now single instance objects.
- app.dialogs described [here](https://jupyterlab.readthedocs.io/en/stable/extension/ui_helpers.html#user-interface-helpers).

### Removed

- Callback functionality
- Drop Python < 3.11
- Drop Jupyterlab < 4.0
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ jlpm && jlpm run build
pip install pre-commit
pre-commit install

# Use jlpm script to lint the JS
jlpm lint
#or
jlpm lint:check


```

Expand Down
15 changes: 11 additions & 4 deletions src/widgets/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ export class CommandRegistryModel extends IpylabModel {
this._commands = IpylabModel.app.commands;
super.initialize(attributes, options);
this.on('comm_live_update', () => {
if (!this.comm_live)
if (!this.comm_live) {
Private.customCommands.values().forEach(command => command.dispose());
}
});

this._commands.commandChanged.connect(this._sendCommandList, this);
Expand Down Expand Up @@ -90,7 +91,9 @@ export class CommandRegistryModel extends IpylabModel {
*/
private _sendCommandList(sender?: object, args?: any): void {
// this._commands.notifyCommandChanged();
if (args && args.type != 'added' && args.type != 'removed') return;
if (args && args.type !== 'added' && args.type !== 'removed') {
return;
}
this.set('commands', this._commands.listCommands());
this.save_changes();
}
Expand All @@ -109,7 +112,9 @@ export class CommandRegistryModel extends IpylabModel {
const { id, caption, label, iconClass, icon } = options;
if (this._commands.hasCommand(id)) {
const cmd = Private.customCommands.get(id);
if (cmd) cmd.dispose();
if (cmd) {
cmd.dispose();
}
}

let labIcon: LabIcon | null = null;
Expand Down Expand Up @@ -150,7 +155,9 @@ export class CommandRegistryModel extends IpylabModel {
private _removeCommand(command_id: string): null {
if (Private.customCommands.has(command_id)) {
const cmd = Private.customCommands.get(command_id);
if (cmd) cmd.dispose();
if (cmd) {
cmd.dispose();
}
}
this.save_changes();
return null;
Expand Down
Loading

0 comments on commit ca386a7

Please sign in to comment.