From f3ae475bda30f26a2a4998ea0140b76edb7598af Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Thu, 12 Nov 2026 07:31:41 -0600 Subject: [PATCH] fix general use std vs use std/ issues --- benchmarks/fibonacci-recursive.nu | 4 +-- benchmarks/fibonacci.nu | 4 +-- benchmarks/random-bytes.nu | 2 +- modules/fun/star.nu | 2 +- modules/maths/math_functions.nu | 8 ++--- modules/prompt/full-line.nu | 7 ++-- sourced/progress_bar/bar.nu | 5 +-- sourced/typeof.nu | 34 ++++++++----------- .../stdlib-candidate-older/std-rfc/mod.nu | 2 -- .../stdlib-candidate-older/std-rfc/set-env.nu | 2 +- .../stdlib-candidate-older/tests/bench.nu | 2 +- .../tests/bulk-rename.nu | 2 +- .../stdlib-candidate-older/tests/math.nu | 2 +- .../stdlib-candidate-older/tests/record.nu | 2 +- .../tests/script-parsing.nu | 2 +- .../tests/str_dedent.nu | 2 +- .../stdlib-candidate-older/tests/str_xpend.nu | 2 +- stdlib-candidate-archive/tests/conversions.nu | 2 +- 18 files changed, 42 insertions(+), 44 deletions(-) diff --git a/benchmarks/fibonacci-recursive.nu b/benchmarks/fibonacci-recursive.nu index 79109640a..03b2aeb45 100644 --- a/benchmarks/fibonacci-recursive.nu +++ b/benchmarks/fibonacci-recursive.nu @@ -2,7 +2,7 @@ # This is a much less efficient, recursive version of fibonacci that can be used to test our # command call performance. -use std bench +use std/bench def fib [n: int] { match $n { @@ -13,5 +13,5 @@ def fib [n: int] { } def main [] { - print (bench { 0..20 | each { |n| fib $n } } | reject times) + print (bench { 0..20 | each { |n| fib $n } }) } diff --git a/benchmarks/fibonacci.nu b/benchmarks/fibonacci.nu index 501286745..d8968a915 100644 --- a/benchmarks/fibonacci.nu +++ b/benchmarks/fibonacci.nu @@ -6,7 +6,7 @@ # Originally added by @devyn to show what absolute best case performance for IR evaluation can look # like. Not super representative of normal Nushell code. -use std bench +use std/bench def fib [n: int] { mut a = 0 @@ -20,5 +20,5 @@ def fib [n: int] { } def main [] { - print (bench -n 1000 { 0..50 | each { |n| fib $n } } | reject times) + print (bench -n 1000 { 0..50 | each { |n| fib $n } }) } diff --git a/benchmarks/random-bytes.nu b/benchmarks/random-bytes.nu index 020a42c7a..06b545d0d 100644 --- a/benchmarks/random-bytes.nu +++ b/benchmarks/random-bytes.nu @@ -1,4 +1,4 @@ -use std bench +use std/bench def "random bytes" [n: int]: nothing -> binary { seq 1 ($n / 8 + 1) diff --git a/modules/fun/star.nu b/modules/fun/star.nu index 526b69d68..a3feb8ab6 100644 --- a/modules/fun/star.nu +++ b/modules/fun/star.nu @@ -80,7 +80,7 @@ # } -use std math +use std/math def atan2 [y x] { if $x > 0 { diff --git a/modules/maths/math_functions.nu b/modules/maths/math_functions.nu index 381e43171..8df8af047 100644 --- a/modules/maths/math_functions.nu +++ b/modules/maths/math_functions.nu @@ -191,8 +191,8 @@ export def scale-minmax-table [a, b,input?] { # ``` export def "cartesian product" [ ...iters: list # the iterables you want the cartesian product of -]: nothing -> list> { - def aux [a: list>]: nothing -> list> { +]: nothing -> list { + def aux [a: list>]: nothing -> list { if ($a | is-empty) { return [] } @@ -215,7 +215,7 @@ export def "cartesian product" [ #[test] def cartesian_product [] { - use std assert + use std/assert # emptiness assert equal (cartesian product [] []) [] @@ -277,7 +277,7 @@ export def ways-to-add-up-to [n: int]: [ nothing -> list> ] { #[test] def test [] { - use std assert + use std/assert for it in [ [n, expected]; diff --git a/modules/prompt/full-line.nu b/modules/prompt/full-line.nu index bf148a14e..47331de6e 100644 --- a/modules/prompt/full-line.nu +++ b/modules/prompt/full-line.nu @@ -20,8 +20,11 @@ # # credit panache-git for the git status widget. -use std dirs -use std assert +use std/dirs +use std/assert + +# set up `$env.DIRS_LIST` for whoever imports this module, since `dirs` reads it +export-env { use std/dirs [] } # build the prompt from segments, looks like: # diff --git a/sourced/progress_bar/bar.nu b/sourced/progress_bar/bar.nu index 8652775ee..0430f53ec 100644 --- a/sourced/progress_bar/bar.nu +++ b/sourced/progress_bar/bar.nu @@ -11,13 +11,14 @@ def 'bar' [ --width (-w): int = 5 ] { let blocks = [null "▏" "▎" "▍" "▌" "▋" "▊" "▉" "█"] - let $whole_part = (($blocks | last) * ($percentage * $width // 1)) + let $whole_part = ("" | fill --character ($blocks | last) --width ($percentage * $width // 1 | into int)) let $fraction = ( $blocks | get ( ($percentage * $width) mod 1 | $in * ($blocks | length | $in - 1) | math round + | into int ) ) @@ -36,7 +37,7 @@ def 'bar' [ } } -use std assert equal +use std/assert equal #[test] def bar_tests [] { diff --git a/sourced/typeof.nu b/sourced/typeof.nu index 7489247f5..91f49617a 100644 --- a/sourced/typeof.nu +++ b/sourced/typeof.nu @@ -28,7 +28,7 @@ def typeof [] { #[test] def simple_type [] { - use std assert + use std/assert assert equal ("foo" | typeof) "string" assert equal (123 | typeof) "int" @@ -37,23 +37,23 @@ def simple_type [] { #[test] def list_type [] { - use std assert + use std/assert assert equal ([1 2 3] | typeof) {type: "list", items: "int"} assert equal (["foo" "bar" "baz"] | typeof) {type: "list", items: "string"} - assert equal (["foo" 2 true] | typeof) {type: "list", items: "any"} + assert equal (["foo" 2 true] | typeof) {type: "list", items: "oneof"} } #[test] def table_type [] { - use std assert + use std/assert assert equal (ls | typeof) { type: "table", columns: { name: "string", type: "string", size: "filesize", - modified: "date", + modified: "datetime", } } } @@ -61,32 +61,28 @@ def table_type [] { #[test] def record_type [] { - use std assert - assert equal ($nu | typeof) { + use std/assert + let data = { + name: "foo", + pid: 123, + os-info: {arch: "x86_64", kernel_version: "6.1"}, + startup-time: 2sec, + is-login: false, + } + assert equal ($data | typeof) { type: "record", fields: { - default-config-dir: "string", - config-path: "string", - env-path: "string", - history-path: "string", - loginshell-path: "string", - plugin-path: "string", - home-path: "string", - temp-path: "string", + name: "string", pid: "int", os-info: { type: "record", fields: { - name: "string", arch: "string", - family: "string", kernel_version: "string", } }, startup-time: "duration", - is-interactive: "bool", is-login: "bool", - current-exe: "string", } } } diff --git a/stdlib-candidate-archive/stdlib-candidate-older/std-rfc/mod.nu b/stdlib-candidate-archive/stdlib-candidate-older/std-rfc/mod.nu index 99468a5d3..346079984 100644 --- a/stdlib-candidate-archive/stdlib-candidate-older/std-rfc/mod.nu +++ b/stdlib-candidate-archive/stdlib-candidate-older/std-rfc/mod.nu @@ -8,5 +8,3 @@ export use bulk-rename.nu * export use set-env.nu * export use bench.nu export use script-parsing.nu [ parse-arg ] -export use conversions * -export use tables * diff --git a/stdlib-candidate-archive/stdlib-candidate-older/std-rfc/set-env.nu b/stdlib-candidate-archive/stdlib-candidate-older/std-rfc/set-env.nu index 0dea2c341..5d86d2387 100644 --- a/stdlib-candidate-archive/stdlib-candidate-older/std-rfc/set-env.nu +++ b/stdlib-candidate-archive/stdlib-candidate-older/std-rfc/set-env.nu @@ -18,7 +18,7 @@ export def --env main [ --append (-a) # Append to the previous value or wrap in a new list ]: nothing -> nothing { def 'get or' [default field] { - get --ignore-errors $field | default $default + get --optional $field | default $default } let value = if $append { $env | get or [] $field | append $value diff --git a/stdlib-candidate-archive/stdlib-candidate-older/tests/bench.nu b/stdlib-candidate-archive/stdlib-candidate-older/tests/bench.nu index b28910ff8..ad9db5c77 100644 --- a/stdlib-candidate-archive/stdlib-candidate-older/tests/bench.nu +++ b/stdlib-candidate-archive/stdlib-candidate-older/tests/bench.nu @@ -1,4 +1,4 @@ -use std assert +use std/assert use ../std-rfc bench export def "test bench-timings" [] { diff --git a/stdlib-candidate-archive/stdlib-candidate-older/tests/bulk-rename.nu b/stdlib-candidate-archive/stdlib-candidate-older/tests/bulk-rename.nu index e79f004b7..ce5b7f462 100644 --- a/stdlib-candidate-archive/stdlib-candidate-older/tests/bulk-rename.nu +++ b/stdlib-candidate-archive/stdlib-candidate-older/tests/bulk-rename.nu @@ -1,4 +1,4 @@ -use std assert +use std/assert use ../std-rfc 'bulk-rename' const fixture = [ diff --git a/stdlib-candidate-archive/stdlib-candidate-older/tests/math.nu b/stdlib-candidate-archive/stdlib-candidate-older/tests/math.nu index cafe00db5..03af9df73 100644 --- a/stdlib-candidate-archive/stdlib-candidate-older/tests/math.nu +++ b/stdlib-candidate-archive/stdlib-candidate-older/tests/math.nu @@ -1,4 +1,4 @@ -use std assert +use std/assert use ../std-rfc/math #[test] diff --git a/stdlib-candidate-archive/stdlib-candidate-older/tests/record.nu b/stdlib-candidate-archive/stdlib-candidate-older/tests/record.nu index f297076e6..f4e3fe9b0 100644 --- a/stdlib-candidate-archive/stdlib-candidate-older/tests/record.nu +++ b/stdlib-candidate-archive/stdlib-candidate-older/tests/record.nu @@ -1,4 +1,4 @@ -use std assert +use std/assert use ../std-rfc record export def "test list_merge" [] { diff --git a/stdlib-candidate-archive/stdlib-candidate-older/tests/script-parsing.nu b/stdlib-candidate-archive/stdlib-candidate-older/tests/script-parsing.nu index e43e176fa..6025f4974 100644 --- a/stdlib-candidate-archive/stdlib-candidate-older/tests/script-parsing.nu +++ b/stdlib-candidate-archive/stdlib-candidate-older/tests/script-parsing.nu @@ -1,4 +1,4 @@ -use std assert +use std/assert use ../std-rfc parse-arg const SPAN = { start: 0, end: 0 } diff --git a/stdlib-candidate-archive/stdlib-candidate-older/tests/str_dedent.nu b/stdlib-candidate-archive/stdlib-candidate-older/tests/str_dedent.nu index 7fedd347c..87bb527de 100644 --- a/stdlib-candidate-archive/stdlib-candidate-older/tests/str_dedent.nu +++ b/stdlib-candidate-archive/stdlib-candidate-older/tests/str_dedent.nu @@ -1,4 +1,4 @@ -use std assert +use std/assert use ../std-rfc str export def "test str dedent" [] { diff --git a/stdlib-candidate-archive/stdlib-candidate-older/tests/str_xpend.nu b/stdlib-candidate-archive/stdlib-candidate-older/tests/str_xpend.nu index 0c8398861..9219fa828 100644 --- a/stdlib-candidate-archive/stdlib-candidate-older/tests/str_xpend.nu +++ b/stdlib-candidate-archive/stdlib-candidate-older/tests/str_xpend.nu @@ -1,4 +1,4 @@ -use std assert +use std/assert use ../std-rfc str export def "test append" [] { diff --git a/stdlib-candidate-archive/tests/conversions.nu b/stdlib-candidate-archive/tests/conversions.nu index 04124f4fd..db473f985 100644 --- a/stdlib-candidate-archive/tests/conversions.nu +++ b/stdlib-candidate-archive/tests/conversions.nu @@ -1,4 +1,4 @@ -use std assert +use std/assert use ../std-rfc/conversions * #[test]