-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add pre-commit, fix python formatting
- Loading branch information
Showing
7 changed files
with
54 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
repos: | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: v0.6.1 | ||
hooks: | ||
- id: ruff | ||
args: [ --fix ] | ||
- id: ruff-format | ||
- repo: local | ||
hooks: | ||
- id: cargo-format | ||
name: Cargo format | ||
entry: cargo fmt | ||
language: system | ||
files: \.rs$ | ||
pass_filenames: false | ||
- id: cargo-clippy | ||
name: Cargo clippy | ||
entry: cargo clippy -- --deny warnings | ||
language: system | ||
files: \.rs$ | ||
pass_filenames: false | ||
- id: cargo-check | ||
name: Cargo check | ||
entry: cargo check | ||
language: system | ||
files: \.rs$ | ||
pass_filenames: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,24 @@ | ||
from typing import Any, Iterable, TypedDict | ||
|
||
|
||
class SizeDict(TypedDict): | ||
width: int | ||
height: int | ||
mime_type: int | ||
is_animated: int | ||
|
||
|
||
class Size: | ||
width: int | ||
height: int | ||
mime_type: int | ||
is_animated: int | ||
|
||
def __init__(self, width: int, height: int, mime_type: str, is_animated: bool) -> None: ... | ||
|
||
def __init__( | ||
self, width: int, height: int, mime_type: str, is_animated: bool | ||
) -> None: ... | ||
def as_dict(self) -> SizeDict: ... | ||
|
||
def __repr__(self) -> str: ... | ||
|
||
def __eq__(self, other: Any) -> bool: ... | ||
|
||
def __iter__(self) -> Iterable[int]: ... | ||
|
||
def __hash__(self) -> int: ... | ||
|
||
|
||
def get_size(data: bytes) -> Size | None: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,6 @@ test = [ | |
|
||
[tool.maturin] | ||
features = ["pyo3/extension-module"] | ||
|
||
[tool.ruff.lint] | ||
select = ["F", "E", "W", "I"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import sys | ||
from importlib import import_module | ||
from pathlib import Path | ||
from subprocess import check_call | ||
|
||
import pytest | ||
import sys | ||
|
||
ROOT = Path(__file__).parent.parent | ||
|
||
|
||
@pytest.fixture(scope='session') | ||
@pytest.fixture(scope="session") | ||
def imgsize(): | ||
assert sys.prefix != sys.base_prefix, "must be in virtualenv" | ||
check_call(['maturin', 'develop', '--manifest-path', ROOT / 'Cargo.toml']) | ||
return import_module('imgsize') | ||
check_call(["maturin", "develop", "--manifest-path", ROOT / "Cargo.toml"]) | ||
return import_module("imgsize") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
def test_eq(imgsize): | ||
assert imgsize.Size(1, 2, 'a', True) == imgsize.Size(1, 2, 'a', True) | ||
assert imgsize.Size(1, 2, 'a', True) != imgsize.Size(2, 2, 'a', True) | ||
assert imgsize.Size(1, 2, 'a', True) != imgsize.Size(1, 1, 'a', True) | ||
assert imgsize.Size(1, 2, 'a', True) != imgsize.Size(1, 2, 'b', True) | ||
assert imgsize.Size(1, 2, 'a', True) != imgsize.Size(1, 2, 'a', False) | ||
assert imgsize.Size(1, 2, "a", True) == imgsize.Size(1, 2, "a", True) | ||
assert imgsize.Size(1, 2, "a", True) != imgsize.Size(2, 2, "a", True) | ||
assert imgsize.Size(1, 2, "a", True) != imgsize.Size(1, 1, "a", True) | ||
assert imgsize.Size(1, 2, "a", True) != imgsize.Size(1, 2, "b", True) | ||
assert imgsize.Size(1, 2, "a", True) != imgsize.Size(1, 2, "a", False) | ||
|
||
|
||
def test_iter(imgsize): | ||
assert list(imgsize.Size(1, 2, 'a', True)) == [1, 2] | ||
assert list(imgsize.Size(1, 2, "a", True)) == [1, 2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters