Skip to content
Merged
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
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ ci:
autoupdate_schedule: quarterly
repos:
- repo: https://github.com/BlankSpruce/gersemi-pre-commit
rev: 0.27.7
rev: 0.29.2
hooks:
- id: gersemi
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.20
rev: v0.16.10
hooks:
- id: ruff-check
- id: ruff-format
- repo: https://github.com/pappasam/toml-sort
rev: v0.24.4
rev: v0.25.0
hooks:
- id: toml-sort-fix
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v22.1.5
rev: v23.1.2
hooks:
- id: clang-format
args:
Expand Down
12 changes: 6 additions & 6 deletions doc/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@
#
############# README ###############################

from __future__ import print_function
import re
import os
import re
import sys

from doxygen_xml_parser import Index


Expand Down Expand Up @@ -165,7 +165,7 @@ def substitute(istr, ostr):
currentClass = None
currentNamespace = None
index = None
for line in map(lambda s: s.rstrip(), istr):
for line in (s.rstrip() for s in istr):
for match in nsPattern.finditer(line):
currentNamespace = match.group("namespace")
index = indexFromNamespace(currentNamespace)
Expand All @@ -185,9 +185,9 @@ def substitute(istr, ostr):
line = line.replace(
match.group(0), make_doc_string(escape(b), escape(d))
)
except Exception as e:
except Exception as e: # noqa: BLE001
print(
"Failed to find class doc for {0}: {1}".format(cn, e),
f"Failed to find class doc for {cn}: {e}",
file=sys.stderr,
)
line = line.replace(match.group(0), '"' + cn + '"')
Expand All @@ -209,7 +209,7 @@ def substitute(istr, ostr):
)
except IndexError as e:
print(
"Failed to find documentation of method {0}::{1}".format(cn, mn),
f"Failed to find documentation of method {cn}::{mn}",
file=sys.stderr,
)
line = line.replace(match.group(0), '"' + str(e) + '", ""')
Expand Down
6 changes: 3 additions & 3 deletions doc/doxygen_xml_parser.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import print_function
from lxml import etree
from os import path
import sys
from os import path

from lxml import etree


class Index:
Expand Down
2 changes: 1 addition & 1 deletion doc/fix_stubs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
from ._fixer import fix_file
from ._overrides import SETTER_TYPE_OVERRIDES

__all__ = ["fix_file", "main", "SETTER_TYPE_OVERRIDES"]
__all__ = ["SETTER_TYPE_OVERRIDES", "fix_file", "main"]
2 changes: 1 addition & 1 deletion doc/fix_stubs/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def main() -> None:
setter_overrides=setter_overrides,
method_overrides=method_overrides,
)
except Exception as e:
except Exception as e: # noqa: BLE001
print(f"error: failed to fix {f}: {e}", file=sys.stderr)
continue
total_files += 1
Expand Down
4 changes: 1 addition & 3 deletions doc/fix_stubs/_fixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ def fix_file(
fixed = 0
for cls in tree:
for fn in cls.functions:
if fn.from_docstring:
fixed += 1
elif fn.setter_overloads:
if fn.from_docstring or fn.setter_overloads:
fixed += 1

new_content = render_file(header, tree)
Expand Down
2 changes: 1 addition & 1 deletion doc/fix_stubs/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def __init__(self, is_module: bool = False):
self.bases: list[str] = []
self.docstring = ""
self.functions: list[Function] = []
self.nested_classes: list["ClassI"] = []
self.nested_classes: list[ClassI] = []
self.is_module = is_module
self.extra_lines: list[str] = []

Expand Down
2 changes: 1 addition & 1 deletion doc/fix_stubs/_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def load_method_overrides(path: Path | None) -> dict[str, _MethodSig]:

raw = json.loads(path.read_text())
if not isinstance(raw, dict):
raise ValueError(f"{path}: expected a JSON object, got {type(raw).__name__}")
raise TypeError(f"{path}: expected a JSON object, got {type(raw).__name__}")

for key, value in raw.items():
entries = value if isinstance(value, list) else [value]
Expand Down
1 change: 1 addition & 0 deletions doc/fix_stubs/_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""

from __future__ import annotations

import sys
from pathlib import Path

Expand Down
22 changes: 10 additions & 12 deletions doc/gen_api_md.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

from __future__ import annotations

import argparse
import ast
import html as _html
import keyword
import re
import sys
import argparse
from pathlib import Path

# ---------------------------------------------------------------------------
Expand Down Expand Up @@ -251,7 +251,7 @@ def _parse_stub(stub_path: Path) -> ast.Module | None:
source = _KW_PARAM_RE.sub(r"\1\2_\3", source)

return ast.parse(source)
except Exception:
except Exception: # noqa: BLE001
return None


Expand Down Expand Up @@ -822,12 +822,11 @@ def render_class(
node = group[0]
if node.name in SKIP_NAMES or is_setter(node):
continue
if node.name == "__init__":
if any(
get_docstring(ov) and NOT_INSTANTIABLE.search(get_docstring(ov))
for ov in group
):
continue
if node.name == "__init__" and any(
get_docstring(ov) and NOT_INSTANTIABLE.search(get_docstring(ov))
for ov in group
):
continue
sig = _sig_cell(group, class_index, current_page)
if owner != qualified_class:
sig += f" *(inherited from {_type_link(owner, class_index, current_page)})*"
Expand Down Expand Up @@ -906,10 +905,9 @@ def generate_module_md(
if pending_funcs:
func_groups.append(pending_funcs)
pending_funcs = [item]
elif isinstance(item, ast.ClassDef):
if pending_funcs:
func_groups.append(pending_funcs)
pending_funcs = []
elif isinstance(item, ast.ClassDef) and pending_funcs:
func_groups.append(pending_funcs)
pending_funcs = []
if pending_funcs:
func_groups.append(pending_funcs)

Expand Down
2 changes: 1 addition & 1 deletion src/pyhpp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
category=RuntimeWarning,
)

import eigenpy # noqa: E402, F401
import eigenpy # noqa: F401
9 changes: 4 additions & 5 deletions src/pyhpp/core/static_stability_constraint_factory.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
#
# Copyright (c) 2025 CNRS
# Author: Paul Sardin
Expand Down Expand Up @@ -29,7 +28,7 @@
# DAMAGE.

import numpy as np
from pinocchio import Quaternion, SE3
from pinocchio import SE3, Quaternion


# # This class provides tools to create static stability constraints
Expand All @@ -55,7 +54,7 @@ def _getCOM(self, com):
def createSlidingStabilityConstraint(
self, prefix, comName, leftAnkle, rightAnkle, q0
):
created_constraints = dict()
created_constraints = {}

_tfs = self.robot.getJointsPosition(q0, [leftAnkle, rightAnkle])
Ml = SE3(Quaternion(np.array(_tfs[0][3:7])), np.array(_tfs[0][0:3]))
Expand Down Expand Up @@ -112,7 +111,7 @@ def createSlidingStabilityConstraint(
def createStaticStabilityConstraint(
self, prefix, comName, leftAnkle, rightAnkle, q0, maskCom=[True] * 3
):
created_constraints = dict()
created_constraints = {}

_tfs = self.robot.getJointsPosition(q0, [leftAnkle, rightAnkle])
Ml = SE3(Quaternion(np.array(_tfs[0][3:7])), np.array(_tfs[0][0:3]))
Expand Down Expand Up @@ -158,7 +157,7 @@ def createStaticStabilityConstraint(
def createAlignedCOMStabilityConstraint(
self, prefix, comName, leftAnkle, rightAnkle, q0, sliding
):
created_constraints = dict()
created_constraints = {}

_tfs = self.robot.getJointsPosition(q0, [leftAnkle, rightAnkle])
Ml = SE3(Quaternion(np.array(_tfs[0][3:7])), np.array(_tfs[0][0:3]))
Expand Down
Loading
Loading