Skip to content

Commit

Permalink
hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
tschm committed Jan 1, 2025
1 parent e5596ff commit 1e86cf4
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 24 deletions.
26 changes: 19 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions cvx/bson/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"""
Tools to support working with bson files and strings
"""

from __future__ import annotations

from os import PathLike
Expand Down
2 changes: 1 addition & 1 deletion cvx/bson/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)}")
Expand Down
1 change: 1 addition & 0 deletions cvx/json/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"""
Tools to support working with json files
"""

import json
from collections.abc import Iterable
from os import PathLike
Expand Down
4 changes: 1 addition & 3 deletions experiment/demo1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down
2 changes: 1 addition & 1 deletion experiment/fill.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 2 additions & 6 deletions tests/test_bson.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions tests/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1e86cf4

Please sign in to comment.