Skip to content

Commit 4fa48b3

Browse files
authored
🐛 fix some parser issues with type signatures (#1001)
When I updated nu to 101, the completions of poetry failed because of a missing `:` this ```nu def "nu-complete poetry python-versions" [] nothing -> list<string> { ``` for this ```nu def "nu-complete poetry python-versions" []: nothing -> list<string> { ``` Fixed a couple of places and some other parser issues
1 parent 43d1224 commit 4fa48b3

File tree

5 files changed

+45
-41
lines changed

5 files changed

+45
-41
lines changed

custom-completions/auto-generate/parse-fish.nu

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def pair-args [] {
6060
{$"($pair.0 | str trim -c '-')": ($pair.1 | unquote)} # turn into a [{<flag> :<arg>}] removing quotes
6161
]
6262
}
63-
| reduce { |it, acc| $acc | merge { $it }} # merge the list of records into one big record
63+
| reduce { |it, acc| $acc | merge $it } # merge the list of records into one big record
6464
}
6565

6666
def unquote [] {
@@ -84,11 +84,10 @@ def make-commands-completion [] {
8484
}
8585
}
8686

87-
let quote = '"' # "
88-
8987
# make the action nu completion string from subcommand and args
9088
# subcommand can be empty which will be the root command
9189
def make-subcommands-completion [parents: list] {
90+
let quote = '"' # "
9291
let fishes = $in
9392
$fishes
9493
| group-by a # group by sub command (a flag)

custom-completions/op/op-completions.nu

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export extern "op account forget" [
109109
--help(-h) # help for forget
110110
--all # Forget all authenticated accounts.
111111

112-
account?: string: string@"nu completion account" # The account to forget.
112+
account?: string@"nu completion account" # The account to forget.
113113
]
114114

115115
# Manage Connect server instances and tokens in your 1Password account
@@ -2124,7 +2124,7 @@ def "nu completion item" [] {
21242124

21252125
def parse_args_rg [] { "(?<opening_quote>['\"`]?)(?<content>.*?)(?<closing_quote>\\k<opening_quote>)(?<separator>\\s+)" }
21262126

2127-
def "nu completion parse-context" [] string -> {cmd: string, args: list<string>} {
2127+
def "nu completion parse-context" []: string -> record {
21282128
# context strings starts at cursor position
21292129
let ctx = $in + ' ' # add space to end to ensure last part is parsed🙄
21302130
mut parse = $ctx | parse --regex (parse_args_rg)
@@ -2177,7 +2177,7 @@ def "nu completion parse-context" [] string -> {cmd: string, args: list<string>}
21772177
def "nu completion output" [
21782178
ctx: string, # entered command [sub command, args, + options]
21792179
--complete (-c) # if the copletion should have a closing quote and terminating space
2180-
] list<string> -> list<string>, string -> list<string> {
2180+
]: list<string> -> list<string>, string -> list<string> {
21812181

21822182
let output = $in
21832183
let parse = $ctx + ` `

custom-completions/poetry/poetry-completions.nu

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
# Python versions
22
#
33
# Used by the add command to specify for which Python version the dependency must be installed
4-
def "nu-complete poetry python-versions" [] nothing -> list<string> {
4+
def "nu-complete poetry python-versions" []: nothing -> list<string> {
55
["3.8" "3.9" "3.10" "3.11" "3.12" "3.13"]
66
}
77

88
# Default package source names
99
#
1010
# The default package source names available to install packages from
11-
def "nu-complete poetry default-package-source-names" [] nothing -> list<string> {
11+
def "nu-complete poetry default-package-source-names" []: nothing -> list<string> {
1212
[pypi test test.pypi.org internal-pypi]
1313
}
1414

1515
# Default package source urls
1616
#
1717
# The default package source urls available to install packages from
18-
def "nu-complete poetry default-package-source-urls" [] nothing -> list<string> {
18+
def "nu-complete poetry default-package-source-urls" []: nothing -> list<string> {
1919
["https://" "https://test.pypi.org/legacy/" "https://pypi.org/legacy"]
2020
}
2121

2222
# Default package sources
2323
#
2424
# The default sources to use to install the package, beyond the ones defined within pyproject.toml available for the add command
25-
def "nu-complete poetry default-package-sources" [] nothing -> list<string> {
25+
def "nu-complete poetry default-package-sources" []: nothing -> list<string> {
2626
(nu-complete poetry default-package-source-names) | append (
2727
nu-complete poetry default-package-source-urls
2828
)
@@ -31,21 +31,21 @@ def "nu-complete poetry default-package-sources" [] nothing -> list<string> {
3131
# Build formats
3232
#
3333
# Used by the build command to limit the built package to either sdist or wheel
34-
def "nu-complete poetry build-formats" [] nothing -> list<string> {
34+
def "nu-complete poetry build-formats" []: nothing -> list<string> {
3535
[sdist wheel]
3636
}
3737

3838
# Default usernames
3939
#
4040
# The current username which is the default suggestion for logging in to services with a username
41-
def "nu-complete poetry default-usernames" [] nothing -> list<string> {
41+
def "nu-complete poetry default-usernames" []: nothing -> list<string> {
4242
[(whoami)]
4343
}
4444

4545
# Setting keys
4646
#
4747
# The available setting keys that can be retrieved/changed by the config command
48-
def "nu-complete poetry setting-keys" [] nothing -> list<string> {
48+
def "nu-complete poetry setting-keys" []: nothing -> list<string> {
4949
[
5050
cache-dir
5151
experimental.system-git-client
@@ -87,7 +87,7 @@ def "nu-complete poetry setting-keys" [] nothing -> list<string> {
8787
# Setting keys
8888
#
8989
# The possible values for the given setting key, that the config command can chenge the respective setting key to
90-
def "nu-complete poetry setting-values" [context: string] nothing -> list<any> {
90+
def "nu-complete poetry setting-values" [context: string]: nothing -> list<any> {
9191
let $final_context: string = ($context | str trim | split row " " | last)
9292

9393
if (
@@ -173,21 +173,21 @@ def "nu-complete poetry setting-values" [context: string] nothing -> list<any> {
173173
# Export formats
174174
#
175175
# The list of possible formats supported by the export command
176-
def "nu-complete poetry export-formats" [] nothing -> list<string> {
176+
def "nu-complete poetry export-formats" []: nothing -> list<string> {
177177
["requirements.txt" "constraints.txt"]
178178
}
179179

180180
# Default dependency groups
181181
#
182182
# A default selection of dependency groups
183-
def "nu-complete poetry default-dependency-groups" [] nothing -> list<string> {
183+
def "nu-complete poetry default-dependency-groups" []: nothing -> list<string> {
184184
[main dev deploy test testing tests development developing deployment deploying]
185185
}
186186

187187
# Commands
188188
#
189189
# The list of command names available to have a help message displayed using the help command
190-
def "nu-complete poetry commands" [] nothing -> list<string> {
190+
def "nu-complete poetry commands" []: nothing -> list<string> {
191191
[
192192
about
193193
add
@@ -233,35 +233,35 @@ def "nu-complete poetry commands" [] nothing -> list<string> {
233233
# Licenses
234234
#
235235
# The available license IDs for project.toml
236-
def "nu-complete poetry licenses" [] nothing -> list<string> {
236+
def "nu-complete poetry licenses" []: nothing -> list<string> {
237237
http get https://spdx.org/licenses/licenses.json | get licenses | get licenseId
238238
}
239239

240240
# ReadMe file formats
241241
#
242242
# A default selection of file extensions used for ReadMe files
243-
def "nu-complete poetry readme-file-formats" [] nothing -> list<string> {
243+
def "nu-complete poetry readme-file-formats" []: nothing -> list<string> {
244244
[md txt adoc rst rft pdf html dbk odf tex latex texi asciidoc markdown xhtml xht htm xml]
245245
}
246246

247247
# Namespaces
248248
#
249249
# The list of namespaces available to list poetry commands about
250-
def "nu-complete poetry namespaces" [] nothing -> list<string> {
250+
def "nu-complete poetry namespaces" []: nothing -> list<string> {
251251
[cache debug env self source]
252252
}
253253

254254
# Default repositories
255255
#
256256
# The default set of repositories available to publish this projects package to
257-
def "nu-complete poetry default-repositories" [] nothing -> list<string> {
257+
def "nu-complete poetry default-repositories" []: nothing -> list<string> {
258258
nu-complete poetry default-package-sources
259259
}
260260

261261
# Default dist directories
262262
#
263263
# The default set of directories where build artifacts may be stored
264-
def "nu-complete poetry default-dist-directories" [] nothing -> list<string> {
264+
def "nu-complete poetry default-dist-directories" []: nothing -> list<string> {
265265
(
266266
ls | get name | where (($it | path type) == "dir") | each {|it| $it | path expand}
267267
) | prepend ($env.PWD | path join "dist")
@@ -270,21 +270,21 @@ def "nu-complete poetry default-dist-directories" [] nothing -> list<string> {
270270
# Caches
271271
#
272272
# The list of available poetry caches, used to remove one that is listed
273-
def "nu-complete poetry caches" [] nothing -> list<string> {
273+
def "nu-complete poetry caches" []: nothing -> list<string> {
274274
poetry cache list | lines
275275
}
276276

277277
# Virtual environments
278278
#
279279
# The list of available virtual environements, used to remove one that is listed
280-
def "nu-complete poetry virtual-environments" [] nothing -> list<string> {
280+
def "nu-complete poetry virtual-environments" []: nothing -> list<string> {
281281
poetry env list --full-path | lines | each {|| (split row " ").0}
282282
}
283283

284284
# Source priorities
285285
#
286286
# Used by the source commands to set/display the priority of the source
287-
def "nu-complete poetry source-priorities" [] nothing -> list<string> {
287+
def "nu-complete poetry source-priorities" []: nothing -> list<string> {
288288
[default primary secondary supplemental explicit]
289289
}
290290

make_release/gen-js-ext.nu

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ def gen_keywords [] {
33
| where is_extern == false
44
and is_custom == false
55
and category !~ deprecated
6-
and ($it.name | str contains -n ' ')
6+
and not ($it.name | str contains ' ')
77
| get name
88
| str join '|')
99

@@ -12,10 +12,6 @@ def gen_keywords [] {
1212
let postamble = ')\\b'
1313
$'"match": "($var_with_dash_or_under_regex)|($preamble)($cmds)($postamble)",'
1414
}
15-
print $"Generating keywords(char nl)"
16-
print (gen_keywords)
17-
print (char nl)
18-
print (char nl)
1915

2016
def gen_sub_keywords [] {
2117
let sub_cmds = (scope commands
@@ -33,17 +29,14 @@ def gen_sub_keywords [] {
3329
} | str join '|')
3430
$'"match": "($preamble)($cmds)($postamble)",'
3531
}
36-
print $"Generating sub keywords(char nl)"
37-
print (gen_sub_keywords)
38-
print (char nl)
3932

4033
def gen_keywords_alphabetically [] {
4134
let alphabet = [a b c d e f g h i j k l m n o p q r s t u v w x y z]
4235
let cmds = (scope commands
4336
| where is_extern == false
4437
and is_custom == false
4538
and category !~ deprecated
46-
and ($it.name | str contains -n ' ')
39+
and not ($it.name | str contains ' ')
4740
| get name)
4841

4942
let preamble = '\\b('
@@ -64,9 +57,6 @@ def gen_keywords_alphabetically [] {
6457
} | str join "\n"
6558
}
6659

67-
print "Generating keywords alphabetically\n"
68-
print (gen_keywords_alphabetically)
69-
print (char nl)
7060

7161
def gen_sub_keywords_alphabetically [] {
7262
let alphabet = [a b c d e f g h i j k l m n o p q r s t u v w x y z]
@@ -96,6 +86,21 @@ def gen_sub_keywords_alphabetically [] {
9686
} | str join "\n"
9787
}
9888

99-
print "Generating sub keywords alphabetically\n"
100-
print (gen_sub_keywords_alphabetically)
101-
print (char nl)
89+
export def main [] {
90+
print $"Generating keywords(char nl)"
91+
print (gen_keywords)
92+
print (char nl)
93+
print (char nl)
94+
95+
print $"Generating sub keywords(char nl)"
96+
print (gen_sub_keywords)
97+
print (char nl)
98+
99+
print "Generating keywords alphabetically\n"
100+
print (gen_keywords_alphabetically)
101+
print (char nl)
102+
103+
print "Generating sub keywords alphabetically\n"
104+
print (gen_sub_keywords_alphabetically)
105+
print (char nl)
106+
}

modules/cwdhist/mod.nu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def __cwdhist_switching [] {
6464
export def empty-sqlite [] {
6565
# sqlite3 empty.db "VACUUM;"; cat empty.db | gzip | encode base64
6666
'H4sIAAAAAAAAAwsO9MksSVVIyy/KTSxRMGYQYGBkZHBQUGBgYGCEYhhAZhMLGBn0ihbwglgCZOgeBaNgFIyCUTAKRsEoGAWjYBSMglEwCkYBVQAANHgbMAAQAAA='
67-
| decode base64 --binary | gzip -d
67+
| decode base64 | gzip -d
6868
}
6969

7070
export def 'cwd history delete' [cwd] {

0 commit comments

Comments
 (0)