Skip to content
Open
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 .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ jobs:
- name: "Find the names of the Python files that will be linted"
run: echo "PYTHON_FILES=$(uv run ruff check --show-files | grep '\.py$' | tr -s '\n' ' ')" >> $GITHUB_ENV

# Lint with ruff and cpplint
# Fast static checks
- name: "Lint with ruff . . ."
run: uv run ruff check
- name: "Check ruff formatting . . ."
run: uv run ruff format --diff
- name: "Check Ruff formatting . . ."
run: uv run ruff format --check --diff
- name: "Lint with cpplint . . ."
run: uv run cpplint src/*.hpp src/*.cpp

Expand All @@ -72,7 +72,7 @@ jobs:
- name: "Install libsemigroups_pybind11 . . ."
run: uv sync --verbose --locked --all-extras --no-dev --group lint

# Lint with ruff and cpplint
# Pylint requires the built extension
- name: "Lint with pylint . . ."
run: uv run pylint $PYTHON_FILES
clang-format:
Expand Down
36 changes: 36 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
minimum_pre_commit_version: "3.2.0"
default_install_hook_types: [pre-commit, pre-push]

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.2
hooks:
- id: ruff-check
stages: [pre-commit]
- id: ruff-format
stages: [pre-commit]

- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: system
# Keep the local hook static; CI checks the built native extension.
args:
- --jobs=1
- --extension-pkg-allow-list=
- --ignored-modules=_libsemigroups_pybind11
- --disable=missing-class-docstring
types: [python]
exclude: ^(?:build_tools|etc)/
require_serial: true
stages: [pre-push]

- id: cpplint
name: cpplint
entry: cpplint
language: system
files: ^src/
types_or: [c, c++]
stages: [pre-push]
22 changes: 21 additions & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,27 @@ where [package_manager] is your favourite conda-like package manager, such as
conda or mamba. The default value is mamba. Note that this DOES NOT *yet* work
with micromamba.

To build libsemigroups (with the above environment active):
Git hooks
---------

Install the repository's commit and push hooks after creating the development
environment:

.. code-block:: console

pre-commit install

Ruff linting and formatting then run when committing, while Pylint and cpplint
run before a push. To check every tracked file without making a commit or push,
run:

.. code-block:: console

pre-commit run --all-files
pre-commit run --all-files --hook-stage pre-push

Building libsemigroups
----------------------

First, clone and prepare the libsemigroups repository:

Expand Down
1 change: 1 addition & 0 deletions dev-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dependencies:
- pip
- pip-tools
- pkgconfig
- pre-commit
- pybind11
- pylint
- pytest
Expand Down
3 changes: 3 additions & 0 deletions etc/make-lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ exit_code=0
echo "Linting with ruff . . ."
ruff check || ((exit_code = 1))

echo "Checking formatting with ruff . . ."
ruff format --check || ((exit_code = 1))

echo "Linting with pylint . . ."
pylint $(ruff check --show-files | grep "\.py$") || ((exit_code = 1))

Expand Down
12 changes: 8 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# TODO:
# * Use ruff
# * Decide on good configurations for tools
# * Use pre-commit
# * Use MyPy
[build-system]
build-backend = "setuptools.build_meta"
Expand Down Expand Up @@ -80,8 +78,14 @@ test = ["pytest>=8.4.2"]
[dependency-groups]
# This list should contain any package used in the development of
# libsemigroups_pybind11.
dev = ["ipython>=9.6.0", { include-group = "lint" }]
lint = ["codespell>=2.4.1", "cpplint>=2.0.2", "pylint>=4.0.2", "ruff>=0.14.2"]
dev = ["ipython>=9.6.0", { include-group = "lint" }]
lint = [
"codespell>=2.4.1",
"cpplint>=2.0.2",
"pre-commit>=4.3.0",
"pylint>=4.0.2",
"ruff>=0.14.2",
]

###################################################################
# Tools
Expand Down
4 changes: 1 addition & 3 deletions src/libsemigroups_pybind11/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,7 @@ def generators(self: _Self) -> Iterator[Element]:

_copy_cxx_mem_fns(_RightActionPPerm1PPerm1, Action)

for _type in (
Action._py_template_params_to_cxx_type.values() # pylint: disable=protected-access
):
for _type in Action._py_template_params_to_cxx_type.values(): # pylint: disable=protected-access
_register_cxx_wrapped_type(_type, Action)

########################################################################
Expand Down
4 changes: 1 addition & 3 deletions src/libsemigroups_pybind11/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,7 @@ def __call__(self: _Self, pt: Point, x: Element) -> Point:

_copy_cxx_mem_fns(_ImageRightActionPPerm1PPerm1, ImageRightAction)

for _type in (
ImageRightAction._py_template_params_to_cxx_type.values() # pylint:disable=protected-access
):
for _type in ImageRightAction._py_template_params_to_cxx_type.values(): # pylint:disable=protected-access
_register_cxx_wrapped_type(_type, ImageRightAction)


Expand Down
4 changes: 1 addition & 3 deletions src/libsemigroups_pybind11/froidure_pin.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,7 @@ def sorted_elements( # pylint: disable=missing-function-docstring

_copy_cxx_mem_fns(_FroidurePinBMat, FroidurePin)

for _fp_type in (
FroidurePin._py_template_params_to_cxx_type.values() # pylint:disable=protected-access
):
for _fp_type in FroidurePin._py_template_params_to_cxx_type.values(): # pylint:disable=protected-access
_register_cxx_wrapped_type(_fp_type, FroidurePin)


Expand Down
8 changes: 2 additions & 6 deletions src/libsemigroups_pybind11/konieczny.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,10 @@ def D_classes(self: _Self) -> _Iterator[DClass]:
_copy_cxx_mem_fns(_KoniecznyBMat8, Konieczny)
_copy_cxx_mem_fns(_KoniecznyBMat8DClass, Konieczny.DClass)

for _type in (
Konieczny._py_template_params_to_cxx_type.values() # pylint: disable=protected-access
):
for _type in Konieczny._py_template_params_to_cxx_type.values(): # pylint: disable=protected-access
_register_cxx_wrapped_type(_type, Konieczny)

for _type in (
Konieczny.DClass._py_template_params_to_cxx_type.values() # pylint: disable=protected-access
):
for _type in Konieczny.DClass._py_template_params_to_cxx_type.values(): # pylint: disable=protected-access
_register_cxx_wrapped_type(_type, Konieczny.DClass)

__all__ = ["Konieczny"]
1 change: 0 additions & 1 deletion tests/test_konieczny.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

"""This module contains some tests for the Konieczny class."""


# pylint: disable=missing-function-docstring, invalid-name

from datetime import timedelta
Expand Down
93 changes: 93 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading