Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Use local ruff and mypy for pre-commit #1440

Merged
merged 1 commit into from
Aug 16, 2024
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
43 changes: 29 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,36 @@ repos:
- id: check-docstring-first
- id: debug-statements

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.0
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.0
hooks:
- id: mypy
additional_dependencies: [pydantic]

- repo: local
hooks:
- id: poetry-install
name: sync poetry deps
description: Ensure development tools are installed.
entry: poetry install --sync
language: system
files: poetry.lock
pass_filenames: false
- id: ruff-format
name: ruff format
description: Format python code with `ruff`.
entry: poetry run ruff format
language: system
files: \.py$
pass_filenames: false
- id: ruff-check
name: ruff
description: Check python code with `ruff`.
entry: poetry run ruff check --fix --exit-non-zero-on-fix
language: system
files: \.py$
pass_filenames: false
- id: mypy-check
name: mypy
description: Check python code with `mypy`.
entry: poetry run mypy .
language: system
files: \.py$
pass_filenames: false
- id: cargo-fmt
name: cargo format
description: Format rust code with `cargo fmt`.
Expand Down Expand Up @@ -88,7 +103,7 @@ repos:
# We need to rebuild `hugr-cli` without the `extension_inference` feature
# to avoid test errors.
# TODO: Remove this once the issue is fixed.
entry: sh -c "cargo build -p hugr-cli && poetry install && poetry run pytest"
entry: sh -c "cargo build -p hugr-cli && poetry run pytest"
language: system
files: \.py$
pass_filenames: false
2 changes: 1 addition & 1 deletion hugr-py/tests/test_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def test_registry():
reg.get_extension("not_found")


@pytest.fixture()
@pytest.fixture
def registry() -> ext.ExtensionRegistry:
reg = ext.ExtensionRegistry()
reg.add_extension(LOGIC_EXT)
Expand Down
41 changes: 21 additions & 20 deletions poetry.lock

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

5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ pre-commit = "^3.6.2"
pytest = "^8.1.1"
pytest-cov = "^5.0.0"
mypy = "^1.9.0"
ruff = "^0.3.3"
ruff = "^0.6.0"
toml = "^0.10.0"

[tool.poetry.group.hugr.dependencies]
hugr = { path = "hugr-py", develop = true }


[tool.poetry.dependencies]
python = "^3.10"
typing-extensions = "^4.12.0"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Expand Down
Loading