Skip to content

Fix six docstring parameter names that do not match the signature - #3641

Closed
karpovantonme wants to merge 3 commits into
astropy:mainfrom
karpovantonme:fix/docstring-param-names
Closed

karpovantonme wants to merge 3 commits into
astropy:mainfrom
karpovantonme:fix/docstring-param-names

Conversation

@karpovantonme

Copy link
Copy Markdown

Problem

Six docstrings name a parameter the function does not take, so the real one goes undocumented and the documented one cannot be passed.

Module Documented Actual signature
ipac/irsa raidus def query_ssa(self, *, pos=None, radius=None, ...)
mast val def parse_numeric_product_filter(vals)
ipac/irsa/irsa_dust xmlTree def find_result_node(desc, xml_tree)
cadc certificate def login(self, *, user=None, password=None, certificate_file=None)
ipac/ned format def _extract_image_urls(self, html_in, *, file_format='fits')
vizier coordinate_system def query_object_async(self, object_name, *, catalog=None, radius=None, coordinate_frame=None, ...)

The ipac/irsa one is a plain typo, raidus. The others are renames the docstrings did not follow.

One note on how it was applied: in ipac/ned/core.py the string format : str, optional occurs three times in the file, and only the one at line 506 is wrong. That change was made by line number, not by search and replace, so the two correct ones are untouched.

Change

Renamed the six in the docstrings to match. No code touched.

Checks

ruff check on the changed files - clean.

Found with a script that pulls every numpydoc Parameters name out of a docstring and compares it against the identifiers in the signature below it. All six were read by hand before touching.

21 more, left alone on purpose

The same sweep flags 21 further cases in astroquery, but they are a different kind: the documented parameter does not correspond to any argument at all. Mostly verbose, plus get_query_payload, output_file, product_level, retrieval_type and others. Those read like parameters that were removed while the docstring stayed, and deciding between "drop the doc" and "restore the parameter" needs someone who knows the intent.

Given that there are a lot of open PRs here, I kept this one to the unambiguous renames. Happy to send the rest in a follow-up, split per module, if that is useful. A few examples so you can judge:

  • mocserver/core.py:318 query_async documents verbose, signature is (self, region, criteria, return_moc, max_norder, ...)
  • cadc/core.py:622 create_async documents output_file, signature is (self, query, maxrec, uploads, ...)
  • esa/iso/core.py:146 get_postcard_link documents product_level and retrieval_type, signature is (self, tdt, filename, verbose)
  • simbad/core.py:1283 list_tables documents get_adql, signature is (self, get_query_payload)

Changelog

I did not add a CHANGES.rst entry, since nothing user-facing changes in behaviour. Say the word and I will add one.

@codecov

codecov Bot commented Aug 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.42%. Comparing base (de02e4d) to head (b12777c).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3641   +/-   ##
=======================================
  Coverage   73.42%   73.42%           
=======================================
  Files         230      230           
  Lines       21354    21354           
=======================================
  Hits        15679    15679           
  Misses       5675     5675           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ManonMarchand

ManonMarchand commented Aug 4, 2026 •

Copy link
Copy Markdown
Member

Disclaimer, I only maintain the submodules simbad, vizier, and mocserver touched by this PR so my comments are only for these:

  • vizier: good with the change, thank you
  • simbad: you can go ahead and document get_query_payload the docstring should match the other occurrences of get_query_payload. get_adql can be safely removed (was only there between two PRs and never released).
  • mocserver: verbose can be removed safely, it's a bad copy paste of doctrings and never was an argument

Your script is very useful. Do you intend on publishing it somewhere?

@karpovantonme

Copy link
Copy Markdown
Author

Thank you, all three are in the last commit.

  • simbad: removed the get_adql blocks from list_tables and list_columns. get_query_payload was already documented in both, with the same wording as the other occurrences, so I left that as it was. The @deprecated_renamed_argument decorators are still there, since removing those changes behaviour rather than docs. Say the word if you want them gone too.
  • mocserver: removed verbose from query_async. The other four verbose entries in that file belong to functions that really take the argument, so they are untouched.
  • vizier: thanks.

Tests: 92 passed, 46 skipped across simbad and mocserver.

On the script: yes, I am planning to. It pulls every numpydoc Parameters name out of a docstring and compares it against the identifiers in the signature below it, and it has found this same class of drift in a dozen projects by now. There is a sibling for Doxygen \param and \tparam in C++ headers.

I want to clean both up before handing them to anyone, mostly because the parsers have known blind spots and I would rather ship them with those written down than have someone trust a wrong count. I will link it here once it is up.

karpovantonme and others added 3 commits August 4, 2026 10:33
- ipac/irsa: query_ssa documents raidus, the argument is radius
- mast: parse_numeric_product_filter documents val, the argument is vals
- ipac/irsa/irsa_dust: find_result_node documents xmlTree, it is xml_tree
- cadc: login documents certificate, the argument is certificate_file
- ipac/ned: _extract_image_urls documents format, it is file_format
- vizier: query_object_async documents coordinate_system, it is
  coordinate_frame

Docstrings only. In ipac/ned the string 'format : str, optional' appears
three times in the file, so that one was changed by line, not by name.
Per maintainer review:
- simbad: get_adql in list_tables and list_columns. get_query_payload is
  already documented there with the same wording as everywhere else.
- mocserver: verbose in query_async, which had no description at all.

The other four verbose entries in mocserver/core.py belong to functions
that really take the argument and are untouched.
@keflavich
keflavich force-pushed the fix/docstring-param-names branch from ad7a1f3 to b12777c Compare August 4, 2026 16:34

@keflavich keflavich left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are minor, easy fixes, so fine to merge.

I also ran an ai-gen script locally and found more, so I added to this PR.

I've reviewed each individual change by hand. They're all correct.

@karpovantonme

Copy link
Copy Markdown
Author

It is up: https://github.com/karpovantonme/driftkit

It grew a bit past the one script you saw :))
Sixteen tools in the end, all the same shape: two statements about one thing, in two places, nobody comparing them. The docstring one is docdrift, and next to it there are checks for Doxygen in C++, protobuf against OpenAPI, a vendored copy against the upstream that has since been fixed, translations against the original, declared Python support against the CI matrix that actually runs, and dead external links.

The part I would point you at first is FALSE-POSITIVES.md. Sixty-one worked cases where the tool was wrong, each with the number of false findings it produced before it was fixed. Some of them are embarrassing: one invented rule cost 14 022 false hits, and a @property handling bug accounted for 41 of 44 findings on networkx. It sits up front rather than in an appendix, because for this kind of tool the list of mistakes already worked out of it is the product. Accuracy is accumulated reading, not an algorithm.

One of those rules is relevant to your code, by the way. Case 7 in the journal: a compatibility decorator keeps accepting the old name, the docstring documents both, and the signature knows nothing about it, so a scanner reading only the signature calls a live name non-existent. That was thirty false findings out of fifty six on statsmodels, and @deprecated_renamed_argument in simbad is the same shape. The tool now reads names out of those decorators, and when a decorator does not spell its names out it refuses to judge that function at all and says how many it skipped.

If it turns out useful, a star would genuinely help, it is a day-old repository and the first few decide whether anyone ever finds it. Comments and issues even more so: if it lies on your code, a file and a line is the most useful thing you can send, and that is how every rule in that journal got written. And if you know someone this would save time for, passing it along would mean a lot. Thanks

@keflavich

Copy link
Copy Markdown
Contributor

I'm closing this as ai-generated without attribution. The changes are correct but given the duplicate pr that just came out, I want to aggressively discourage ai prs without proper attribution.

@keflavich keflavich closed this Aug 5, 2026
@ManonMarchand

ManonMarchand commented Aug 5, 2026 •

Copy link
Copy Markdown
Member

Is it though? It looks like the other person used the same script (they opened an issue in driftkit mentioned above)
I don't know. The scripts are real and seem to work, but the PRs are AI generated. It's true that it should be disclosed somewhere and the author did not do it 🤷‍♀️

@karpovantonme

Copy link
Copy Markdown
Author

Fair enough, and thanks for saying the changes are correct.

I should have disclosed the tooling. I do it in projects that ask for it, and I read the absence of a policy here as it not mattering. That was my call and I got it wrong 🤷🏽‍♂️

On the duplicate, for what it is worth: the my checker is open source, someone else ran it and landed on the same file. Nothing coordinated, just the same tool finding the same thing

So if the fixes are still worth having, say the word and I will reopen with the tooling stated up front. If not, no hard feelings

@keflavich

Copy link
Copy Markdown
Contributor

We are still working out our formal AI policy. astroquery is part of the astropy org and has a policy here: https://github.com/astropy/astropy-project/blob/main/policies/ai-policy.md and we're expanding it here: astropy/astropy-project#538 so the full policy hasn't landed yet.

@pllim

pllim commented Aug 6, 2026

Copy link
Copy Markdown
Member

I cannot tell if there is even a human on the other end for this account. No point if just the bot running wild.

@bsipocz

bsipocz commented Aug 6, 2026 •

Copy link
Copy Markdown
Member

@pllim - I can tell, there isn't, certainly not a human who has any interest in using any/most of these multiple dozens of libraries the account opened PRs for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants