diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 177bd964..7d502e6b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,12 +5,15 @@ repos: - id: check-toml - id: end-of-file-fixer - id: trailing-whitespace + - id: check-yaml - repo: https://github.com/charliermarsh/ruff-pre-commit rev: 'v0.8.4' hooks: - id: ruff args: [ --fix, --exit-non-zero-on-fix ] + # Run the formatter + - id: ruff-format - repo: https://github.com/igorshubovych/markdownlint-cli rev: v0.43.0 @@ -23,13 +26,6 @@ repos: hooks: - id: pyupgrade - #- repo: 'https://github.com/pre-commit/mirrors-mypy' - # rev: v1.4.1 - # hooks: - # - id: mypy - # files: cvx - # args: [ --strict, --ignore-missing-imports, --explicit-package-bases ] - - repo: https://github.com/python-jsonschema/check-jsonschema rev: 0.30.0 hooks: @@ -45,3 +41,19 @@ repos: files: ^(cvx) args: ['--license-filepath', 'copyright.txt', '--no-extra-eol'] + + - repo: https://github.com/rhysd/actionlint + rev: v1.7.5 + hooks: + - id: actionlint + args: [-ignore, SC] + + - repo: https://github.com/abravalheri/validate-pyproject + rev: v0.23 + hooks: + - id: validate-pyproject + + - repo: https://github.com/crate-ci/typos + rev: v1.29.0 + hooks: + - id: typos diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8c6c937b..ab8a2a1a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,7 +19,7 @@ Before sending a pull request, make sure you do the following: ## Building cvxbson from source You'll need to build cvxbson locally in order to start editing code. -Please install [task](https://taskfile.dev) +Please install [task](https://taskfile.dev). To install cvxbson from source, clone the Github repository, navigate to its root, and run the following command: diff --git a/cvx/bson/file.py b/cvx/bson/file.py index 4529bda3..5ea2747e 100644 --- a/cvx/bson/file.py +++ b/cvx/bson/file.py @@ -14,6 +14,7 @@ """ Tools to support working with bson files and strings """ + from __future__ import annotations from os import PathLike diff --git a/cvx/bson/io.py b/cvx/bson/io.py index d998b59b..c0a58cbe 100644 --- a/cvx/bson/io.py +++ b/cvx/bson/io.py @@ -51,7 +51,7 @@ def encode(data: Union[np.ndarray, pd.DataFrame, pl.DataFrame]) -> Any: # return bytes. # print(encoded_tuple) # decoded_color = encoded_color.decode() - # orginal_form = json.load(decoded_color) + # original_form = json.load(decoded_color) # return # raise TypeError(f"Invalid Datatype {type(data)}") diff --git a/cvx/json/file.py b/cvx/json/file.py index e37adb21..6e8452c7 100644 --- a/cvx/json/file.py +++ b/cvx/json/file.py @@ -14,6 +14,7 @@ """ Tools to support working with json files """ + import json from collections.abc import Iterable from os import PathLike diff --git a/experiment/demo1.py b/experiment/demo1.py index b76bddab..5eb65da6 100644 --- a/experiment/demo1.py +++ b/experiment/demo1.py @@ -14,9 +14,7 @@ class DataAPI(Data): C: pl.DataFrame # Define a mutable value for the mapping from short name to full name - tables: Dict[str, str] = field( - default_factory=lambda: {"A": "AAA", "B": "BBB", "C": "CCC"} - ) + tables: Dict[str, str] = field(default_factory=lambda: {"A": "AAA", "B": "BBB", "C": "CCC"}) if __name__ == "__main__": diff --git a/experiment/fill.py b/experiment/fill.py index a132f573..336d13f6 100644 --- a/experiment/fill.py +++ b/experiment/fill.py @@ -3,7 +3,7 @@ if __name__ == "__main__": # gain this dictionary through reflection # every table has a shortname, e.g. prices and a longer descriptive name - # we use the shortname to name the variable refering to the code + # we use the shortname to name the variable referring to the code names = {"A": "AAA", "B": "BBB", "C": "CCC"} strategy = "s239" diff --git a/pyproject.toml b/pyproject.toml index 5c04fa4e..4829c28f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,15 +25,16 @@ dev = [ "loguru>=0.7.0" ] - [tool.ruff] -select = ["E", "F", "I"] line-length = 120 target-version = "py310" exclude = [ "*__init__.py" ] +[tool.ruff.lint] +select = ["E", "F", "I"] + [build-system] requires = ["hatchling"] build-backend = "hatchling.build" diff --git a/tests/test_bson.py b/tests/test_bson.py index 1722fe38..cd59f2eb 100644 --- a/tests/test_bson.py +++ b/tests/test_bson.py @@ -6,9 +6,7 @@ from cvx.bson.file import from_bson, read_bson, to_bson, write_bson -@pytest.mark.parametrize( - "shape", [(50, 50), (1000, 50), (50, 1000), (1000, 1000), (5000, 2000)] -) +@pytest.mark.parametrize("shape", [(50, 50), (1000, 50), (50, 1000), (1000, 1000), (5000, 2000)]) def test_write(tmp_path, shape): """ Test that a numpy array is written and read correctly @@ -42,9 +40,7 @@ def test_vector(tmp_path): np.allclose(x["a"], data["a"]) -@pytest.mark.parametrize( - "shape", [(50, 50), (1000, 50), (50, 1000), (1000, 1000), (5000, 2000)] -) +@pytest.mark.parametrize("shape", [(50, 50), (1000, 50), (50, 1000), (1000, 1000), (5000, 2000)]) def test_without_file(shape): """ Test that a matrix is written and read correctly diff --git a/tests/test_json.py b/tests/test_json.py index fa359296..10b80606 100644 --- a/tests/test_json.py +++ b/tests/test_json.py @@ -4,9 +4,7 @@ from cvx.json import read_json, write_json -@pytest.mark.parametrize( - "shape", [(50, 50), (1000, 50), (50, 1000), (1000, 1000), (5000, 2000)] -) +@pytest.mark.parametrize("shape", [(50, 50), (1000, 50), (50, 1000), (1000, 1000), (5000, 2000)]) def test_read_and_write_json(tmp_path, shape): """ Test that a numpy array is written and read correctly