Commit 4db3503
refactor: code cleanup and improvements (#63)
* test: use bash from PATH for portability
* refactor: rename ContextVar from var_ prefix to ctx_ prefix
Improve naming clarity for module-level ContextVar variables:
- var_root -> ctx_root
- var_parent -> ctx_parent
- var_self -> ctx_self
- var_finding -> ctx_finding
Amp-Thread-ID: https://ampcode.com/threads/T-019c2e4e-7deb-7076-8168-36fbd8141afa
Co-authored-by: Amp <amp@ampcode.com>
* refactor: use dict mapping for comparison operators in transformer
Replace if-elif chain with COMPARISON_OPERATORS dict for better
readability and extensibility.
Amp-Thread-ID: https://ampcode.com/threads/T-019c2e4e-7deb-7076-8168-36fbd8141afa
Co-authored-by: Amp <amp@ampcode.com>
* refactor: improve CLI error handling with proper exception chaining
- Use 'raise SystemExit() from exc' to preserve exception chain
- Add try-except for file reading and JSON parsing errors
- Provide more descriptive error messages
Amp-Thread-ID: https://ampcode.com/threads/T-019c2e4e-7deb-7076-8168-36fbd8141afa
Co-authored-by: Amp <amp@ampcode.com>
* refactor: simplify Slice.find default value assignments
- Use 'or' operator to reduce redundant if statements
- Replace assert with proper JSONPathFindError exception
Amp-Thread-ID: https://ampcode.com/threads/T-019c2e4e-7deb-7076-8168-36fbd8141afa
Co-authored-by: Amp <amp@ampcode.com>
* refactor: reduce Compare subclass boilerplate with _symbol and _operator
- Add _symbol and _operator class attributes to Compare base class
- Move common _get_partial_expression and find to base class
- Subclasses now only define _symbol and _operator attributes
- And/Or retain custom find for short-circuit evaluation semantics
Amp-Thread-ID: https://ampcode.com/threads/T-019c2e4e-7deb-7076-8168-36fbd8141afa
Co-authored-by: Amp <amp@ampcode.com>
* refactor: replace assert with proper TypeError exceptions
- Array.__init__: use TypeError for invalid idx parameter
- Predicate.__init__: use TypeError for invalid expr parameter
- Brace.__init__: use TypeError for invalid expr parameter
- Search.__init__: use TypeError for invalid expr parameter
- Key.__init__: use TypeError for unexpected arguments
- Contains.__init__: use TypeError for invalid parameters
- Not.__init__: use TypeError for invalid parameters
This ensures type checks work even with Python -O optimization.
Amp-Thread-ID: https://ampcode.com/threads/T-019c2e4e-7deb-7076-8168-36fbd8141afa
Co-authored-by: Amp <amp@ampcode.com>
* refactor: final cleanup of assert statements and if-elif chains
- get_begin: replace assert with RuntimeError
- Array.find: simplify control flow, remove unreachable AssertionError
- predicate: merge isinstance checks to remove assert
- func_call: use FUNCTIONS dict mapping instead of if-elif chain
Amp-Thread-ID: https://ampcode.com/threads/T-019c2e4e-7deb-7076-8168-36fbd8141afa
Co-authored-by: Amp <amp@ampcode.com>
* refactor: minor cleanup for naming consistency
- Slice: rename self.end to self.stop to match parameter name
- comparison_expr: use ValueError instead of AssertionError
- doctest: update var_boo to ctx_boo for naming consistency
Amp-Thread-ID: https://ampcode.com/threads/T-019c2e4e-7deb-7076-8168-36fbd8141afa
Co-authored-by: Amp <amp@ampcode.com>
* ci: add Python 3.14 support and update actions/cache to v4
* ci: migrate from PDM to Nix-based workflow and add Python 3.14 support
- Replace PDM setup with custom Nix GitHub Action for CI
- Add new Nix build check job to verify flake builds
- Update GitHub Actions: checkout@v6, actions/cache@v5, codecov-action@v5
- Add Nix store and Cargo dependency caching
- Switch from pre-commit to prek for linting
- Update flake inputs to use nixpkgs-unstable directly
- Add Python 3.14 to test matrix (3.10-3.14)
- Update dependency versions (babel, charset-normalizer, coverage, etc.)
- Add make init step before running tests
* ci: update actions/cache to v4
---------
Co-authored-by: Amp <amp@ampcode.com>1 parent c2cbdac commit 4db3503
File tree
16 files changed
+1361
-997
lines changed- .github
- actions/setup-nix
- workflows
- jsonpath
- scripts/requirements
- tests
16 files changed
+1361
-997
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
18 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
19 | 20 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
35 | 42 | | |
36 | 43 | | |
37 | 44 | | |
38 | 45 | | |
39 | 46 | | |
40 | | - | |
| 47 | + | |
41 | 48 | | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
47 | 52 | | |
48 | | - | |
| 53 | + | |
49 | 54 | | |
50 | 55 | | |
51 | 56 | | |
| |||
56 | 61 | | |
57 | 62 | | |
58 | 63 | | |
| 64 | + | |
59 | 65 | | |
60 | 66 | | |
61 | | - | |
| 67 | + | |
62 | 68 | | |
63 | 69 | | |
64 | 70 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
23 | 26 | | |
24 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
25 | 31 | | |
26 | | - | |
| 32 | + | |
27 | 33 | | |
28 | 34 | | |
29 | 35 | | |
| |||
0 commit comments