Skip to content

Commit

Permalink
Merge pull request #84 from pybop-team/83-ruff-format-to-pre-commit
Browse files Browse the repository at this point in the history
Ruff pre-commit updates (#83)
  • Loading branch information
BradyPlanden authored Nov 6, 2023
2 parents 2637230 + 8c66077 commit 8dc572e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
13 changes: 4 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@ ci:

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.0.292"
rev: "v0.1.3"
hooks:
- id: ruff
args: ["--fix", "--ignore=E501,E402,E741", "--exclude=__init__.py"]

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.7.0
hooks:
- id: nbqa-ruff
additional_dependencies: [ruff==0.0.284]
args: ["--fix","--ignore=E501,E402"]
args: [--fix, --show-fixes]
types_or: [python, pyi, jupyter]
- id: ruff-format

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
Expand Down
9 changes: 2 additions & 7 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,16 @@
# nox options
nox.options.reuse_existing_virtualenvs = True

# @nox.session
# def lint(session):
# session.install('flake8')
# session.run('flake8', 'example.py')


@nox.session
def unit(session):
session.run_always("pip", "install", "-e", ".")
session.install("pytest")
session.run("pytest", "--unit")
session.run("pytest", "--unit", "-v")


@nox.session
def coverage(session):
session.run_always("pip", "install", "-e", ".")
session.install("pytest-cov")
session.run("pytest", "--unit", "--cov", "--cov-report=xml")
session.run("pytest", "--unit", "-v", "--cov", "--cov-report=xml")
5 changes: 1 addition & 4 deletions pybop/parameters/base_parameter_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ class ParameterSet:

def __new__(cls, method, name):
if method.casefold() == "pybamm":
try:
return pybamm.ParameterValues(name).copy()
except:
raise ValueError("Parameter set not found")
return pybamm.ParameterValues(name).copy()
else:
raise ValueError("Only PyBaMM parameter sets are currently implemented")
8 changes: 8 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
extend-include = ["*.ipynb"]
extend-exclude = ["__init__.py"]

[lint]
ignore = ["E501","E741"]

[lint.per-file-ignores]
"**.ipynb" = ["E402", "E703"]

0 comments on commit 8dc572e

Please sign in to comment.