Skip to content

Commit d9322c9

Browse files
authored
feat!: Bump openjd-* Rust crates to the openjd-model 0.13.0 release (#378)
* feat!: Bump openjd-* Rust crates to the openjd-model 0.13.0 release openjd-expr 0.10.1 -> 0.12.0, openjd-model 0.11.0 -> 0.13.0 and openjd-sessions 0.7.3 -> 0.8.1. The bindings compile unchanged. Tests that pinned old upstream behaviour now assert the new one: syntax errors use CPython's wording (openjd-rs#429), incompatible list types read "int and string" (#434), and a create_job let failure is a ModelValidationError at the binding's path (#428). New tests cover and/or typing after an unresolved operand (#435) and one-letter URI schemes treated as paths (#424); each fails on the old pins. BREAKING CHANGE: create_job raises ModelValidationError instead of ExpressionError for a let-binding failure. Some templates that decoded before are now rejected: and/or after an unresolved operand types as a union (#435), nested lists with mismatched element types (#434), and parameter-dependent invalid timeouts (#428). Building from source needs Rust 1.97. Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com> * fix: Type field-annotation walkers' model as Any for pydantic 2.14 pydantic 2.14 types FieldInfo.annotation as TypeForm[Any], so mypy 2.3 rejects passing it to two walkers declared `model: Type`. They already take Unions and generic aliases and dispatch on typing.get_origin, so `Type` was never accurate. No runtime change. Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com> * test: Pin the path format in the one-letter scheme tests The default path format follows the host, so on Windows the drive-letter cases render with backslashes. Assert both formats explicitly. Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com> --------- Signed-off-by: David Leong <116610336+leongdl@users.noreply.github.com>
1 parent 3d38d2e commit d9322c9

8 files changed

Lines changed: 450 additions & 82 deletions

File tree

‎Cargo.lock‎

Lines changed: 241 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎THIRD-PARTY-LICENSES.txt‎

Lines changed: 126 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2424
SOFTWARE.
2525

2626
------
27-
** pydantic; version 2.13.5 -- https://pypi.org/project/pydantic/
27+
** pydantic; version 2.14.1 -- https://pypi.org/project/pydantic/
2828
The MIT License (MIT)
2929

3030
Copyright (c) 2017 to present Pydantic Services Inc. and individual contributors.
@@ -48,7 +48,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
4848
SOFTWARE.
4949

5050
------
51-
** pydantic_core; version 2.46.5 -- https://pypi.org/project/pydantic_core/
51+
** pydantic_core; version 2.50.1 -- https://pypi.org/project/pydantic_core/
5252
The MIT License (MIT)
5353

5454
Copyright (c) 2022 Samuel Colvin
@@ -607,11 +607,11 @@ PERFORMANCE OF THIS SOFTWARE.
607607
limitations under the License.
608608

609609
------
610-
** derive-where; version 1.6.1 -- https://crates.io/crates/derive-where
611610
** encoding_rs; version 0.8.35 -- https://crates.io/crates/encoding_rs
612611
** nohash-hasher; version 0.2.0 -- https://crates.io/crates/nohash-hasher
613612
** static_assertions; version 1.1.0 -- https://crates.io/crates/static_assertions
614613
** tinyvec; version 1.12.0 -- https://crates.io/crates/tinyvec
614+
** utf8_iter; version 1.0.4 -- https://crates.io/crates/utf8_iter
615615

616616
Apache License
617617
Version 2.0, January 2004
@@ -1041,9 +1041,9 @@ Software.
10411041

10421042

10431043
------
1044-
** attribute-derive; version 0.10.5 -- https://crates.io/crates/attribute-derive
1044+
** attribute-derive; version 0.11.0 -- https://crates.io/crates/attribute-derive
10451045
** interpolator; version 0.5.0 -- https://crates.io/crates/interpolator
1046-
** manyhow; version 0.11.4 -- https://crates.io/crates/manyhow
1046+
** manyhow; version 0.14.1 -- https://crates.io/crates/manyhow
10471047
** proc-macro-utils; version 0.10.0 -- https://crates.io/crates/proc-macro-utils
10481048
Apache License
10491049
Version 2.0, January 2004
@@ -2094,6 +2094,7 @@ limitations under the License.
20942094
** bitflags; version 2.13.1 -- https://crates.io/crates/bitflags
20952095
** bstr; version 1.13.1 -- https://crates.io/crates/bstr
20962096
** cfg-if; version 1.0.4 -- https://crates.io/crates/cfg-if
2097+
** displaydoc; version 0.2.7 -- https://crates.io/crates/displaydoc
20972098
** drop_bomb; version 0.1.5 -- https://crates.io/crates/drop_bomb
20982099
** either; version 1.18.0 -- https://crates.io/crates/either
20992100
** encoding_rs_io; version 0.1.8 -- https://crates.io/crates/encoding_rs_io
@@ -2113,6 +2114,7 @@ limitations under the License.
21132114
** regex; version 1.13.1 -- https://crates.io/crates/regex
21142115
** signal-hook-registry; version 1.4.8 -- https://crates.io/crates/signal-hook-registry
21152116
** smallvec; version 1.15.2 -- https://crates.io/crates/smallvec
2117+
** stable_deref_trait; version 1.2.1 -- https://crates.io/crates/stable_deref_trait
21162118
** stacker; version 0.1.25 -- https://crates.io/crates/stacker
21172119
** unicode-normalization; version 0.1.25 -- https://crates.io/crates/unicode-normalization
21182120
** unicode-width; version 0.2.2 -- https://crates.io/crates/unicode-width
@@ -2735,15 +2737,15 @@ limitations under the License.
27352737

27362738
------
27372739
** arraydeque; version 0.5.1 -- https://crates.io/crates/arraydeque
2738-
** get-size-derive2; version 0.10.3 -- https://crates.io/crates/get-size-derive2
2739-
** get-size2; version 0.10.3 -- https://crates.io/crates/get-size2
2740+
** get-size-derive2; version 0.11.1 -- https://crates.io/crates/get-size-derive2
2741+
** get-size2; version 0.11.1 -- https://crates.io/crates/get-size2
27402742
** granit-parser; version 1.2.0 -- https://crates.io/crates/granit-parser
27412743
** itoa; version 1.0.18 -- https://crates.io/crates/itoa
27422744
** libc; version 0.2.189 -- https://crates.io/crates/libc
2743-
** manyhow-macros; version 0.11.4 -- https://crates.io/crates/manyhow-macros
2744-
** openjd-expr; version 0.10.1 -- https://crates.io/crates/openjd-expr
2745-
** openjd-model; version 0.11.0 -- https://crates.io/crates/openjd-model
2746-
** openjd-sessions; version 0.7.3 -- https://crates.io/crates/openjd-sessions
2745+
** manyhow-macros; version 0.14.1 -- https://crates.io/crates/manyhow-macros
2746+
** openjd-expr; version 0.12.0 -- https://crates.io/crates/openjd-expr
2747+
** openjd-model; version 0.13.0 -- https://crates.io/crates/openjd-model
2748+
** openjd-sessions; version 0.8.1 -- https://crates.io/crates/openjd-sessions
27472749
** pin-project-lite; version 0.2.17 -- https://crates.io/crates/pin-project-lite
27482750
** portable-atomic; version 1.15.0 -- https://crates.io/crates/portable-atomic
27492751
** proc-macro2; version 1.0.107 -- https://crates.io/crates/proc-macro2
@@ -3013,6 +3015,36 @@ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30133015
DEALINGS IN THE SOFTWARE.
30143016

30153017

3018+
------
3019+
** quote-use-macros; version 0.9.0 -- https://crates.io/crates/quote-use-macros
3020+
** quote-use; version 0.9.0 -- https://crates.io/crates/quote-use
3021+
Copyright (c) Roland Fredenhagen
3022+
3023+
Permission is hereby granted, free of charge, to any
3024+
person obtaining a copy of this software and associated
3025+
documentation files (the "Software"), to deal in the
3026+
Software without restriction, including without
3027+
limitation the rights to use, copy, modify, merge,
3028+
publish, distribute, sublicense, and/or sell copies of
3029+
the Software, and to permit persons to whom the Software
3030+
is furnished to do so, subject to the following
3031+
conditions:
3032+
3033+
The above copyright notice and this permission notice
3034+
shall be included in all copies or substantial portions
3035+
of the Software.
3036+
3037+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
3038+
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
3039+
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
3040+
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
3041+
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
3042+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
3043+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
3044+
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
3045+
DEALINGS IN THE SOFTWARE.
3046+
3047+
30163048
------
30173049
** collection_literals; version 1.0.3 -- https://crates.io/crates/collection_literals
30183050
Copyright (c) The collection_literals Contributors
@@ -3042,6 +3074,17 @@ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30423074
DEALINGS IN THE SOFTWARE.
30433075

30443076

3077+
------
3078+
** synstructure; version 0.14.0 -- https://crates.io/crates/synstructure
3079+
Copyright 2016 Nika Layzell
3080+
3081+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
3082+
3083+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
3084+
3085+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3086+
3087+
30453088
------
30463089
** tokio-macros; version 2.7.2 -- https://crates.io/crates/tokio-macros
30473090
MIT License
@@ -3119,7 +3162,7 @@ SOFTWARE.
31193162

31203163

31213164
------
3122-
** attribute-derive-macro; version 0.10.5 -- https://crates.io/crates/attribute-derive-macro
3165+
** attribute-derive-macro; version 0.11.0 -- https://crates.io/crates/attribute-derive-macro
31233166
MIT License
31243167

31253168
Copyright (c) 2022 Roland Fredenhagen
@@ -3144,7 +3187,7 @@ SOFTWARE.
31443187

31453188

31463189
------
3147-
** char_str; version 0.0.2 -- https://crates.io/crates/char_str
3190+
** char_str; version 0.0.4 -- https://crates.io/crates/char_str
31483191
MIT License
31493192

31503193
Copyright (c) 2024 ryota2357
@@ -3169,13 +3212,11 @@ SOFTWARE.
31693212

31703213

31713214
------
3172-
** quote-use-macros; version 0.8.4 -- https://crates.io/crates/quote-use-macros
3173-
** quote-use; version 0.8.4 -- https://crates.io/crates/quote-use
3174-
** rustpython-ruff_python_ast; version 0.16.5 -- https://crates.io/crates/rustpython-ruff_python_ast
3175-
** rustpython-ruff_python_parser; version 0.16.5 -- https://crates.io/crates/rustpython-ruff_python_parser
3176-
** rustpython-ruff_python_trivia; version 0.16.5 -- https://crates.io/crates/rustpython-ruff_python_trivia
3177-
** rustpython-ruff_source_file; version 0.16.5 -- https://crates.io/crates/rustpython-ruff_source_file
3178-
** rustpython-ruff_text_size; version 0.16.5 -- https://crates.io/crates/rustpython-ruff_text_size
3215+
** rustpython-ruff_python_ast; version 0.16.10 -- https://crates.io/crates/rustpython-ruff_python_ast
3216+
** rustpython-ruff_python_parser; version 0.16.10 -- https://crates.io/crates/rustpython-ruff_python_parser
3217+
** rustpython-ruff_python_trivia; version 0.16.10 -- https://crates.io/crates/rustpython-ruff_python_trivia
3218+
** rustpython-ruff_source_file; version 0.16.10 -- https://crates.io/crates/rustpython-ruff_source_file
3219+
** rustpython-ruff_text_size; version 0.16.10 -- https://crates.io/crates/rustpython-ruff_text_size
31793220
MIT License
31803221

31813222
Copyright (c) <year> <copyright holders>
@@ -3368,6 +3409,71 @@ dealings in these Data Files or Software without prior written
33683409
authorization of the copyright holder.
33693410

33703411

3412+
------
3413+
** icu_collections; version 2.3.0 -- https://crates.io/crates/icu_collections
3414+
** icu_locale_core; version 2.3.0 -- https://crates.io/crates/icu_locale_core
3415+
** icu_properties; version 2.3.0 -- https://crates.io/crates/icu_properties
3416+
** icu_properties_data; version 2.3.0 -- https://crates.io/crates/icu_properties_data
3417+
** icu_provider; version 2.3.1 -- https://crates.io/crates/icu_provider
3418+
** litemap; version 0.8.3 -- https://crates.io/crates/litemap
3419+
** potential_utf; version 0.1.6 -- https://crates.io/crates/potential_utf
3420+
** tinystr; version 0.8.4 -- https://crates.io/crates/tinystr
3421+
** writeable; version 0.6.4 -- https://crates.io/crates/writeable
3422+
** yoke-derive; version 0.8.4 -- https://crates.io/crates/yoke-derive
3423+
** yoke; version 0.8.3 -- https://crates.io/crates/yoke
3424+
** zerofrom-derive; version 0.1.8 -- https://crates.io/crates/zerofrom-derive
3425+
** zerofrom; version 0.1.8 -- https://crates.io/crates/zerofrom
3426+
** zerotrie; version 0.2.5 -- https://crates.io/crates/zerotrie
3427+
** zerovec-derive; version 0.11.6 -- https://crates.io/crates/zerovec-derive
3428+
** zerovec; version 0.11.8 -- https://crates.io/crates/zerovec
3429+
UNICODE LICENSE V3
3430+
3431+
COPYRIGHT AND PERMISSION NOTICE
3432+
3433+
Copyright © 2020-2024 Unicode, Inc.
3434+
3435+
NOTICE TO USER: Carefully read the following legal agreement. BY
3436+
DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING DATA FILES, AND/OR
3437+
SOFTWARE, YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
3438+
TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT
3439+
DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.
3440+
3441+
Permission is hereby granted, free of charge, to any person obtaining a
3442+
copy of data files and any associated documentation (the "Data Files") or
3443+
software and any associated documentation (the "Software") to deal in the
3444+
Data Files or Software without restriction, including without limitation
3445+
the rights to use, copy, modify, merge, publish, distribute, and/or sell
3446+
copies of the Data Files or Software, and to permit persons to whom the
3447+
Data Files or Software are furnished to do so, provided that either (a)
3448+
this copyright and permission notice appear with all copies of the Data
3449+
Files or Software, or (b) this copyright and permission notice appear in
3450+
associated Documentation.
3451+
3452+
THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
3453+
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
3454+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
3455+
THIRD PARTY RIGHTS.
3456+
3457+
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE
3458+
BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES,
3459+
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
3460+
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
3461+
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA
3462+
FILES OR SOFTWARE.
3463+
3464+
Except as contained in this notice, the name of a copyright holder shall
3465+
not be used in advertising or otherwise to promote the sale, use or other
3466+
dealings in these Data Files or Software without prior written
3467+
authorization of the copyright holder.
3468+
3469+
SPDX-License-Identifier: Unicode-3.0
3470+
3471+
—
3472+
3473+
Portions of ICU4X may have been adapted from ICU4C and/or ICU4J.
3474+
ICU 1.8.1 to ICU 57.1 © 1995-2016 International Business Machines Corporation and others.
3475+
3476+
33713477
------
33723478
** unicode_names2; version 1.3.0 -- https://crates.io/crates/unicode_names2
33733479
UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE

‎rust-bindings/Cargo.toml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ name = "_openjd_rs"
1212
crate-type = ["cdylib", "rlib"]
1313

1414
[dependencies]
15-
openjd-expr = "0.10.1"
16-
openjd-model = "0.11.0"
17-
openjd-sessions = "0.7.3"
15+
openjd-expr = "0.12.0"
16+
openjd-model = "0.13.0"
17+
openjd-sessions = "0.8.1"
1818
tokio = { version = "1", features = ["rt-multi-thread"] }
1919
uuid = { version = "1", features = ["v4"] }
2020
serde_json = "1"

‎src/openjd/model/_internal/_variable_reference_validation.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def _internal_deepcopy(value: Any) -> Any:
236236

237237

238238
def _validate_model_template_variable_references(
239-
model: Type,
239+
model: Any, # a field annotation: a class, a Union, or a generic alias
240240
value: Any,
241241
current_scope: ResolutionScope,
242242
symbol_prefix: str,
@@ -831,7 +831,7 @@ def _symbol_expr_type(value: dict, raw: bool) -> Optional[str]:
831831

832832

833833
def _collect_variable_definitions( # noqa: C901 (suppress: too complex)
834-
model: Type,
834+
model: Any, # a field annotation: a class, a Union, or a generic alias
835835
value: Any,
836836
current_scope: ResolutionScope,
837837
symbol_prefix: str,

‎test/openjd/expr/test_error_formatting.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,9 @@ def test_unclosed_paren(self):
308308
"""Unclosed parenthesis shows caret spanning the expression."""
309309
with pytest.raises(ExpressionError) as exc_info:
310310
evaluate_expression("(1 + 2", values=SymbolTable())
311+
# CPython's wording since ruff 0.16.10 (openjd-rs#429).
311312
expected = [
312-
"Syntax error: unexpected EOF while parsing\n",
313+
"Syntax error: '(' was never closed\n",
313314
" (1 + 2\n",
314315
" ^~~~~~",
315316
]
@@ -320,7 +321,7 @@ def test_unclosed_bracket(self):
320321
with pytest.raises(ExpressionError) as exc_info:
321322
evaluate_expression("[1, 2, 3", values=SymbolTable())
322323
expected = [
323-
"Syntax error: unexpected EOF while parsing\n",
324+
"Syntax error: '[' was never closed\n",
324325
" [1, 2, 3\n",
325326
" ^~~~~~~~",
326327
]
@@ -331,7 +332,7 @@ def test_unclosed_string(self):
331332
with pytest.raises(ExpressionError) as exc_info:
332333
evaluate_expression("'unclosed", values=SymbolTable())
333334
expected = [
334-
"Syntax error: missing closing quote in string literal\n",
335+
"Syntax error: unterminated string literal (detected at line 1)\n",
335336
" 'unclosed\n",
336337
" ^~~~~~~~~",
337338
]

‎test/openjd/expr/test_unresolved_eval.py‎

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ def test_incompatible_types_error(self) -> None:
348348
with pytest.raises(ExpressionError) as exc_info:
349349
evaluate_expression("[X, Y]", values=values)
350350
expected = [
351-
"List literal contains incompatible types: int, string\n",
351+
"List literal contains incompatible types: int and string\n",
352352
" [X, Y]\n",
353353
" ^~~~~~",
354354
]
@@ -908,3 +908,38 @@ def test_a_value_error_in_a_branch_is_still_absorbed(self, expression: str) -> N
908908
def test_the_expression_fits_within_a_generous_budget(self, expression: str) -> None:
909909
result = evaluate_expression(expression, values=self._values())
910910
assert result.type == ExprType("unresolved[string]")
911+
912+
913+
_UNRESOLVED_INT = ExprValue.unresolved(ExprType("int"))
914+
_UNRESOLVED_BOOL = ExprValue.unresolved(ExprType("bool"))
915+
916+
917+
class TestBoolOpAfterAnUnresolvedOperand:
918+
"""openjd-expr 0.12.0 (openjd-rs#435): once an and/or operand is unresolved, the
919+
result is the union of every operand it could return. Before, the first later
920+
concrete operand decided it, so a value error there rejected a valid expression
921+
and a static value appeared that run time never produces.
922+
"""
923+
924+
@pytest.mark.parametrize(
925+
("expression", "values", "expected"),
926+
[
927+
# 0.11.0: "Division by zero", though X may decide the result at run time.
928+
("10 // (X or Z)", {"X": _UNRESOLVED_INT, "Z": ExprValue(0)}, "unresolved[int]"),
929+
# 0.11.0: ExprValue(3).
930+
("X or N", {"X": _UNRESOLVED_INT, "N": ExprValue(3)}, "unresolved[int]"),
931+
# 0.11.0: typed as bool, so "upper() is not available for bool".
932+
(
933+
"(F and S).upper()",
934+
{"F": _UNRESOLVED_BOOL, "S": ExprValue("abc")},
935+
"unresolved[string]",
936+
),
937+
# 0.11.0: ExprValue(0).
938+
("F and 1 or 0", {"F": _UNRESOLVED_BOOL}, "unresolved[int]"),
939+
],
940+
)
941+
def test_the_result_is_unresolved_of_every_reachable_operand(
942+
self, expression: str, values: dict, expected: str
943+
) -> None:
944+
result = evaluate_expression(expression, values=SymbolTable(values))
945+
assert result.type == ExprType(expected)

‎test/openjd/expr/test_uri_paths.py‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
output, identical contract.
1717
"""
1818

19+
import pytest
20+
1921
from openjd.expr import ExprValue, PathFormat, SymbolTable, evaluate_expression
2022

2123

@@ -211,3 +213,26 @@ def test_uri_with_suffix_in_symtab(self) -> None:
211213
"P.with_suffix('.png')", values=symtab, path_format=PathFormat.POSIX
212214
)
213215
assert str(result) == "s3://bucket/scene.png"
216+
217+
218+
class TestSingleLetterSchemeIsAPath:
219+
"""openjd-expr 0.11.0 (openjd-rs#424, openjd-specifications#192): a URI scheme has
220+
at least two characters, so ``C://`` is a Windows drive with a doubled separator,
221+
not a URI with scheme ``c``. Before, it kept its ``//`` like ``s3://``. The path
222+
format is pinned because the default follows the host.
223+
"""
224+
225+
@pytest.mark.parametrize(
226+
("expression", "posix", "windows"),
227+
[
228+
('path("C://scenes/a.ma").parent', "C:/scenes", "C:\\scenes"),
229+
('path(["C://scenes", "a.ma"])', "C:/scenes/a.ma", "C:\\scenes\\a.ma"),
230+
# Control: a two-letter scheme is still a URI under either format.
231+
('path("s3://bucket/a/b").parent', "s3://bucket/a", "s3://bucket/a"),
232+
],
233+
)
234+
def test_a_drive_letter_is_a_path_and_a_scheme_is_a_uri(
235+
self, expression: str, posix: str, windows: str
236+
) -> None:
237+
assert str(evaluate_expression(expression, path_format=PathFormat.POSIX)) == posix
238+
assert str(evaluate_expression(expression, path_format=PathFormat.WINDOWS)) == windows

0 commit comments

Comments
 (0)