Skip to content

Commit 2d40881

Browse files
Merge pull request #286 from andreasgriffin/ruff-all
Ruff
2 parents 92832ca + 7d05000 commit 2d40881

File tree

262 files changed

+7587
-3370
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

262 files changed

+7587
-3370
lines changed

.pre-commit-config.yaml

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,23 @@ repos:
1313
language: system
1414
files: ^tools/resources/linux-bitcoin-safe\.desktop$
1515

16-
- repo: https://github.com/pycqa/isort
17-
rev: 5.13.2 # Use the specified version of isort
18-
hooks:
19-
- id: isort
20-
args:
21-
- --profile=black # Set the import order style (change 'google' to your preferred style)
22-
- repo: https://github.com/myint/autoflake
23-
rev: v2.3.1 # Use the latest version of autoflake
24-
hooks:
25-
- id: autoflake
26-
args:
27-
- --expand-star-imports
28-
- --remove-all-unused-imports
29-
- --remove-unused-variables
30-
- --in-place
31-
- --exclude=__init__.py
32-
- --remove-duplicate-keys
33-
- repo: https://github.com/ambv/black
34-
rev: 25.1.0
35-
hooks:
36-
- id: black
37-
language_version: python3.12
16+
# - repo: https://github.com/asmeurer/removestar
17+
# rev: "1.5.2"
18+
# hooks:
19+
# - id: removestar
20+
# args: [-i] # See docs for all args (-i edits file in-place)
21+
# exclude: ^(bitcoin_safe/stubs)
3822

23+
- repo: https://github.com/astral-sh/ruff-pre-commit
24+
rev: v0.13.1
25+
hooks:
26+
# Lint + auto-fix (includes import sorting, unused imports, etc.)
27+
- id: ruff-format
28+
- id: ruff-check
29+
args: [--fix, --exit-non-zero-on-fix]
30+
# If you don't want to run on notebooks, uncomment:
31+
# types_or: [python, pyi]
32+
# Formatter (Black-compatible)
3933

4034

4135
- repo: https://github.com/pre-commit/mirrors-mypy
@@ -70,6 +64,7 @@ repos:
7064
- pyqt6
7165

7266

67+
7368
- repo: local
7469
hooks:
7570
- id: pyright
@@ -79,28 +74,22 @@ repos:
7974
types: [python]
8075
pass_filenames: false
8176

82-
83-
84-
8577
- repo: local
8678
hooks:
8779
- id: update-poetry-version
8880
name: Update Poetry Version
89-
entry: python .update_version.py
81+
entry: python .update_version.py
9082
language: python
9183
always_run: true
9284
files: pyproject.toml
9385
additional_dependencies:
9486
- tomlkit
95-
96-
- repo: local
97-
hooks:
98-
- id: update-poetry-version
99-
name: Update Poetry Version
87+
88+
- id: optional-precommit-checks
89+
name: Optional Precommit Checks
10090
entry: python .optional_precommit_checks.py
10191
language: python
10292
always_run: true
103-
10493

10594

10695

.update_version.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,17 @@
2626
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2727
# SOFTWARE.
2828

29+
from __future__ import annotations
30+
2931
import tomlkit
3032

3133
from bitcoin_safe import __version__
3234

3335

3436
def update_poetry_version(file_path, new_version):
3537
# Read the pyproject.toml file
36-
with open(file_path, "r") as file:
38+
"""Update poetry version."""
39+
with open(file_path) as file:
3740
data = tomlkit.load(file)
3841

3942
# Update the version under tool.poetry

bitcoin_safe/__main__.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66

77
setup_logging()
88

9-
from bitcoin_safe.dynamic_lib_load import ensure_pyzbar_works, set_os_env_ssl_certs
9+
from bitcoin_safe.dynamic_lib_load import ensure_pyzbar_works, set_os_env_ssl_certs # noqa: E402
1010

1111
set_os_env_ssl_certs()
1212
ensure_pyzbar_works()
1313

1414

15-
from PyQt6.QtWidgets import QApplication
15+
from PyQt6.QtWidgets import QApplication # noqa: E402
1616

17-
from bitcoin_safe.compatibility import check_compatibility
18-
from bitcoin_safe.gnome_darkmode import is_gnome_dark_mode, set_dark_palette
19-
from bitcoin_safe.gui.qt.main import MainWindow
20-
from bitcoin_safe.gui.qt.util import custom_exception_handler
17+
from bitcoin_safe.compatibility import check_compatibility # noqa: E402
18+
from bitcoin_safe.gnome_darkmode import is_gnome_dark_mode, set_dark_palette # noqa: E402
19+
from bitcoin_safe.gui.qt.main import MainWindow # noqa: E402
20+
from bitcoin_safe.gui.qt.util import custom_exception_handler # noqa: E402
2121

2222

2323
def parse_args() -> argparse.Namespace:
24-
24+
"""Parse args."""
2525
parser = argparse.ArgumentParser(description="Bitcoin Safe")
2626
parser.add_argument("--network", help="Choose the network: bitcoin, regtest, testnet, signet ")
2727
parser.add_argument(
@@ -39,6 +39,7 @@ def parse_args() -> argparse.Namespace:
3939

4040

4141
def main() -> None:
42+
"""Main."""
4243
args = parse_args()
4344

4445
sys.excepthook = custom_exception_handler

0 commit comments

Comments
 (0)