Skip to content

Commit cd8fd8a

Browse files
authored
Set *print-length* default value to nil instead of 50 (#1095)
Hi, could you please review patch to set the `*print-length*` default to `nil` instead of 50. It addresses #1093. I’ve also added a docstring (feedback welcome!) and a test. Thanks --------- Co-authored-by: ikappaki <[email protected]>
1 parent f0f3be0 commit cd8fd8a

File tree

5 files changed

+27
-3
lines changed

5 files changed

+27
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
* Fix an issue where destructuring a vector would throw an exception rather than returning `nil` for invalid key types (#1090)
1414
* Fix an issue where destructuring default values would take precedence over falsey values in the source data structure (#1078)
1515
* Fixed a bug where imported Python names containing `-` (in lieu of `_`) could not be referenced using the `-` syntax (#1085)
16+
* Fixed a compatibility issue where `*print-length*` defaulted to 50 instead of `nil` (#1093)
1617

1718
### Removed
1819
* Removed support for Python 3.8 (#1083)

src/basilisp/lang/obj.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
SURPASSED_PRINT_LEVEL = "#"
2121

2222
PRINT_DUP = False
23-
PRINT_LENGTH: PrintCountSetting = 50
23+
PRINT_LENGTH: PrintCountSetting = None
2424
PRINT_LEVEL: PrintCountSetting = None
2525
PRINT_META = False
2626
PRINT_NAMESPACE_MAPS = False

src/basilisp/lang/runtime.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2460,7 +2460,19 @@ def in_ns(s: sym.Symbol):
24602460
CORE_NS_SYM, sym.symbol(PRINT_DUP_VAR_NAME), lobj.PRINT_DUP, dynamic=True
24612461
)
24622462
Var.intern(
2463-
CORE_NS_SYM, sym.symbol(PRINT_LENGTH_VAR_NAME), lobj.PRINT_LENGTH, dynamic=True
2463+
CORE_NS_SYM,
2464+
sym.symbol(PRINT_LENGTH_VAR_NAME),
2465+
lobj.PRINT_LENGTH,
2466+
dynamic=True,
2467+
meta=lmap.map(
2468+
{
2469+
_DOC_META_KEY: (
2470+
"Limits the number of items printed per collection. If falsy, all items are shown."
2471+
" If set to an integer, only that many items are printed,"
2472+
" with ``...`` indicating more. By default, it is ``nil``, meaning no limit."
2473+
)
2474+
}
2475+
),
24642476
)
24652477
Var.intern(
24662478
CORE_NS_SYM, sym.symbol(PRINT_LEVEL_VAR_NAME), lobj.PRINT_LEVEL, dynamic=True

tests/basilisp/test_core_fns.lpy

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
(:require
77
[basilisp.io :as bio]
88
[basilisp.set :as set]
9+
[basilisp.string :as str]
910
[basilisp.test :refer [deftest are is testing]]))
1011

1112
(deftest vec-test
@@ -2553,6 +2554,13 @@
25532554
(testing "is dynamic"
25542555
(is (= '(1) (binding [pr (fn [& more] more)] (pr 1)))))
25552556

2557+
(testing "*print-level* support"
2558+
(let [v-str (pr-str (range 100))]
2559+
(is (str/ends-with? v-str " 99)") v-str))
2560+
2561+
(binding [*print-length* 4]
2562+
(is (= "(0 1 2 3 ...)" (pr-str (range 5))))))
2563+
25562564
(testing "with *print-namespace-maps*"
25572565
(is (= "#py {:a/x 5}" (binding [*print-namespace-maps* false] (pr-str #py {:a/x 5}))))
25582566
(is (= "#py #:a{:x 5}" (binding [*print-namespace-maps* true] (pr-str #py {:a/x 5}))))

tox.ini

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ commands =
5959
ruff check src/
6060

6161
[testenv:safety]
62-
deps = safety
62+
deps =
63+
safety
64+
# work around 3.13 issue to avoid building an earlier version of pydantic-core on macos
65+
pydantic-core>=2.25.0
6366
commands =
6467
safety check -i 40291 -i 67599 -i 70612

0 commit comments

Comments
 (0)