Skip to content

Commit

Permalink
run pre-commit and enable GitHub integration
Browse files Browse the repository at this point in the history
  • Loading branch information
adehad committed Feb 12, 2024
1 parent 7eb5b04 commit 93f15d4
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ repos:
additional_dependencies: []
exclude: src/scantailor/translations/
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.11"
rev: "v0.2.1"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
10 changes: 10 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
extends: default

rules:
key-duplicates: enable
line-length:
max: 270
allow-non-breakable-words: true
allow-non-breakable-inline-mappings: true
truthy: disable
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Goal:
Much bigger task than I originally thought.
- [ ] The translations won't work as they are also covering the stuff in the .cpp files.
- [x] Should take inspiration from: https://github.com/JackLilhammers/pyside6-boilerplate/tree/main -- Made my own fork and used it as a grounds to get familiar and upgrade to more modern Python: https://github.com/adehad/pyside6-boilerplate
- [x] Using the pdm post_install hook to run the ui class generaion would be ideal. -- we can use the loader class, for the translations, we can generate however
- [x] Using the pdm post_install hook to run the ui class generation would be ideal. -- we can use the loader class, for the translations, we can generate however
- [ ] generate the translations via the devcontainer, this worked fine in the template, but we can do it a bit differently here
- [ ] The translations should also become a Qt resource, with proper prefixins as shown here: https://www.pythonguis.com/tutorials/packaging-data-files-pyside6-with-qresource-system/
- [x] Run app via debugger -- I mean it didn't do anything and there are things to sort, out but it is a start
Expand Down
25 changes: 13 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ exclude = '''(?x)(
)'''

[tool.ruff]
# The source code paths to consider, e.g., when resolving first- vs. third-party imports
src = ["scantailor", "tests"]
extend-exclude = ["./src/scantailor/_ui/*_ui.py"]

# Assume Python 3.12. (minimum supported)
target-version = "py312"

# Same as Black.
line-length = 88

[tool.ruff.lint]
select = [
"E", # pydocstyle
"W", # pydocstyle
Expand All @@ -90,24 +101,14 @@ select = [
"RUF", # ruff
]
ignore = []
extend-exclude = ["./src/scantailor/_ui/*_ui.py"]

# Same as Black.
line-length = 88

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

# Assume Python 3.12. (minimum supported)
target-version = "py312"

# The source code paths to consider, e.g., when resolving first- vs. third-party imports
src = ["scantailor", "tests"]

[tool.ruff.isort]
[tool.ruff.lint.isort]
known-first-party = ["scantailor", "tests"]
required-imports = ["from __future__ import annotations"]

[tool.ruff.pydocstyle]
[tool.ruff.lint.pydocstyle]
# Use Google-style docstrings.
convention = "google"
2 changes: 2 additions & 0 deletions src/scantailor/__about__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Project Metadata."""
from __future__ import annotations

try:
import importlib.metadata

Expand Down
2 changes: 2 additions & 0 deletions src/scantailor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""ScanTailor."""
from __future__ import annotations

from .__about__ import __version__

__all__ = [
Expand Down
1 change: 1 addition & 0 deletions src/scantailor/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
No relative imports so PyInstaller doesn't get confused.
"""
from __future__ import annotations

from scantailor.main import main

Expand Down
2 changes: 1 addition & 1 deletion src/scantailor/app/ui/DefaultParamsDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -3174,7 +3174,7 @@ QToolButton:pressed {
<item>
<widget class="QCheckBox" name="higherSearchSensitivityCB">
<property name="text">
<string>Higher search sensivity</string>
<string>Higher search sensitivity</string>
</property>
</widget>
</item>
Expand Down
6 changes: 3 additions & 3 deletions src/scantailor/app/ui/SettingsDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="selectContentDeviationCoefSB">
<property name="toolTip">
<string>Deviation multiplier: a higher value means lower sensivity.</string>
<string>Deviation multiplier: a higher value means lower sensitivity.</string>
</property>
<property name="minimum">
<double>0.100000000000000</double>
Expand All @@ -380,7 +380,7 @@
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="deskewDeviationCoefSB">
<property name="toolTip">
<string>Deviation multiplier: a higher value means lower sensivity.</string>
<string>Deviation multiplier: a higher value means lower sensitivity.</string>
</property>
<property name="minimum">
<double>0.100000000000000</double>
Expand Down Expand Up @@ -428,7 +428,7 @@
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="marginsDeviationCoefSB">
<property name="toolTip">
<string>Deviation multiplier: a higher value means lower sensivity.</string>
<string>Deviation multiplier: a higher value means lower sensitivity.</string>
</property>
<property name="minimum">
<double>0.100000000000000</double>
Expand Down
4 changes: 3 additions & 1 deletion src/scantailor/app/ui/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""UI Elements & Screens."""
from __future__ import annotations

import pathlib

from PySide6 import QtCore, QtUiTools, QtWidgets
Expand All @@ -10,7 +12,7 @@ def load_ui_widget(ui_filename: pathlib.Path, parent=None) -> QtWidgets.QWidget:
"""Load UI Widget."""
loader = QtUiTools.QUiLoader()
ui_file = QtCore.QFile(str(ui_filename))
ui_file.open(QtCore.QFile.ReadOnly) # type: ignore[attr-defined]
ui_file.open(QtCore.QFile.ReadOnly) # type: ignore[attr-defined]
ui = loader.load(ui_file, parent)
ui_file.close()
return ui
1 change: 1 addition & 0 deletions src/scantailor/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Main Entrypoint for the application."""
from __future__ import annotations

from PySide6 import QtWidgets

Expand Down

0 comments on commit 93f15d4

Please sign in to comment.