Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d7e18cc4a7695d5446bfde246c91b91b092c0084
15 changes: 6 additions & 9 deletions .github/workflows/fast-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,19 @@ jobs:
steps:
- name: Clone
uses: actions/checkout@v4
- run: pip install flake8 flake8-pyproject
- name: Flake8 lint Python code
run: flake8 src/
- run: pip install ruff
- name: ruff check
run: ruff check

yapf:
name: Formatting
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v4
- run: pip install yapf toml
- name: Yapf source formatting
run: |
yapf src/ --recursive -d
yapf tests/ --recursive -d
yapf template/ --recursive -d
- run: pip install ruff toml
- name: Ruff source formatting
run: ruff format --check

mypy:
name: Type checking
Expand Down
35 changes: 35 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# To install hooks, run:
# pre-commit install --hook-type pre-commit
# pre-commit install --hook-type commit-msg

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: check-added-large-files

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.8
hooks:
- id: ruff-format
args: ["--diff"]
- id: ruff-check

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.14.1
hooks:
- id: mypy
additional_dependencies:
- types-toml
- types-requests

- repo: https://github.com/Mateusz-Grzelinski/actionlint-py
rev: v1.7.7.24
hooks:
- id: actionlint
types_or: [yaml]
args: [-shellcheck='' -pyflakes='']
47 changes: 25 additions & 22 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

import os
import sys
from importlib.metadata import version as get_version

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))


# -- Project information -----------------------------------------------------

project = 'Ragger'
copyright = '2022, bow'
author = 'bow'
project = "Ragger"
copyright = "2022, bow"
author = "bow"


# -- General configuration ---------------------------------------------------
Expand All @@ -30,42 +30,42 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx_copybutton',
'sphinxcontrib.images',
"sphinx.ext.autodoc",
"sphinx_copybutton",
"sphinxcontrib.images",
]

images_config = {
"default_image_width": "90%",
}

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

html_sidebars = { '**': ['globaltoc.html', 'relations.html', 'sourcelink.html', 'searchbox.html'] }
html_sidebars = {
"**": ["globaltoc.html", "relations.html", "sourcelink.html", "searchbox.html"]
}

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["build", "Thumbs.db", ".DS_Store"]

import os
import sys
sys.path.insert(0, os.path.abspath("../src/"))

sys.path.insert(0, os.path.abspath('../src/'))

from importlib.metadata import version as get_version
release = get_version('ragger')
version = '.'.join(release.split('.')[:2])
release = get_version("ragger")
version = ".".join(release.split(".")[:2])

## Autodoc conf ##


# Do not skip __init__ methods by default
def skip(app, what, name, obj, would_skip, options):
if name == "__init__":
return False
return would_skip


# Remove every module documentation string.
# Prevents to integrate the Licence when using automodule.
# It is possible to limit the impacted module by filtering with the 'name'
Expand All @@ -75,20 +75,23 @@ def remove_module_docstring(app, what, name, obj, options, lines):
if what == "module":
del lines[:]


## Setup ##


def setup(app):
app.connect("autodoc-process-docstring", remove_module_docstring)
app.connect("autodoc-skip-member", skip)


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme = "sphinx_rtd_theme"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]
21 changes: 11 additions & 10 deletions src/ragger/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
"""
Copyright 2022 Ledger SAS
Copyright 2022 Ledger SAS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

try:
from ragger.__version__ import __version__ # noqa
except ImportError:
Expand Down
51 changes: 33 additions & 18 deletions src/ragger/backend/__init__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
"""
Copyright 2022 Ledger SAS
Copyright 2022 Ledger SAS

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

from .interface import BackendInterface, RaisePolicy
from .stub import StubBackend

ERROR_MSG = ("This backend needs {}. Please install this package (run `pip install ragger[{}]` or "
"check this address: '{}')")
ERROR_MSG = (
"This backend needs {}. Please install this package (run `pip install ragger[{}]` or "
"check this address: '{}')"
)

try:
from .speculos import SpeculosBackend
Expand All @@ -27,7 +30,10 @@

def SpeculosBackend(*args, **kwargs): # type: ignore
raise ImportError(
ERROR_MSG.format("Speculos", "speculos", "https://github.com/LedgerHQ/speculos/"))
ERROR_MSG.format(
"Speculos", "speculos", "https://github.com/LedgerHQ/speculos/"
)
)


try:
Expand All @@ -38,7 +44,10 @@ def SpeculosBackend(*args, **kwargs): # type: ignore

def LedgerCommBackend(*args, **kwargs): # type: ignore
raise ImportError(
ERROR_MSG.format("LedgerComm", "ledgercomm", "https://github.com/LedgerHQ/ledgercomm/"))
ERROR_MSG.format(
"LedgerComm", "ledgercomm", "https://github.com/LedgerHQ/ledgercomm/"
)
)


try:
Expand All @@ -49,11 +58,17 @@ def LedgerCommBackend(*args, **kwargs): # type: ignore

def LedgerWalletBackend(*args, **kwargs): # type: ignore
raise ImportError(
ERROR_MSG.format("LedgerWallet", "ledgerwallet",
"https://github.com/LedgerHQ/ledgerctl/"))
ERROR_MSG.format(
"LedgerWallet", "ledgerwallet", "https://github.com/LedgerHQ/ledgerctl/"
)
)


__all__ = [
"SpeculosBackend", "LedgerCommBackend", "LedgerWalletBackend", "BackendInterface",
"RaisePolicy", "StubBackend"
"SpeculosBackend",
"LedgerCommBackend",
"LedgerWalletBackend",
"BackendInterface",
"RaisePolicy",
"StubBackend",
]
Loading
Loading