From e81d5c4e175f17f7b79892a95aa30a7bfea30b09 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 17:56:29 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v4.3.0 → v5.0.0](https://github.com/pre-commit/pre-commit-hooks/compare/v4.3.0...v5.0.0) - [github.com/PyCQA/flake8: 7.0.0 → 7.1.1](https://github.com/PyCQA/flake8/compare/7.0.0...7.1.1) - https://github.com/myint/autoflake → https://github.com/PyCQA/autoflake - [github.com/PyCQA/autoflake: v2.3.0 → v2.3.1](https://github.com/PyCQA/autoflake/compare/v2.3.0...v2.3.1) - [github.com/psf/black: 22.6.0 → 24.10.0](https://github.com/psf/black/compare/22.6.0...24.10.0) - [github.com/asottile/pyupgrade: v2.34.0 → v3.19.1](https://github.com/asottile/pyupgrade/compare/v2.34.0...v3.19.1) - [github.com/pre-commit/mirrors-prettier: v2.7.1 → v4.0.0-alpha.8](https://github.com/pre-commit/mirrors-prettier/compare/v2.7.1...v4.0.0-alpha.8) --- .pre-commit-config.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b2125a1a..596754cb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,18 +2,18 @@ ci: autoupdate_schedule: 'quarterly' repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v5.0.0 hooks: - id: check-docstring-first - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/PyCQA/flake8 - rev: 7.0.0 + rev: 7.1.1 hooks: - id: flake8 additional_dependencies: [flake8-typing-imports==1.15.0] - - repo: https://github.com/myint/autoflake - rev: v2.3.0 + - repo: https://github.com/PyCQA/autoflake + rev: v2.3.1 hooks: - id: autoflake args: ["--in-place", "--remove-all-unused-imports", "--ignore-init-module-imports", "--remove-unused-variables"] @@ -22,16 +22,16 @@ repos: hooks: - id: isort - repo: https://github.com/psf/black - rev: 22.6.0 + rev: 24.10.0 hooks: - id: black - repo: https://github.com/asottile/pyupgrade - rev: v2.34.0 + rev: v3.19.1 hooks: - id: pyupgrade args: [--py37-plus] - repo: https://github.com/pre-commit/mirrors-prettier - rev: 'v2.7.1' + rev: 'v4.0.0-alpha.8' hooks: - id: prettier types: [ts] From dd90e80a0a3fbe413750b4cf2734419e3cfa61ce Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 17:56:43 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- ipympl/backend_nbagg.py | 2 +- src/mpl_widget.ts | 56 +++++++++++++++---------------- src/plugin.ts | 2 +- src/toolbar_widget.ts | 10 +++--- ui-tests/jupyter_server_config.py | 1 + ui-tests/tests/ipympl.test.ts | 8 ++--- 6 files changed, 40 insertions(+), 39 deletions(-) diff --git a/ipympl/backend_nbagg.py b/ipympl/backend_nbagg.py index 4dd2b6de..3e05448c 100644 --- a/ipympl/backend_nbagg.py +++ b/ipympl/backend_nbagg.py @@ -24,7 +24,7 @@ from collections.abc import Iterable except ImportError: # Python 2.7 - from collections import Iterable + from collections.abc import Iterable import matplotlib import numpy as np diff --git a/src/mpl_widget.ts b/src/mpl_widget.ts index acd4b58f..65bb24f8 100644 --- a/src/mpl_widget.ts +++ b/src/mpl_widget.ts @@ -238,7 +238,7 @@ export class MPLCanvasModel extends DOMWidgetModel { const url_creator = window.URL || window.webkitURL; const buffer = new Uint8Array( - ArrayBuffer.isView(buffers[0]) ? buffers[0].buffer : buffers[0] + ArrayBuffer.isView(buffers[0]) ? buffers[0].buffer : buffers[0], ); const blob = new Blob([buffer], { type: 'image/png' }); const image_url = url_creator.createObjectURL(blob); @@ -277,7 +277,7 @@ export class MPLCanvasModel extends DOMWidgetModel { } catch (e) { console.log( "No handler for the '" + msg_type + "' message type: ", - msg + msg, ); return; } @@ -330,7 +330,7 @@ export class MPLCanvasModel extends DOMWidgetModel { 0, 0, this.offscreen_canvas.width, - this.offscreen_canvas.height + this.offscreen_canvas.height, ); } @@ -412,23 +412,23 @@ export class MPLCanvasView extends DOMWidgetView { model_events() { this.model.on( 'change:header_visible', - this._update_header_visible.bind(this) + this._update_header_visible.bind(this), ); this.model.on( 'change:footer_visible', - this._update_footer_visible.bind(this) + this._update_footer_visible.bind(this), ); this.model.on( 'change:toolbar_visible', - this._update_toolbar_visible.bind(this) + this._update_toolbar_visible.bind(this), ); this.model.on( 'change:toolbar_position', - this._update_toolbar_position.bind(this) + this._update_toolbar_position.bind(this), ); this.model.on( 'change:_figure_label', - this._update_figure_label.bind(this) + this._update_figure_label.bind(this), ); this.model.on('change:_message', this._update_message.bind(this)); this.model.on('change:_cursor', this._update_cursor.bind(this)); @@ -461,7 +461,7 @@ export class MPLCanvasView extends DOMWidgetView { this.header.classList.add( 'jupyter-widgets', 'widget-label', - 'jupyter-matplotlib-header' + 'jupyter-matplotlib-header', ); this._update_header_visible(); this._update_figure_label(); @@ -476,7 +476,7 @@ export class MPLCanvasView extends DOMWidgetView { const canvas_container = document.createElement('div'); canvas_container.classList.add( 'jupyter-widgets', - 'jupyter-matplotlib-canvas-container' + 'jupyter-matplotlib-canvas-container', ); this.figure.appendChild(canvas_container); @@ -485,7 +485,7 @@ export class MPLCanvasView extends DOMWidgetView { canvas_div.style.clear = 'both'; canvas_div.classList.add( 'jupyter-widgets', - 'jupyter-matplotlib-canvas-div' + 'jupyter-matplotlib-canvas-div', ); canvas_div.addEventListener('keydown', this.key_event('key_press')); @@ -514,35 +514,35 @@ export class MPLCanvasView extends DOMWidgetView { top_canvas.addEventListener('dblclick', this.mouse_event('dblclick')); top_canvas.addEventListener( 'mousedown', - this.mouse_event('button_press') + this.mouse_event('button_press'), ); top_canvas.addEventListener( 'mouseup', - this.mouse_event('button_release') + this.mouse_event('button_release'), ); top_canvas.addEventListener( 'mousemove', throttle( this.mouse_event('motion_notify'), - this.model.get('pan_zoom_throttle') - ) + this.model.get('pan_zoom_throttle'), + ), ); top_canvas.addEventListener( 'mouseenter', - this.mouse_event('figure_enter') + this.mouse_event('figure_enter'), ); top_canvas.addEventListener( 'mouseleave', - this.mouse_event('figure_leave') + this.mouse_event('figure_leave'), ); top_canvas.addEventListener( 'wheel', throttle( this.mouse_event('scroll'), - this.model.get('pan_zoom_throttle') - ) + this.model.get('pan_zoom_throttle'), + ), ); top_canvas.addEventListener('wheel', (event: any) => { if (this.model.get('capture_scroll')) { @@ -568,7 +568,7 @@ export class MPLCanvasView extends DOMWidgetView { async _init_toolbar() { this.toolbar_view = (await this.create_child_view( - this.model.get('toolbar') + this.model.get('toolbar'), )) as ToolbarView; this.figure.appendChild(this.toolbar_view.el); @@ -595,7 +595,7 @@ export class MPLCanvasView extends DOMWidgetView { 0, 0, this.canvas.width, - this.canvas.height + this.canvas.height, ); } else { this.context.drawImage(this.model.offscreen_canvas, 0, 0); @@ -605,7 +605,7 @@ export class MPLCanvasView extends DOMWidgetView { 0, 0, this.top_canvas.width, - this.top_canvas.height + this.top_canvas.height, ); // Draw rubberband @@ -624,7 +624,7 @@ export class MPLCanvasView extends DOMWidgetView { this.model.get('_rubberband_x'), this.model.get('_rubberband_y'), this.model.get('_rubberband_width'), - this.model.get('_rubberband_height') + this.model.get('_rubberband_height'), ); } @@ -636,7 +636,7 @@ export class MPLCanvasView extends DOMWidgetView { this.top_canvas.height - this.resize_handle_size, // Stop this.top_canvas.width, - this.top_canvas.height + this.top_canvas.height, ); gradient.addColorStop(0, 'white'); gradient.addColorStop(1, 'black'); @@ -648,15 +648,15 @@ export class MPLCanvasView extends DOMWidgetView { this.top_context.beginPath(); this.top_context.moveTo( this.top_canvas.width, - this.top_canvas.height + this.top_canvas.height, ); this.top_context.lineTo( this.top_canvas.width, - this.top_canvas.height - this.resize_handle_size + this.top_canvas.height - this.resize_handle_size, ); this.top_context.lineTo( this.top_canvas.width - this.resize_handle_size, - this.top_canvas.height + this.top_canvas.height, ); this.top_context.closePath(); this.top_context.fill(); @@ -675,7 +675,7 @@ export class MPLCanvasView extends DOMWidgetView { this.footer.classList.add( 'jupyter-widgets', 'widget-label', - 'jupyter-matplotlib-footer' + 'jupyter-matplotlib-footer', ); this._update_footer_visible(); this._update_message(); diff --git a/src/plugin.ts b/src/plugin.ts index 1305d7c1..8fe80481 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -27,7 +27,7 @@ export default jupyterMatplotlibPlugin; */ function activateWidgetExtension( app: Application, - registry: IJupyterWidgetRegistry + registry: IJupyterWidgetRegistry, ): void { registry.registerWidget({ name: MODULE_NAME, diff --git a/src/toolbar_widget.ts b/src/toolbar_widget.ts index b13637fb..28e2a3eb 100644 --- a/src/toolbar_widget.ts +++ b/src/toolbar_widget.ts @@ -38,7 +38,7 @@ export class ToolbarView extends DOMWidgetView { 'jupyter-widgets', 'jupyter-matplotlib-toolbar', 'widget-container', - 'widget-box' + 'widget-box', ); // Fade-in/fade-out mode by default, the figure will decide @@ -69,14 +69,14 @@ export class ToolbarView extends DOMWidgetView { button.classList.add( 'jupyter-matplotlib-button', 'jupyter-widgets', - 'jupyter-button' + 'jupyter-button', ); button.setAttribute('href', '#'); button.setAttribute('title', tooltip); button.style.outline = 'none'; button.addEventListener( 'click', - this.toolbar_button_onclick(method_name) + this.toolbar_button_onclick(method_name), ); const icon = document.createElement('i'); @@ -162,7 +162,7 @@ export class ToolbarView extends DOMWidgetView { } set_visibility( - value: 'visible' | 'hidden' | 'fade-in-fade-out' | boolean + value: 'visible' | 'hidden' | 'fade-in-fade-out' | boolean, ): void { // For backward compatibility with the old API if (typeof value === 'boolean') { @@ -247,7 +247,7 @@ export class ToolbarView extends DOMWidgetView { this.model.on_some_change( ['button_style', '_current_action'], this.set_buttons_style, - this + this, ); } } diff --git a/ui-tests/jupyter_server_config.py b/ui-tests/jupyter_server_config.py index be3a30bf..f4fcd788 100644 --- a/ui-tests/jupyter_server_config.py +++ b/ui-tests/jupyter_server_config.py @@ -4,6 +4,7 @@ opens the server to the world and provide access to JupyterLab JavaScript objects through the global window variable. """ + from jupyterlab.galata import configure_jupyter_server configure_jupyter_server(c) # noqa F821 diff --git a/ui-tests/tests/ipympl.test.ts b/ui-tests/tests/ipympl.test.ts index 8e26187d..b4c55c9b 100644 --- a/ui-tests/tests/ipympl.test.ts +++ b/ui-tests/tests/ipympl.test.ts @@ -17,7 +17,7 @@ const filterUpdateNotebooks = (item) => { const testCellOutputs = async ( page: IJupyterLabPageFixture, - tmpPath: string + tmpPath: string, ) => { const paths = klaw(path.resolve(__dirname, './notebooks'), { filter: (item) => !filterUpdateNotebooks(item), @@ -53,7 +53,7 @@ const testCellOutputs = async ( for (let c = 0; c < numCellImages; ++c) { expect(results[c]).toMatchSnapshot( getCaptureImageName(notebook, c), - { threshold: 0.4 } + { threshold: 0.4 }, ); } @@ -96,7 +96,7 @@ const testUpdates = async (page: IJupyterLabPageFixture, tmpPath: string) => { for (let i = 0; i < cellCount; i++) { expect(results[i]).toMatchSnapshot( getCaptureImageName(notebook, i), - { threshold: 0.4 } + { threshold: 0.4 }, ); } @@ -108,7 +108,7 @@ test.describe('ipympl Visual Regression', () => { test.beforeEach(async ({ page, tmpPath }) => { await page.contents.uploadDirectory( path.resolve(__dirname, './notebooks'), - tmpPath + tmpPath, ); await page.filebrowser.openDirectory(tmpPath); });