Skip to content

Treat keyword arguments in calls without a semicolon as kwarg names - #184

Open
navidcy wants to merge 1 commit into
JuliaTesting:mainfrom
navidcy:kwarg-without-semicolon
Open

navidcy wants to merge 1 commit into
JuliaTesting:mainfrom
navidcy:kwarg-without-semicolon

Conversation

@navidcy

@navidcy navidcy commented Oct 16, 2026

Copy link
Copy Markdown

A keyword argument passed in a call without a semicolon at module scope, such as

module M
using Base: getindex
f(; getindex = 0) = getindex
const x = f(getindex = 1)
g() = getindex([1, 2, 3], 1)
end

was analyzed as an assignment to a global getindex. check_no_stale_explicit_imports then reported the import as stale. The same call written as f(; getindex = 1), or placed inside a function body, was fine.

is_kwarg_name recognized f(; x = 1) and named tuples, but not f(x = 1). It now does too, unless the call is a function signature with a default value (f(x = 1) = x), including one wrapped in a return type or where clause. The tests cover both cases.

We ran into this with $(MethodSignatures(defaults = true)) from DocStringExtensions v0.10 in docstrings (CliMA/Oceananigans.jl#6263).

🤖 Generated with Claude Code

A call such as `f(x = 1)` at module scope was analyzed as an assignment
to a global `x`, which made an explicit import of `x` look stale.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.16%. Comparing base (2ea249f) to head (31eb1db).
⚠️ Report is 16 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #184       +/-   ##
===========================================
+ Coverage   66.49%   95.16%   +28.67%     
===========================================
  Files          31       11       -20     
  Lines        6127     1593     -4534     
===========================================
- Hits         4074     1516     -2558     
+ Misses       2053       77     -1976     

☔ 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.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant