From 6c840b03a964e8cc6903a6aaf11e5b74e9f7cd19 Mon Sep 17 00:00:00 2001 From: ikappaki Date: Mon, 28 Oct 2024 23:31:43 +0000 Subject: [PATCH 1/2] Set *print-length* default value to nil instead of 50 Also added doc string --- CHANGELOG.md | 1 + src/basilisp/lang/obj.py | 2 +- src/basilisp/lang/runtime.py | 14 +++++++++++++- tests/basilisp/test_core_fns.lpy | 8 ++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 478d21ffe..75f3d294c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Fix an issue where destructuring a vector would throw an exception rather than returning `nil` for invalid key types (#1090) * Fix an issue where destructuring default values would take precedence over falsey values in the source data structure (#1078) * Fixed a bug where imported Python names containing `-` (in lieu of `_`) could not be referenced using the `-` syntax (#1085) + * Fixed a compatibility issue where `*print-length*` defaulted to 50 instead of `nil` (#1093) ### Removed * Removed support for Python 3.8 (#1083) diff --git a/src/basilisp/lang/obj.py b/src/basilisp/lang/obj.py index 297909d4b..14972539b 100644 --- a/src/basilisp/lang/obj.py +++ b/src/basilisp/lang/obj.py @@ -20,7 +20,7 @@ SURPASSED_PRINT_LEVEL = "#" PRINT_DUP = False -PRINT_LENGTH: PrintCountSetting = 50 +PRINT_LENGTH: PrintCountSetting = None PRINT_LEVEL: PrintCountSetting = None PRINT_META = False PRINT_NAMESPACE_MAPS = False diff --git a/src/basilisp/lang/runtime.py b/src/basilisp/lang/runtime.py index d2e132835..7c9b2961c 100644 --- a/src/basilisp/lang/runtime.py +++ b/src/basilisp/lang/runtime.py @@ -2460,7 +2460,19 @@ def in_ns(s: sym.Symbol): CORE_NS_SYM, sym.symbol(PRINT_DUP_VAR_NAME), lobj.PRINT_DUP, dynamic=True ) Var.intern( - CORE_NS_SYM, sym.symbol(PRINT_LENGTH_VAR_NAME), lobj.PRINT_LENGTH, dynamic=True + CORE_NS_SYM, + sym.symbol(PRINT_LENGTH_VAR_NAME), + lobj.PRINT_LENGTH, + dynamic=True, + meta=lmap.map( + { + _DOC_META_KEY: ( + "Limits the number of items printed per collection. If falsy, all items are shown." + " If set to an integer, only that many items are printed," + " with ``...`` indicating more. By default, it is ``nil``, meaning no limit." + ) + } + ), ) Var.intern( CORE_NS_SYM, sym.symbol(PRINT_LEVEL_VAR_NAME), lobj.PRINT_LEVEL, dynamic=True diff --git a/tests/basilisp/test_core_fns.lpy b/tests/basilisp/test_core_fns.lpy index c064b6229..9f669e1e3 100644 --- a/tests/basilisp/test_core_fns.lpy +++ b/tests/basilisp/test_core_fns.lpy @@ -6,6 +6,7 @@ (:require [basilisp.io :as bio] [basilisp.set :as set] + [basilisp.string :as str] [basilisp.test :refer [deftest are is testing]])) (deftest vec-test @@ -2553,6 +2554,13 @@ (testing "is dynamic" (is (= '(1) (binding [pr (fn [& more] more)] (pr 1))))) + (testing "*print-level* support" + (let [v-str (pr-str (range 100))] + (is (str/ends-with? v-str " 99)") v-str)) + + (binding [*print-length* 4] + (is (= "(0 1 2 3 ...)" (pr-str (range 5)))))) + (testing "with *print-namespace-maps*" (is (= "#py {:a/x 5}" (binding [*print-namespace-maps* false] (pr-str #py {:a/x 5})))) (is (= "#py #:a{:x 5}" (binding [*print-namespace-maps* true] (pr-str #py {:a/x 5})))) From 701e9b1e580a403bce19ddc4ad43be1d55ec1866 Mon Sep 17 00:00:00 2001 From: ikappaki Date: Tue, 29 Oct 2024 22:30:56 +0000 Subject: [PATCH 2/2] avoid building an early version of pydantic-core for tox safety --- tox.ini | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 15b94dc65..69f5b64bd 100644 --- a/tox.ini +++ b/tox.ini @@ -59,6 +59,9 @@ commands = ruff check src/ [testenv:safety] -deps = safety +deps = + safety + # work around 3.13 issue to avoid building an earlier version of pydantic-core on macos + pydantic-core>=2.25.0 commands = safety check -i 40291 -i 67599 -i 70612 \ No newline at end of file