fieldproof 0.2.1__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. {fieldproof-0.2.1 → fieldproof-0.2.2}/CHANGELOG.md +12 -0
  2. {fieldproof-0.2.1 → fieldproof-0.2.2}/PKG-INFO +2 -1
  3. {fieldproof-0.2.1 → fieldproof-0.2.2}/README.md +1 -0
  4. {fieldproof-0.2.1 → fieldproof-0.2.2}/pyproject.toml +1 -1
  5. {fieldproof-0.2.1 → fieldproof-0.2.2}/src/fieldproof/__init__.py +1 -1
  6. {fieldproof-0.2.1 → fieldproof-0.2.2}/src/fieldproof/cli.py +19 -1
  7. {fieldproof-0.2.1 → fieldproof-0.2.2}/src/fieldproof/extract/base.py +10 -1
  8. {fieldproof-0.2.1 → fieldproof-0.2.2}/.gitignore +0 -0
  9. {fieldproof-0.2.1 → fieldproof-0.2.2}/LICENSE +0 -0
  10. {fieldproof-0.2.1 → fieldproof-0.2.2}/src/fieldproof/document/__init__.py +0 -0
  11. {fieldproof-0.2.1 → fieldproof-0.2.2}/src/fieldproof/document/loader.py +0 -0
  12. {fieldproof-0.2.1 → fieldproof-0.2.2}/src/fieldproof/document/model.py +0 -0
  13. {fieldproof-0.2.1 → fieldproof-0.2.2}/src/fieldproof/document/ocr.py +0 -0
  14. {fieldproof-0.2.1 → fieldproof-0.2.2}/src/fieldproof/document/render.py +0 -0
  15. {fieldproof-0.2.1 → fieldproof-0.2.2}/src/fieldproof/extract/__init__.py +0 -0
  16. {fieldproof-0.2.1 → fieldproof-0.2.2}/src/fieldproof/extract/anthropic_provider.py +0 -0
  17. {fieldproof-0.2.1 → fieldproof-0.2.2}/src/fieldproof/extract/fixture_provider.py +0 -0
  18. {fieldproof-0.2.1 → fieldproof-0.2.2}/src/fieldproof/ground/__init__.py +0 -0
  19. {fieldproof-0.2.1 → fieldproof-0.2.2}/src/fieldproof/ground/align.py +0 -0
  20. {fieldproof-0.2.1 → fieldproof-0.2.2}/src/fieldproof/ground/normalize.py +0 -0
  21. {fieldproof-0.2.1 → fieldproof-0.2.2}/src/fieldproof/schemas/__init__.py +0 -0
  22. {fieldproof-0.2.1 → fieldproof-0.2.2}/src/fieldproof/schemas/base.py +0 -0
  23. {fieldproof-0.2.1 → fieldproof-0.2.2}/src/fieldproof/schemas/contract.py +0 -0
  24. {fieldproof-0.2.1 → fieldproof-0.2.2}/src/fieldproof/schemas/invoice.py +0 -0
  25. {fieldproof-0.2.1 → fieldproof-0.2.2}/src/fieldproof/schemas/receipt.py +0 -0
  26. {fieldproof-0.2.1 → fieldproof-0.2.2}/src/fieldproof/server/__init__.py +0 -0
  27. {fieldproof-0.2.1 → fieldproof-0.2.2}/src/fieldproof/server/app.py +0 -0
  28. {fieldproof-0.2.1 → fieldproof-0.2.2}/src/fieldproof/server/static/assets/index-BLATbujI.js +0 -0
  29. {fieldproof-0.2.1 → fieldproof-0.2.2}/src/fieldproof/server/static/assets/index-Bo892MpF.css +0 -0
  30. {fieldproof-0.2.1 → fieldproof-0.2.2}/src/fieldproof/server/static/index.html +0 -0
  31. {fieldproof-0.2.1 → fieldproof-0.2.2}/src/fieldproof/server/store.py +0 -0
  32. {fieldproof-0.2.1 → fieldproof-0.2.2}/src/fieldproof/verify/__init__.py +0 -0
  33. {fieldproof-0.2.1 → fieldproof-0.2.2}/src/fieldproof/verify/cross_field.py +0 -0
  34. {fieldproof-0.2.1 → fieldproof-0.2.2}/src/fieldproof/verify/engine.py +0 -0
  35. {fieldproof-0.2.1 → fieldproof-0.2.2}/src/fieldproof/verify/value_checks.py +0 -0
@@ -2,6 +2,18 @@
2
2
 
3
3
  All notable changes to this project are documented in this file.
4
4
 
5
+ ## [0.2.2] - 2026-10-02
6
+
7
+ ### Fixed
8
+
9
+ - A result or fixture JSON saved by a Windows editor or shell. Notepad's
10
+ "UTF-8 with BOM" and PowerShell's `-Encoding utf8` put a byte-order mark
11
+ first ("not valid JSON (line 1, column 1: Unexpected UTF-8 BOM ...)"), and
12
+ PowerShell's `>` writes UTF-16 ("is not UTF-8 text"). All three are read, by
13
+ the CLI and by the review server.
14
+ - Output written to a pipe or a file is UTF-8, so a document path outside the
15
+ system's code page can be printed when stdout is redirected on Windows.
16
+
5
17
  ## [0.2.1] - 2026-10-02
6
18
 
7
19
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: fieldproof
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: Document extraction that shows its work: every field linked to the exact words it came from.
5
5
  Project-URL: Homepage, https://antonsoo.github.io/fieldproof/
6
6
  Project-URL: Repository, https://github.com/antonsoo/fieldproof
@@ -42,6 +42,7 @@ Description-Content-Type: text/markdown
42
42
 
43
43
  **Document extraction that shows its work: every field linked to the exact words it came from.**
44
44
 
45
+ [![PyPI](https://img.shields.io/pypi/v/fieldproof)](https://pypi.org/project/fieldproof/)
45
46
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/antonsoo/fieldproof/blob/main/LICENSE)
46
47
  [![Live demo](https://img.shields.io/badge/demo-antonsoo.github.io%2Ffieldproof-14524c)](https://antonsoo.github.io/fieldproof/)
47
48
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  **Document extraction that shows its work: every field linked to the exact words it came from.**
4
4
 
5
+ [![PyPI](https://img.shields.io/pypi/v/fieldproof)](https://pypi.org/project/fieldproof/)
5
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
6
7
  [![Live demo](https://img.shields.io/badge/demo-antonsoo.github.io%2Ffieldproof-14524c)](https://antonsoo.github.io/fieldproof/)
7
8
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "fieldproof"
3
- version = "0.2.1"
3
+ version = "0.2.2"
4
4
  description = "Document extraction that shows its work: every field linked to the exact words it came from."
5
5
  dynamic = ["readme"]
6
6
  requires-python = ">=3.11"
@@ -5,4 +5,4 @@ reviewer (or a downstream system) can tell a verified value from a
5
5
  hallucinated one before it reaches a database.
6
6
  """
7
7
 
8
- __version__ = "0.2.1"
8
+ __version__ = "0.2.2"
@@ -3,6 +3,7 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import json
6
+ import sys
6
7
  from pathlib import Path
7
8
  from typing import NoReturn
8
9
 
@@ -31,13 +32,30 @@ def _print_version(value: bool) -> None:
31
32
  raise typer.Exit
32
33
 
33
34
 
35
+ def _text_streams() -> None:
36
+ """Make stdout and stderr able to carry any text.
37
+
38
+ A pipe or a file gets UTF-8: before 3.15, Python on Windows gives it the system's code
39
+ page, where a file name outside it raised ``UnicodeEncodeError``. A terminal keeps its
40
+ own encoding and shows a character it cannot encode as an escape.
41
+ """
42
+ for stream in (sys.stdout, sys.stderr):
43
+ reconfigure = getattr(stream, "reconfigure", None)
44
+ if reconfigure is None: # replaced by something that isn't a text file
45
+ continue
46
+ if stream.isatty():
47
+ reconfigure(errors="backslashreplace")
48
+ else:
49
+ reconfigure(encoding="utf-8")
50
+
51
+
34
52
  @app.callback()
35
53
  def _options(
36
54
  version: bool = typer.Option(
37
55
  False, "--version", callback=_print_version, is_eager=True, help="show the version and exit"
38
56
  ),
39
57
  ) -> None:
40
- pass
58
+ _text_streams()
41
59
 
42
60
 
43
61
  def _fail(message: str, code: int = 1) -> NoReturn:
@@ -19,11 +19,20 @@ class ExtractionError(RuntimeError):
19
19
  shape. The message is written for the person who supplied the file."""
20
20
 
21
21
 
22
+ def _decode(content: bytes) -> str:
23
+ """A JSON file's text as editors and shells on Windows save it: UTF-8, with or without a
24
+ byte-order mark (Notepad's "UTF-8 with BOM", PowerShell's `-Encoding utf8`), or UTF-16
25
+ with one (PowerShell's `>`)."""
26
+ if content.startswith((b"\xff\xfe", b"\xfe\xff")):
27
+ return content.decode("utf-16")
28
+ return content.decode("utf-8-sig")
29
+
30
+
22
31
  def read_extraction_json(content: str | bytes, source: str) -> dict[str, Any]:
23
32
  """Parse a stored extraction (a fixture, or another tool's `result.json`).
24
33
  `source` names the file in the error."""
25
34
  try:
26
- text = content.decode("utf-8") if isinstance(content, bytes) else content
35
+ text = _decode(content) if isinstance(content, bytes) else content
27
36
  raw = json.loads(text)
28
37
  except UnicodeDecodeError as exc:
29
38
  raise ExtractionError(f"{source} is not UTF-8 text") from exc
File without changes
File without changes