Skip to content

Commit c33c4b1

Browse files
committed
Add .pre-commit-config.yaml
* Add .pre-commit-config.yaml * Fix some ruff issues * Add some ruff ignores -- to be fixed later
1 parent 4a9cd32 commit c33c4b1

5 files changed

Lines changed: 42 additions & 6 deletions

File tree

.pre-commit-config.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v6.0.0
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-yaml
10+
- id: check-added-large-files
11+
- repo: https://github.com/abravalheri/validate-pyproject
12+
rev: v0.24.1
13+
hooks:
14+
- id: validate-pyproject
15+
# Optional extra validations from SchemaStore:
16+
additional_dependencies: [ "validate-pyproject-schema-store[all]" ]
17+
- repo: https://github.com/astral-sh/ruff-pre-commit
18+
rev: v0.13.1
19+
hooks:
20+
- id: ruff-check
21+
types_or: [ python, pyi ]
22+
args: [ --fix ]
23+
- id: ruff-format
24+
types_or: [ python, pyi ]

pyproject.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,26 @@ lint.ignore = [
9292
"D100", # Ignore missing docstring in public modules
9393
"D101", # Ignore missing docstring in public classes
9494
"F401",
95+
# FIXME: those are ignored for now, should be fixed eventually
96+
"E501", # Ignore line too long
97+
"ERA001", # Found commented-out code
98+
"RET504", # Unnecessary assignment before `return`
99+
"T201", # `print` found"
100+
"SIM105", # Use `contextlib.suppress`
101+
"S110", # `try`-`except`-`pass` detected, consider logging the exception
102+
"A002", # Function argument shadowing a Python builtin
103+
"E701", # Multiple statements on one line (colon)
104+
"E741", # Ambiguous variable name
95105
]
96106
[tool.ruff.lint.per-file-ignores]
97107
"*/__init__.py" = [
98108
"F401",
99109
"D400",
100110
"D205",
101111
]
112+
"docs/source/conf.py" = [
113+
"A001", # Variable `copyright` is shadowing a Python builtin
114+
115+
]
102116
[tool.ruff.lint.pydocstyle]
103117
convention = "pep257"

src/petab_gui/controllers/sbml_controller.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,10 @@ def _overwrite_sbml_with_model(self, sbml_model: SbmlModel):
151151
"SBML model successfully overwritten.", color="green"
152152
)
153153

154-
155154
def clear_model(self):
156-
"""Clear the model in case the user wants to start a new problem"""
155+
"""Clear the model in case the user wants to start a new problem."""
157156
self.model.antimony_text = DEFAULT_ANTIMONY_TEXT
158157
self.model.convert_antimony_to_sbml()
159158
self.view.sbml_text_edit.setPlainText(self.model.sbml_text)
160159
self.view.antimony_text_edit.setPlainText(self.model.antimony_text)
161160
self.overwritten_model.emit()
162-

src/petab_gui/models/sbml_model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def __init__(self, sbml_model: petab.models.Model, parent=None):
3333
self.antimony_text = sbmlToAntimony(self.sbml_text)
3434
else:
3535
self.antimony_text = DEFAULT_ANTIMONY_TEXT
36-
with QSignalBlocker(self) as blocker:
36+
with QSignalBlocker(self):
3737
self.convert_antimony_to_sbml()
3838
self.model_id = self._get_model_id()
3939

@@ -67,7 +67,7 @@ def get_current_sbml_model(self):
6767

6868
def _get_model_id(self):
6969
"""Extract the model ID from the SBML text."""
70-
document = libsbml.readSBMLFromString(self.sbml_text)
70+
document = libsbml.readSBMLFromString(self.sbml_text)
7171
model = document.getModel()
7272
model_id = model.getIdAttribute() or "New_File"
7373
return model_id

src/petab_gui/views/simple_plot_view.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ class ToolbarOptionManager(QObject):
390390

391391
def __new__(cls):
392392
if cls._instance is None:
393-
cls._instance = super(ToolbarOptionManager, cls).__new__(cls)
393+
cls._instance = super().__new__(cls)
394394
return cls._instance
395395

396396
def __init__(self):

0 commit comments

Comments
 (0)