Skip to content

Commit

Permalink
Merge pull request NSLS-II#95 from thomashopkins32/ruff-linter
Browse files Browse the repository at this point in the history
Ruff linter support; Removal of black, flake8, and isort
  • Loading branch information
thomaswmorris authored Feb 20, 2025
2 parents c0eb914 + fe06de0 commit d736bda
Show file tree
Hide file tree
Showing 30 changed files with 223 additions and 267 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- name: Install pre-commit dependencies
run: pip install .[pre-commit]
- uses: pre-commit/action@v3.0.0
with:
extra_args: --all-files
44 changes: 26 additions & 18 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,36 @@
default_language_version:
python: python3
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-yaml
- id: check-merge-conflict
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/ambv/black
rev: 24.10.0

- repo: local
hooks:
- id: black
language_version: python3
- id: black-jupyter
language_version: python3
- repo: https://github.com/pycqa/flake8
rev: 7.1.1
hooks:
- id: flake8
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black"]
- id: ruff
name: lint with ruff
language: system
entry: ruff check --force-exclude
types: [python]
require_serial: true

- id: ruff-format
name: format with ruff
language: system
entry: ruff format --force-exclude
types: [python]
require_serial: true

- id: import-linter
name: ensure import directionality
pass_filenames: false
language: system
entry: lint-imports
types: [python]
require_serial: false

- repo: https://github.com/kynan/nbstripout
rev: 0.8.1
hooks:
Expand Down
12 changes: 5 additions & 7 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# blop documentation build configuration file, created by
# sphinx-quickstart on Thu Jun 28 12:35:56 2018.
Expand All @@ -21,6 +20,11 @@
# import sys
# sys.path.insert(0, os.path.abspath('.'))

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
import blop

# -- General configuration ------------------------------------------------

Expand Down Expand Up @@ -72,12 +76,6 @@
copyright = "2020, Brookhaven National Laboratory"
author = "Brookhaven National Laboratory"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
import blop

# The short X.Y version.
version = blop.__version__
# The full version, including alpha/beta/rc tags.
Expand Down
16 changes: 6 additions & 10 deletions docs/source/tutorials/hyperparameters.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib as mpl\n",
"import numpy as np\n",
"from matplotlib import pyplot as plt\n",
"\n",
"from blop.utils import functions\n",
"\n",
"x1 = x2 = np.linspace(-10, 10, 256)\n",
Expand Down Expand Up @@ -66,11 +67,11 @@
},
"outputs": [],
"source": [
"from blop.utils import prepare_re_env\n",
"from blop.utils import prepare_re_env # noqa: F401\n",
"\n",
"%run -i $prepare_re_env.__file__ --db-type=temp\n",
"\n",
"from blop import DOF, Objective, Agent\n",
"from blop import DOF, Agent, Objective\n",
"\n",
"dofs = [\n",
" DOF(name=\"x1\", search_domain=(-6, 6)),\n",
Expand Down Expand Up @@ -139,7 +140,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "blop-dev",
"language": "python",
"name": "python3"
},
Expand All @@ -153,12 +154,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.20"
},
"vscode": {
"interpreter": {
"hash": "b0fa6594d8f4cbf19f97940f81e996739fb7646882a419484c72d19e05852a7e"
}
"version": "3.12.8"
}
},
"nbformat": 4,
Expand Down
14 changes: 5 additions & 9 deletions docs/source/tutorials/introduction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"metadata": {},
"outputs": [],
"source": [
"from blop.utils import prepare_re_env\n",
"from blop.utils import prepare_re_env # noqa: F401\n",
"\n",
"%run -i $prepare_re_env.__file__ --db-type=temp"
]
Expand All @@ -38,9 +38,10 @@
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib as mpl\n",
"import numpy as np\n",
"from matplotlib import pyplot as plt\n",
"\n",
"from blop.utils import functions\n",
"\n",
"x1 = x2 = np.linspace(-6, 6, 256)\n",
Expand Down Expand Up @@ -289,7 +290,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "blop-dev",
"language": "python",
"name": "python3"
},
Expand All @@ -303,12 +304,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.20"
},
"vscode": {
"interpreter": {
"hash": "b0fa6594d8f4cbf19f97940f81e996739fb7646882a419484c72d19e05852a7e"
}
"version": "3.12.8"
}
},
"nbformat": 4,
Expand Down
21 changes: 4 additions & 17 deletions docs/source/tutorials/kb-mirrors.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"metadata": {},
"outputs": [],
"source": [
"from blop.utils import prepare_re_env\n",
"from blop.utils import prepare_re_env # noqa: F401\n",
"\n",
"%run -i $prepare_re_env.__file__ --db-type=temp\n",
"bec.disable_plots()"
Expand All @@ -42,7 +42,7 @@
"metadata": {},
"outputs": [],
"source": [
"from blop import DOF, Objective, Agent\n",
"from blop import DOF, Agent, Objective\n",
"from blop.digestion import beam_stats_digestion\n",
"\n",
"dofs = [\n",
Expand Down Expand Up @@ -103,19 +103,11 @@
"source": [
"agent.plot_objectives(axes=(2, 3))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "blop-dev",
"language": "python",
"name": "python3"
},
Expand All @@ -129,12 +121,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.20"
},
"vscode": {
"interpreter": {
"hash": "b0fa6594d8f4cbf19f97940f81e996739fb7646882a419484c72d19e05852a7e"
}
"version": "3.12.8"
}
},
"nbformat": 4,
Expand Down
17 changes: 5 additions & 12 deletions docs/source/tutorials/pareto-fronts.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"metadata": {},
"outputs": [],
"source": [
"from blop.utils import prepare_re_env\n",
"from blop.utils import prepare_re_env # noqa: F401\n",
"\n",
"%run -i $prepare_re_env.__file__ --db-type=temp"
]
Expand All @@ -30,12 +30,10 @@
"metadata": {},
"outputs": [],
"source": [
"from blop import DOF, Objective, Agent\n",
"from blop.utils import functions\n",
"from blop.dofs import BrownianMotion\n",
"\n",
"import numpy as np\n",
"\n",
"from blop import DOF, Agent, Objective\n",
"\n",
"\n",
"def digestion(df):\n",
" for index, entry in df.iterrows():\n",
Expand Down Expand Up @@ -130,7 +128,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "blop-dev",
"language": "python",
"name": "python3"
},
Expand All @@ -144,12 +142,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.20"
},
"vscode": {
"interpreter": {
"hash": "b0fa6594d8f4cbf19f97940f81e996739fb7646882a419484c72d19e05852a7e"
}
"version": "3.12.8"
}
},
"nbformat": 4,
Expand Down
14 changes: 4 additions & 10 deletions docs/source/tutorials/passive-dofs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"metadata": {},
"outputs": [],
"source": [
"from blop.utils import prepare_re_env\n",
"from blop.utils import prepare_re_env # noqa: F401\n",
"\n",
"%run -i $prepare_re_env.__file__ --db-type=temp"
]
Expand All @@ -38,11 +38,10 @@
"metadata": {},
"outputs": [],
"source": [
"from blop.digestion.tests import constrained_himmelblau_digestion\n",
"from blop import DOF, Agent, Objective\n",
"from blop.digestion.tests import constrained_himmelblau_digestion\n",
"from blop.dofs import BrownianMotion\n",
"\n",
"\n",
"dofs = [\n",
" DOF(name=\"x1\", search_domain=(-5.0, 5.0)),\n",
" DOF(name=\"x2\", search_domain=(-5.0, 5.0)),\n",
Expand Down Expand Up @@ -80,7 +79,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "blop-dev",
"language": "python",
"name": "python3"
},
Expand All @@ -94,12 +93,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.20"
},
"vscode": {
"interpreter": {
"hash": "b0fa6594d8f4cbf19f97940f81e996739fb7646882a419484c72d19e05852a7e"
}
"version": "3.12.8"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit d736bda

Please sign in to comment.