Skip to content

Commit

Permalink
build!: drop python 3.8, simplify dep, fix ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
kiyoon committed Feb 12, 2025
1 parent 9cd3167 commit af57c1b
Show file tree
Hide file tree
Showing 26 changed files with 147 additions and 154 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
nvim-tag: [stable]

steps:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ The Jupynium server will receive events from Neovim, keep the copy of the buffer
- Other browsers are not supported due to their limitation with Selenium (see [#49](https://github.com/kiyoon/jupynium.nvim/issues/49#issuecomment-1443304753))
- 🦎 Mozilla geckodriver
- May already be installed with Firefox. Check `geckodriver -V`
- 🐍 Python >= 3.8
- 🐍 Python >= 3.9
- Supported Python installation methods include system-level and [Conda](https://docs.conda.io/en/latest/miniconda.html)
- 📔 Jupyter Notebook >= 6.2
- Jupyter Lab is not supported
Expand All @@ -54,7 +54,7 @@ Don't forget to upgrade your notebook and install nbclassic (`pip install --upgr
### Install Python
Don't have system Python 3.8? You can use [Conda](https://docs.conda.io/en/latest/miniconda.html):
Don't have system Python 3.9? You can use [Conda](https://docs.conda.io/en/latest/miniconda.html):

```bash
conda create -n jupynium python=3
Expand Down
2 changes: 1 addition & 1 deletion deps/lock/aarch64-apple-darwin/.requirements.in.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
918b65d5e1c28c0eca34020abeb4851fe92201626cb5a1c4058e1a37d739a966 requirements.in
ddcefbbf279d844b4332eca884ee2f86dec55d6f3947c5a4377e20ba5feff176 requirements.in
6 changes: 1 addition & 5 deletions deps/lock/aarch64-apple-darwin/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file was autogenerated by uv via the following command:
# uv pip compile requirements.in -o /Users/kiyoon/project/jupynium.nvim/deps/lock/aarch64-apple-darwin/requirements.txt --python-platform aarch64-apple-darwin --python-version 3.8
# uv pip compile requirements.in -o /Users/kiyoon/project/jupynium.nvim/deps/lock/aarch64-apple-darwin/requirements.txt --python-platform aarch64-apple-darwin --python-version 3.9
attrs==25.1.0
# via
# outcome
Expand Down Expand Up @@ -28,8 +28,6 @@ msgpack==1.1.0
# via pynvim
outcome==1.3.0.post0
# via trio
packaging==24.2
# via -r requirements.in
persist-queue==1.0.0
# via -r requirements.in
platformdirs==4.3.6
Expand All @@ -42,8 +40,6 @@ pysocks==1.7.1
# via urllib3
selenium==4.27.1
# via -r requirements.in
setuptools==75.3.0
# via -r requirements.in
smmap==5.0.2
# via gitdb
sniffio==1.3.1
Expand Down
5 changes: 1 addition & 4 deletions deps/lock/aarch64-apple-darwin/requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file was autogenerated by uv via the following command:
# uv pip compile requirements_dev.in -o /Users/kiyoon/project/jupynium.nvim/deps/lock/aarch64-apple-darwin/requirements_dev.txt --python-platform aarch64-apple-darwin --python-version 3.8
# uv pip compile requirements_dev.in -o /Users/kiyoon/project/jupynium.nvim/deps/lock/aarch64-apple-darwin/requirements_dev.txt --python-platform aarch64-apple-darwin --python-version 3.9
attrs==25.1.0
# via
# outcome
Expand Down Expand Up @@ -47,7 +47,6 @@ outcome==1.3.0.post0
# via trio
packaging==24.2
# via
# -r requirements.in
# pyproject-api
# pytest
# tox
Expand Down Expand Up @@ -80,8 +79,6 @@ ruff==0.9.6
# via -r requirements_dev.in
selenium==4.27.1
# via -r requirements.in
setuptools==75.3.0
# via -r requirements.in
smmap==5.0.2
# via gitdb
sniffio==1.3.1
Expand Down
2 changes: 1 addition & 1 deletion deps/lock/x86_64-apple-darwin/.requirements.in.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
918b65d5e1c28c0eca34020abeb4851fe92201626cb5a1c4058e1a37d739a966 requirements.in
ddcefbbf279d844b4332eca884ee2f86dec55d6f3947c5a4377e20ba5feff176 requirements.in
6 changes: 1 addition & 5 deletions deps/lock/x86_64-apple-darwin/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file was autogenerated by uv via the following command:
# uv pip compile requirements.in -o /Users/kiyoon/project/jupynium.nvim/deps/lock/x86_64-apple-darwin/requirements.txt --python-platform x86_64-apple-darwin --python-version 3.8
# uv pip compile requirements.in -o /Users/kiyoon/project/jupynium.nvim/deps/lock/x86_64-apple-darwin/requirements.txt --python-platform x86_64-apple-darwin --python-version 3.9
attrs==25.1.0
# via
# outcome
Expand Down Expand Up @@ -28,8 +28,6 @@ msgpack==1.1.0
# via pynvim
outcome==1.3.0.post0
# via trio
packaging==24.2
# via -r requirements.in
persist-queue==1.0.0
# via -r requirements.in
platformdirs==4.3.6
Expand All @@ -42,8 +40,6 @@ pysocks==1.7.1
# via urllib3
selenium==4.27.1
# via -r requirements.in
setuptools==75.3.0
# via -r requirements.in
smmap==5.0.2
# via gitdb
sniffio==1.3.1
Expand Down
5 changes: 1 addition & 4 deletions deps/lock/x86_64-apple-darwin/requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file was autogenerated by uv via the following command:
# uv pip compile requirements_dev.in -o /Users/kiyoon/project/jupynium.nvim/deps/lock/x86_64-apple-darwin/requirements_dev.txt --python-platform x86_64-apple-darwin --python-version 3.8
# uv pip compile requirements_dev.in -o /Users/kiyoon/project/jupynium.nvim/deps/lock/x86_64-apple-darwin/requirements_dev.txt --python-platform x86_64-apple-darwin --python-version 3.9
attrs==25.1.0
# via
# outcome
Expand Down Expand Up @@ -47,7 +47,6 @@ outcome==1.3.0.post0
# via trio
packaging==24.2
# via
# -r requirements.in
# pyproject-api
# pytest
# tox
Expand Down Expand Up @@ -80,8 +79,6 @@ ruff==0.9.6
# via -r requirements_dev.in
selenium==4.27.1
# via -r requirements.in
setuptools==75.3.0
# via -r requirements.in
smmap==5.0.2
# via gitdb
sniffio==1.3.1
Expand Down
2 changes: 1 addition & 1 deletion deps/lock/x86_64-manylinux_2_28/.requirements.in.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
918b65d5e1c28c0eca34020abeb4851fe92201626cb5a1c4058e1a37d739a966 requirements.in
ddcefbbf279d844b4332eca884ee2f86dec55d6f3947c5a4377e20ba5feff176 requirements.in
6 changes: 1 addition & 5 deletions deps/lock/x86_64-manylinux_2_28/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file was autogenerated by uv via the following command:
# uv pip compile requirements.in -o /Users/kiyoon/project/jupynium.nvim/deps/lock/x86_64-manylinux_2_28/requirements.txt --python-platform x86_64-manylinux_2_28 --python-version 3.8
# uv pip compile requirements.in -o /Users/kiyoon/project/jupynium.nvim/deps/lock/x86_64-manylinux_2_28/requirements.txt --python-platform x86_64-manylinux_2_28 --python-version 3.9
attrs==25.1.0
# via
# outcome
Expand Down Expand Up @@ -28,8 +28,6 @@ msgpack==1.1.0
# via pynvim
outcome==1.3.0.post0
# via trio
packaging==24.2
# via -r requirements.in
persist-queue==1.0.0
# via -r requirements.in
platformdirs==4.3.6
Expand All @@ -42,8 +40,6 @@ pysocks==1.7.1
# via urllib3
selenium==4.27.1
# via -r requirements.in
setuptools==75.3.0
# via -r requirements.in
smmap==5.0.2
# via gitdb
sniffio==1.3.1
Expand Down
5 changes: 1 addition & 4 deletions deps/lock/x86_64-manylinux_2_28/requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file was autogenerated by uv via the following command:
# uv pip compile requirements_dev.in -o /Users/kiyoon/project/jupynium.nvim/deps/lock/x86_64-manylinux_2_28/requirements_dev.txt --python-platform x86_64-manylinux_2_28 --python-version 3.8
# uv pip compile requirements_dev.in -o /Users/kiyoon/project/jupynium.nvim/deps/lock/x86_64-manylinux_2_28/requirements_dev.txt --python-platform x86_64-manylinux_2_28 --python-version 3.9
attrs==25.1.0
# via
# outcome
Expand Down Expand Up @@ -47,7 +47,6 @@ outcome==1.3.0.post0
# via trio
packaging==24.2
# via
# -r requirements.in
# pyproject-api
# pytest
# tox
Expand Down Expand Up @@ -80,8 +79,6 @@ ruff==0.9.6
# via -r requirements_dev.in
selenium==4.27.1
# via -r requirements.in
setuptools==75.3.0
# via -r requirements.in
smmap==5.0.2
# via gitdb
sniffio==1.3.1
Expand Down
2 changes: 0 additions & 2 deletions deps/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@ verboselogs>=1.7
selenium>=4.7.2
psutil>=5.9.4
persist-queue>=0.8.0
packaging>=22.0
setuptools>=45.0 # for pkg_resources. Otherwise get LegacyVersion error
gitpython>=3.1.24
platformdirs>=4.0.0
9 changes: 4 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ authors = [
]
readme = "README.md"
license = { file="LICENSE" }
requires-python = ">=3.8"
requires-python = ">=3.9"
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand Down Expand Up @@ -84,12 +83,11 @@ omit = [

[tool.tox]
requires = ["tox>=4.19"]
env_list = ["python3.8", "python3.9", "python3.10", "python3.11", "python3.12", "python3.13"]
env_list = ["python3.9", "python3.10", "python3.11", "python3.12", "python3.13"]
isolated_build = true

[tool.tox.gh-actions]
python = """
3.8: python3.8
3.9: python3.9
3.10: python3.10
3.11: python3.11
Expand All @@ -109,7 +107,7 @@ typeCheckingMode = "standard"
useLibraryCodeForTypes = true
autoImportCompletions = true

pythonVersion = "3.8"
pythonVersion = "3.9"
# pythonPlatform = "Linux"

reportDuplicateImport = true
Expand Down Expand Up @@ -161,6 +159,7 @@ ignore = [
"TD", # TODO
"FIX", # TODO
"ARG", # unused argument
"PERF",
]

[tool.ruff.lint.per-file-ignores]
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_with_uv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ fi

source "$path_to_venv/bin/activate"
uv pip install .
mkdir -p "$HOME/.local/bin"
# mkdir -p "$HOME/.local/bin"
# ln -sf "$path_to_venv/bin/jupynium" "$HOME/.local/bin"
3 changes: 0 additions & 3 deletions scripts/run_luacheck.sh

This file was deleted.

38 changes: 20 additions & 18 deletions src/jupynium/buffer.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
from __future__ import annotations

import logging

from pkg_resources import resource_stream
from selenium.webdriver.remote.webdriver import WebDriver
from importlib.resources import files as resfiles
from typing import TYPE_CHECKING

from .jupyter_notebook_selenium import insert_cell_at

if TYPE_CHECKING:
from selenium.webdriver.remote.webdriver import WebDriver

logger = logging.getLogger(__name__)


set_cell_text_js_code = (
resource_stream("jupynium", "js/set_cell_text.js").read().decode("utf-8")
)
set_cell_text_js_code = (resfiles("jupynium") / "js" / "set_cell_text.js").read_text()


class JupyniumBuffer:
Expand Down Expand Up @@ -64,7 +64,7 @@ def full_analyse_buf(self, header_cell_type: str = "header"):
content processing.)
Args:
header_cell_type (str, optional): Used to be used only when partial update.
header_cell_type: Used to be used only when partial update.
Now deprecated.
"""
num_rows_this_cell = 0
Expand Down Expand Up @@ -101,15 +101,13 @@ def _process_cell_text(self, cell_type: str, lines: list[str]):
if len(lines) > 0 and lines[0] == '"""':
return "\n".join(line for line in lines if not line.startswith('"""'))
else:
return "\n".join(
line[2:] if line.startswith("# ") else line for line in lines
)
return "\n".join(line.removeprefix("# ") for line in lines)
else:
# header
return "\n".join(lines)

def get_cells_text(
self, start_cell_idx: int, end_cell_idx: int, strip: bool = True
self, start_cell_idx: int, end_cell_idx: int, *, strip: bool = True
) -> list[str]:
"""
Get processed cell text.
Expand Down Expand Up @@ -152,12 +150,13 @@ def get_cells_text(

return texts_per_cell

def get_cell_text(self, cell_idx: int, strip: bool = True) -> str:
def get_cell_text(self, cell_idx: int, *, strip: bool = True) -> str:
return self.get_cells_text(cell_idx, cell_idx, strip=strip)[0]

def process_on_lines(
self,
driver: WebDriver,
*,
strip: bool,
lines: list[str],
start_row: int,
Expand Down Expand Up @@ -338,15 +337,16 @@ def get_cell_index_from_row(
self,
row: int,
num_rows_per_cell: list[int] | None = None,
*,
raise_out_of_bound: bool = True,
) -> tuple[int, int, int]:
"""
Returns the cell index for the given row.
Args:
row (int): row index
num_rows_per_cell (list): number of rows per cell. If None, use self.num_rows_per_cell
raise_out_of_bound (bool): whether to raise an IndexError if the row is out of bound
row: row index
num_rows_per_cell: number of rows per cell. If None, use self.num_rows_per_cell
raise_out_of_bound: whether to raise an IndexError if the row is out of bound
Returns:
int: cell index
Expand Down Expand Up @@ -376,7 +376,7 @@ def _check_validity(self):
assert all(x in ("code", "markdown") for x in self.cell_types[1:])

def _partial_sync_to_notebook(
self, driver: WebDriver, start_cell_idx: int, end_cell_idx: int, strip=True
self, driver: WebDriver, start_cell_idx: int, end_cell_idx: int, *, strip=True
):
"""
Given the range of cells to update, sync the JupyniumBuffer with the notebook.
Expand Down Expand Up @@ -405,7 +405,9 @@ def _partial_sync_to_notebook(
if start_cell_idx == 0:
start_cell_idx = 1

texts_per_cell = self.get_cells_text(start_cell_idx, end_cell_idx, strip)
texts_per_cell = self.get_cells_text(
start_cell_idx, end_cell_idx, strip=strip
)

code_cell_indices = [
start_cell_idx + i
Expand Down Expand Up @@ -444,7 +446,7 @@ def _partial_sync_to_notebook(
*texts_per_cell,
)

def full_sync_to_notebook(self, driver: WebDriver, strip: bool = True):
def full_sync_to_notebook(self, driver: WebDriver, *, strip: bool = True):
# Full sync with notebook.
# WARNING: syncing may result in data loss.
num_cells = self.num_cells_in_notebook
Expand Down
2 changes: 1 addition & 1 deletion src/jupynium/cmds/ipynb2jupytext.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import argparse
from pathlib import Path

from ..ipynb import ipynb2jupytext, load_ipynb
from jupynium.ipynb import ipynb2jupytext, load_ipynb


def get_parser():
Expand Down
Loading

0 comments on commit af57c1b

Please sign in to comment.