Skip to content

Commit

Permalink
Update-pre-commit-hooks (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
andersy005 committed Mar 1, 2024
1 parent 7a2eb4b commit 6e4b197
Show file tree
Hide file tree
Showing 14 changed files with 109 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pypi-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: 3.8
python-version: 3.x

- name: Install dependencies
run: |
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: 3.8
python-version: 3.x
- uses: actions/download-artifact@v4
with:
name: releases
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upstream-dev-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.10"]
python-version: ["3.11"]
steps:
- uses: actions/checkout@v4
with:
Expand Down
31 changes: 5 additions & 26 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,12 @@ repos:
- id: debug-statements
- id: mixed-line-ending

- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.3.0"
hooks:
- id: pyupgrade
args:
- "--py38-plus"

- repo: https://github.com/psf/black
rev: 24.1.1
hooks:
- id: black
- id: black-jupyter

- repo: https://github.com/keewis/blackdoc
rev: v0.3.9
hooks:
- id: blackdoc

- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8

- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
- id: ruff
args: ["--fix"]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ include README.md
recursive-include jupyter_forward *.py
recursive-exclude * __pycache__
recursive-exclude * *.py[co]
include jupyter_forward/py.typed

include *.md
include *.toml
Expand Down
2 changes: 1 addition & 1 deletion ci/environment-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dependencies:
- furo
- myst-nb
- pip
- python=3.9
- python=3.11
- sphinx-copybutton
- sphinx-inline-tabs
- sqlalchemy
Expand Down
1 change: 0 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import jupyter_forward


extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.viewcode',
Expand Down
1 change: 1 addition & 0 deletions jupyter_forward/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
# flake8: noqa
"""Top-level module for jupyter_forward ."""

from pkg_resources import DistributionNotFound, get_distribution

from .core import RemoteRunner
Expand Down
9 changes: 4 additions & 5 deletions jupyter_forward/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import typing
from pathlib import Path

import typer
Expand All @@ -23,7 +22,7 @@ def start(
port: int = typer.Option(
8888,
help=(
'''The local port the remote notebook server will be forwarded to. If not specified, defaults to 8888.'''
"""The local port the remote notebook server will be forwarded to. If not specified, defaults to 8888."""
),
show_default=True,
),
Expand All @@ -40,7 +39,7 @@ def start(
notebook: str = typer.Option(
None,
show_default=True,
help='''The absolute path of the notebook to load on the remote host. `--notebook-dir` and `--notebook` are mutually exclusive.''',
help="""The absolute path of the notebook to load on the remote host. `--notebook-dir` and `--notebook` are mutually exclusive.""",
),
port_forwarding: bool = typer.Option(
True, show_default=True, help='Whether to set up SSH port forwarding or not.'
Expand All @@ -53,7 +52,7 @@ def start(
file_okay=True,
show_default=True,
help=(
'''Selects a file from which the identity (private key) for public key authentication is read.'''
"""Selects a file from which the identity (private key) for public key authentication is read."""
),
),
launch_command: str = typer.Option(
Expand All @@ -72,7 +71,7 @@ def start(
show_default=True,
help='Which remote shell binary to use.',
),
version: typing.Optional[bool] = typer.Option(
version: bool | None = typer.Option(
None,
'--version',
callback=version_callback,
Expand Down
16 changes: 8 additions & 8 deletions jupyter_forward/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import sys
import textwrap
import time
from typing import Callable
from collections.abc import Callable

import invoke
import paramiko
Expand Down Expand Up @@ -38,13 +38,13 @@ class RemoteRunner:

host: str
port: int = 8888
conda_env: str = None
notebook_dir: str = None
notebook: str = None
conda_env: str | None = None
notebook_dir: str | None = None
notebook: str | None = None
port_forwarding: bool = True
launch_command: str = None
identity: str = None
shell: str = None
launch_command: str | None = None
identity: str | None = None
shell: str | None = None
auth_handler: Callable = _authentication_handler
fallback_auth_handler: Callable = getpass.getpass

Expand All @@ -58,7 +58,7 @@ def __post_init__(self):

if self.port_forwarding and not is_port_available(self.port):
console.print(
f'''[bold red]:x: Specified port={self.port} is already in use on your local machine. Try a different port'''
f"""[bold red]:x: Specified port={self.port} is already in use on your local machine. Try a different port"""
)
sys.exit(1)
self._authenticate()
Expand Down
7 changes: 6 additions & 1 deletion jupyter_forward/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
from .console import console


def open_browser(port: int = None, token: str = None, url: str = None, path=None) -> None:
def open_browser(
port: int | None = None,
token: str | None = None,
url: str | None = None,
path: str | None = None,
) -> None:
"""Opens notebook interface in a new browser window.
Parameters
Expand Down
Empty file added jupyter_forward/py.typed
Empty file.
77 changes: 72 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,75 @@
[tool.black]
line-length = 100
target-version = ['py38']
skip-string-normalization = true


[build-system]
requires = ["setuptools>=45", "wheel", "setuptools_scm>=6.2"]


[tool.ruff]
line-length = 100
target-version = "py310"

builtins = ["ellipsis"]
# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".git-rewrite",
".hg",
".ipynb_checkpoints",
".mypy_cache",
".nox",
".pants.d",
".pyenv",
".pytest_cache",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
".vscode",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"site-packages",
"venv",
]
[tool.ruff.lint]
per-file-ignores = {}
ignore = [
"E721", # Comparing types instead of isinstance
"E741", # Ambiguous variable names
"E501", # Conflicts with ruff format
]
select = [
# Pyflakes
"F",
# Pycodestyle
"E",
"W",
# isort
"I",
# Pyupgrade
"UP",
]

[tool.ruff.lint.mccabe]
max-complexity = 18

[tool.ruff.lint.isort]
known-first-party = ["jupyter_forward"]

[tool.ruff.format]
quote-style = "single"
docstring-code-format = true

[tool.ruff.lint.pydocstyle]
convention = "numpy"


[tool.pytest.ini_options]
console_output_style = "count"
addopts = "--cov=./ --cov-report=xml --verbose"
13 changes: 7 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@

"""The setup script."""

import pathlib

from setuptools import find_packages, setup

with open('requirements.txt') as f:
requirements = f.read().strip().split('\n')

with open('README.md') as f:
long_description = f.read()
long_description = pathlib.Path('README.md').read_text()
setup(
maintainer='Xdev',
maintainer_email='xdev@ucar.edu',
python_requires='>=3.7',
python_requires='>=3.10',
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Topic :: Scientific/Engineering',
'Operating System :: OS Independent',
'Intended Audience :: Science/Research',
Expand Down

0 comments on commit 6e4b197

Please sign in to comment.