Skip to content

Commit ae4b425

Browse files
committed
Fix infer arguments
1 parent fd0a603 commit ae4b425

2 files changed

Lines changed: 29 additions & 24 deletions

File tree

requirements.txt

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ backrefs==5.8
1616
# via mkdocs-material
1717
cachetools==5.5.2
1818
# via google-auth
19-
certifi==2025.4.26
19+
certifi==2025.6.15
2020
# via requests
2121
cfgv==3.4.0
2222
# via pre-commit
@@ -32,9 +32,9 @@ click==8.2.1
3232
# typer
3333
colorama==0.4.6
3434
# via mkdocs-material
35-
coverage==7.8.2
35+
coverage==7.9.1
3636
# via pytest-cov
37-
defopt==6.4.0
37+
defopt==7.0.0
3838
# via hdx-python-api (pyproject.toml)
3939
distlib==0.3.9
4040
# via virtualenv
@@ -56,7 +56,7 @@ frictionless==5.18.1
5656
# via hdx-python-utilities
5757
ghp-import==2.1.0
5858
# via mkdocs
59-
google-auth==2.40.2
59+
google-auth==2.40.3
6060
# via
6161
# google-auth-oauthlib
6262
# gspread
@@ -117,7 +117,7 @@ markdown==3.8
117117
# pymdown-extensions
118118
markdown-it-py==3.0.0
119119
# via rich
120-
marko==2.1.3
120+
marko==2.1.4
121121
# via frictionless
122122
markupsafe==3.0.2
123123
# via
@@ -166,7 +166,9 @@ platformdirs==4.3.8
166166
# mkdocs-get-deps
167167
# virtualenv
168168
pluggy==1.6.0
169-
# via pytest
169+
# via
170+
# pytest
171+
# pytest-cov
170172
ply==3.11
171173
# via
172174
# jsonpath-ng
@@ -181,26 +183,27 @@ pyasn1==0.6.1
181183
# rsa
182184
pyasn1-modules==0.4.2
183185
# via google-auth
184-
pydantic==2.11.5
186+
pydantic==2.11.7
185187
# via frictionless
186188
pydantic-core==2.33.2
187189
# via pydantic
188190
pygments==2.19.1
189191
# via
190192
# mkdocs-material
193+
# pytest
191194
# rich
192195
pymdown-extensions==10.15
193196
# via mkdocs-material
194197
pyphonetics==0.5.3
195198
# via hdx-python-utilities
196-
pytest==8.3.5
199+
pytest==8.4.0
197200
# via
198201
# hdx-python-api (pyproject.toml)
199202
# pytest-check
200203
# pytest-cov
201204
pytest-check==2.5.3
202205
# via hdx-python-api (pyproject.toml)
203-
pytest-cov==6.1.1
206+
pytest-cov==6.2.1
204207
# via hdx-python-api (pyproject.toml)
205208
python-dateutil==2.9.0.post0
206209
# via
@@ -233,7 +236,7 @@ referencing==0.36.2
233236
# via
234237
# jsonschema
235238
# jsonschema-specifications
236-
requests==2.32.3
239+
requests==2.32.4
237240
# via
238241
# hdx-python-api (pyproject.toml)
239242
# ckanapi
@@ -256,7 +259,7 @@ rpds-py==0.25.1
256259
# referencing
257260
rsa==4.9.1
258261
# via google-auth
259-
ruamel-yaml==0.18.11
262+
ruamel-yaml==0.18.14
260263
# via hdx-python-utilities
261264
ruamel-yaml-clib==0.2.12
262265
# via ruamel-yaml
@@ -276,7 +279,7 @@ six==1.17.0
276279
# sphinxcontrib-napoleon
277280
sphinxcontrib-napoleon==0.7
278281
# via defopt
279-
structlog==25.3.0
282+
structlog==25.4.0
280283
# via libhxl
281284
tableschema-to-template==0.0.13
282285
# via hdx-python-utilities
@@ -286,11 +289,11 @@ tenacity==9.1.2
286289
# via hdx-python-country
287290
text-unidecode==1.3
288291
# via python-slugify
289-
typeguard==4.4.2
292+
typeguard==4.4.3
290293
# via inflect
291294
typer==0.16.0
292295
# via frictionless
293-
typing-extensions==4.13.2
296+
typing-extensions==4.14.0
294297
# via
295298
# frictionless
296299
# pydantic
@@ -316,7 +319,7 @@ watchdog==6.0.0
316319
# via mkdocs
317320
wheel==0.45.1
318321
# via libhxl
319-
xlrd==2.0.1
322+
xlrd==2.0.2
320323
# via hdx-python-utilities
321324
xlrd3==1.1.0
322325
# via libhxl

src/hdx/facades/infer_arguments.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ def facade(projectmainfn: Callable[[Any], None], **kwargs: Any):
3737
#
3838

3939
parsed_main_doc = defopt._parse_docstring(getdoc(projectmainfn))
40-
main_doc = [f"{parsed_main_doc.first_line}\n\nArgs:"]
41-
no_main_params = len(parsed_main_doc.params)
42-
for param_name, param_info in parsed_main_doc.params.items():
43-
main_doc.append(f"\n {param_name} ({param_info.type}): {param_info.text}")
40+
main_doc = [f"{parsed_main_doc.doc}\n\nArgs:"]
41+
no_main_parameters = len(parsed_main_doc.parameters)
42+
for param_name, param_info in parsed_main_doc.parameters.items():
43+
main_doc.append(
44+
f"\n {param_name} ({param_info.annotation}): {param_info.doc}"
45+
)
4446
create_config_doc = getdoc(Configuration.create)
4547
kwargs_index = create_config_doc.index("**kwargs")
4648
kwargs_index = create_config_doc.index("\n", kwargs_index)
@@ -54,13 +56,13 @@ def facade(projectmainfn: Callable[[Any], None], **kwargs: Any):
5456
param_names.append(str(param))
5557

5658
parsed_main_doc = defopt._parse_docstring(main_doc)
57-
main_doc = [f"{parsed_main_doc.first_line}\n\nArgs:"]
59+
main_doc = [f"{parsed_main_doc.doc}Args:"]
5860
count = 0
59-
for param_name, param_info in parsed_main_doc.params.items():
60-
param_type = param_info.type
61+
for param_name, param_info in parsed_main_doc.parameters.items():
62+
param_type = param_info.annotation
6163
if param_type == "dict":
6264
continue
63-
if count < no_main_params:
65+
if count < no_main_parameters:
6466
count += 1
6567
else:
6668
if param_type == "str":
@@ -73,7 +75,7 @@ def facade(projectmainfn: Callable[[Any], None], **kwargs: Any):
7375
"Configuration.create has new parameter with unknown type!"
7476
)
7577
param_names.append(f"{param_name}: {param_type} = {default}")
76-
main_doc.append(f"\n {param_name} ({param_type}): {param_info.text}")
78+
main_doc.append(f"\n {param_name} ({param_type}): {param_info.doc}")
7779
main_doc = "".join(main_doc)
7880

7981
projectmainname = projectmainfn.__name__

0 commit comments

Comments
 (0)