Skip to content

Commit

Permalink
Use ruff format (#133)
Browse files Browse the repository at this point in the history
* use ruff format

* use 3.x qualifier

* fix type

* fix theme options

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
blink1073 and pre-commit-ci[bot] authored Oct 29, 2023
1 parent 964ce67 commit c0887fd
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 127 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.8", "3.11"]
python-version: ["3.8", "3.12"]
include:
- os: windows-latest
python-version: "3.9"
- os: ubuntu-latest
python-version: "pypy-3.8"
python-version: "pypy-3.9"
- os: macos-latest
python-version: "3.10"
- os: ubuntu-latest
python-version: "3.11"

steps:
- uses: actions/checkout@v4
Expand Down
17 changes: 9 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ci:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: check-case-conflict
- id: check-ast
Expand Down Expand Up @@ -42,11 +42,6 @@ repos:
- id: blacken-docs
additional_dependencies: [black==23.7.0]

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.9.1
hooks:
- id: black

- repo: https://github.com/codespell-project/codespell
rev: "v2.2.6"
hooks:
Expand All @@ -60,14 +55,20 @@ repos:
- id: rst-directive-colons
- id: rst-inline-touching-normal

- repo: https://github.com/tox-dev/pyproject-fmt
rev: "1.0.0"
hooks:
- id: pyproject-fmt

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.292
rev: v0.1.3
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
- id: ruff-format

- repo: https://github.com/scientific-python/cookie
rev: "2023.09.21"
rev: "2023.10.27"
hooks:
- id: sp-repo-review
additional_dependencies: ["repo-review[cli]"]
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
# a list of builtin themes.
#
html_theme = "pydata_sphinx_theme"
html_theme_options = {"navigation_with_keys": False}

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {"python": {"https://docs.python.org/3/": None}}
Expand Down
129 changes: 73 additions & 56 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,43 +1,63 @@
[build-system]
requires = ["hatchling>=1.17.0"]
build-backend = "hatchling.build"
requires = [
"hatchling>=1.17",
]

[project]
name = "hatch-jupyter-builder"
dynamic = ["version"]
description = 'A hatch plugin to help build Jupyter packages'
description = "A hatch plugin to help build Jupyter packages"
readme = "README.md"
requires-python = ">=3.8"
keywords = [
"hatch",
"jupyter",
"jupyterlab",
]
license = { file = "LICENSE.txt" }
keywords = ["jupyter", "jupyterlab", "hatch"]
authors = [
{ name = "Jupyter Development Team", email = "jupyter@googlegroups.com" },
]
requires-python = ">=3.8"
classifiers = [
"Development Status :: 4 - Beta",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
dependencies = ["hatchling>=1.17.0"]

dynamic = [
"version",
]
dependencies = [
"hatchling>=1.17",
]
[project.optional-dependencies]
docs = [
"hatch_jupyter_builder",
"myst-parser",
"pydata-sphinx-theme",
"sphinx-autodoc-typehints",
"sphinxcontrib-spelling",
]
test = [
"hatch",
"pytest",
"pytest-cov",
"pytest-mock",
"tomli",
"twine",
]
[project.urls]
Documentation = "https://github.com/jupyterlab/hatch-jupyter-builder#readme"
Issues = "https://github.com/jupyterlab/hatch-jupyter-builder/issues"
Source = "https://github.com/jupyterlab/hatch-jupyter-builder"

[project.optional-dependencies]
test = ["pytest", "pytest-mock", "hatch", "pytest-cov", "tomli", "twine"]
docs = ["pydata-sphinx-theme", "myst-parser", "hatch_jupyter_builder", "sphinxcontrib-spelling", "sphinx-autodoc-typehints"]

[project.scripts]
hatch-jupyter-builder = 'hatch_jupyter_builder.cli:run'

[project.entry-points.hatch]
jupyter = "hatch_jupyter_builder.hooks"

Expand Down Expand Up @@ -78,64 +98,28 @@ test = "mypy --install-types --non-interactive {args}"

[tool.hatch.envs.lint]
dependencies = [
"black[jupyter]==23.3.0",
"mdformat>0.7",
"ruff==0.0.287",
"ruff==0.1.3",
]
[tool.hatch.envs.lint.scripts]
style = [
"ruff {args:.}",
"black --check --diff {args:.}",
"ruff format {args:.}",
"mdformat --check {args:docs/source *.md}"
]
fmt = [
"black {args:.}",
"ruff --fix {args:.}",
"ruff format {args:.}",
"mdformat {args:docs/source *.md}"
]

[tool.pytest.ini_options]
minversion = "6.0"
xfail_strict = true
log_cli_level = "info"
addopts = [
"-raXs", "--durations=10", "--color=yes", "--doctest-modules",
"--showlocals", "--strict-markers", "--strict-config"
]
testpaths = [
"tests/"
]
norecursedirs = "tests/data/*"
filterwarnings = [
"error"
]

[tool.coverage.run]
omit = [
"hatch_jupyter_builder/cli.py",
"hatch_jupyter_builder/migrate/*",
"hatch_jupyter_builder/compare_migrated/*"
]
relative_files = true
source = ["hatch_jupyter_builder"]

[tool.mypy]
python_version = "3.8"
strict = true
show_error_codes = true
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
warn_unreachable = true
files = ["hatch_jupyter_builder"]

[tool.black]
line-length = 100
target-version = ["py38"]

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

[tool.ruff.lint]
select = [
"A", "B", "C", "DTZ", "E", "EM", "F", "FBT", "I", "ICN", "ISC", "N",
"A", "B", "C", "DTZ", "E", "EM", "F", "FBT", "I", "ICN", "N",
"PLC", "PLE", "PLR", "PLW", "Q", "RUF", "S", "SIM", "T", "TID", "UP",
"W", "YTT",
]
Expand Down Expand Up @@ -186,7 +170,7 @@ unfixable = [
"RUF100",
]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
# B011 Do not call assert False since python -O removes these calls
# F841 local variable 'foo' is assigned to but never used
# C408 Unnecessary `dict` call
Expand All @@ -196,6 +180,39 @@ unfixable = [
# PLR2004 Magic value used in comparison
"tests/*" = ["B011", "F841", "C408", "E402", "T201", "EM101", "EM102", "EM103", "PLR2004"]

[tool.pytest.ini_options]
minversion = "6.0"
xfail_strict = true
log_cli_level = "info"
addopts = [
"-raXs", "--durations=10", "--color=yes", "--doctest-modules",
"--showlocals", "--strict-markers", "--strict-config"
]
testpaths = [
"tests/"
]
norecursedirs = "tests/data/*"
filterwarnings = [
"error"
]

[tool.coverage.run]
omit = [
"hatch_jupyter_builder/cli.py",
"hatch_jupyter_builder/migrate/*",
"hatch_jupyter_builder/compare_migrated/*"
]
relative_files = true
source = ["hatch_jupyter_builder"]

[tool.mypy]
python_version = "3.8"
strict = true
show_error_codes = true
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
warn_unreachable = true
files = ["hatch_jupyter_builder"]

[tool.interrogate]
ignore-init-module=true
ignore-private=true
Expand Down
7 changes: 6 additions & 1 deletion tests/data/create_cmdclass/myproject/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
[build-system]
requires = ["jupyter_packaging==0.7.9", "jupyterlab==3.*", "setuptools>=40.8.0", "wheel"]
build-backend = "setuptools.build_meta"
requires = [
"jupyter_packaging==0.7.9",
"jupyterlab==3.*",
"setuptools>=40.8",
"wheel",
]
71 changes: 36 additions & 35 deletions tests/data/create_cmdclass/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,59 +1,60 @@
[build-system]
build-backend = "hatchling.build"
requires = [
"hatchling>=1.3.1",
"jupyterlab==3.*",
"hatchling>=1.3.1",
"jupyterlab==3.*",
]
build-backend = "hatchling.build"

[project]
name = "myproject"
version = "0.1.0.dev0"
description = "A Custom Jupyter Widget Library"
readme = "README.md"
keywords = [
"IPython",
"Jupyter",
"Widgets",
]
license = { file = "LICENSE.txt" }
requires-python = ">=3.6"
authors = [
{ name = "me", email = "me@me.com" },
]
keywords = [
"IPython",
"Jupyter",
"Widgets",
]
requires-python = ">=3.6"
classifiers = [
"Framework :: Jupyter",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Framework :: Jupyter",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"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",
]
dependencies = [
"ipywidgets>=7.0.0",
"ipywidgets>=7",
]
version = "0.1.0.dev0"

[project.optional-dependencies]
docs = [
"jupyter_sphinx",
"nbsphinx",
"nbsphinx-link",
"pypandoc",
"pytest_check_links",
"recommonmark",
"sphinx>=1.5",
"sphinx_rtd_theme",
"jupyter_sphinx",
"nbsphinx",
"nbsphinx-link",
"pypandoc",
"pytest_check_links",
"recommonmark",
"sphinx>=1.5",
"sphinx_rtd_theme",
]
examples = [
]
examples = []
test = [
"nbval",
"pytest-cov",
"pytest>=4.6",
"nbval",
"pytest>=4.6",
"pytest-cov",
]

[project.urls]
Homepage = "https://github.com/myorg/myproject"

Expand Down
5 changes: 4 additions & 1 deletion tests/data/npm_builder/myextension/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[build-system]
requires = ["jupyter_packaging~=0.10,<2", "jupyterlab~=3.1"]
build-backend = "jupyter_packaging.build_api"
requires = [
"jupyter_packaging<2,~=0.10",
"jupyterlab~=3.1",
]

[tool.jupyter-packaging.options]
skip-if-exists = ["myextension/labextension/static/style.js"]
Expand Down
Loading

0 comments on commit c0887fd

Please sign in to comment.