Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
geminixiang committed Oct 20, 2023
1 parent 157153c commit a068622
Show file tree
Hide file tree
Showing 18 changed files with 28 additions and 28 deletions.
46 changes: 23 additions & 23 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.5.0
hooks:
# - id: check-added-large-files
- id: check-case-conflict
- id: check-json
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- id: check-case-conflict
- id: check-merge-conflict
- id: end-of-file-fixer
- id: fix-encoding-pragma
args: [--remove]
- id: mixed-line-ending
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
exclude: "__snapshots__/"
# this is not technically always safe but usually is
# use comments `# isort: off` and `# isort: on` to disable/re-enable isort

- repo: https://github.com/psf/black
rev: 23.10.0
hooks:
- id: black
args:
- "--line-length=240"

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.1
hooks:
- id: ruff
args:
- "--line-length=240"

- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
args: [--line-length=240, --profile=black]

# this is slightly dangerous because python imports have side effects
# and this tool removes unused imports, which may be providing
# necessary side effects for the code to run
- repo: https://github.com/PyCQA/autoflake
rev: v1.6.1
- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
hooks:
- id: autoflake
args:
- "--in-place"
- "--expand-star-imports"
- "--remove-duplicate-keys"
- "--remove-unused-variables"
- "--remove-all-unused-imports"

- repo: https://github.com/psf/black
rev: 22.8.0
hooks:
- id: black
args: [--line-length=240, --exclude=""]
- id: codespell
types_or: [python, markdown]

- repo: local
hooks:
Expand Down
4 changes: 2 additions & 2 deletions src/fuzzy_json/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def state_int(input: str, stack: list[str]) -> str | None:
if input[0].isspace():
return input[0] + state_post_value(input[1:], stack)
# NOTE:
# the original grammer not accept 3e3 (without dot)
# the original grammar not accept 3e3 (without dot)
if input[0] in {"e", "E"}:
return input[0] + state_exponent_sign(input[1:], stack)

Expand Down Expand Up @@ -228,7 +228,7 @@ def state_double(input: str, stack: list[str]) -> str | None:
@state
def state_exponent_sign(input: str, stack: list[str]) -> str | None:
# NOTE:
# the original grammer not accept 3.0e3 (without sign)
# the original grammar not accept 3.0e3 (without sign)
if input[0].isdigit():
return input[0] + state_exponent_digits(input[1:], stack)

Expand Down
6 changes: 3 additions & 3 deletions src/fuzzy_json/tests/test_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_repaired_json_simple_case(snapshot: SnapshotAssertion) -> None:

@pytest.mark.parametrize(
"test_filename",
(Path(__file__).parent / "test_data").glob("vaild/*.json"),
(Path(__file__).parent / "test_data").glob("valid/*.json"),
ids=lambda x: x.name,
)
def test_repaired_json_vaild_case(snapshot: SnapshotAssertion, test_filename: Path) -> None:
Expand All @@ -39,7 +39,7 @@ def test_repaired_json_vaild_case(snapshot: SnapshotAssertion, test_filename: Pa

@pytest.mark.parametrize(
"test_filename",
(Path(__file__).parent / "test_data").glob("invaild/*.jsonx"),
(Path(__file__).parent / "test_data").glob("invalid/*.jsonx"),
ids=lambda x: x.name,
)
def test_repaired_json_invaild_case(snapshot: SnapshotAssertion, test_filename: Path) -> None:
Expand All @@ -49,6 +49,6 @@ def test_repaired_json_invaild_case(snapshot: SnapshotAssertion, test_filename:


def test_repair_json_fail() -> None:
with pytest.raises(json.decoder.JSONDecodeError) as e:
with pytest.raises(json.decoder.JSONDecodeError) as _:
# test that it will raise JSONDecodeError if it can't fix the JSON
loads("{", auto_repair=True)

0 comments on commit a068622

Please sign in to comment.