Skip to content

Make Subroutine.argnames return lower-case names#686

Open
Claude wants to merge 5 commits into
mainfrom
claude/make-subroutine-argnames-lower-case
Open

Make Subroutine.argnames return lower-case names#686
Claude wants to merge 5 commits into
mainfrom
claude/make-subroutine-argnames-lower-case

Conversation

@Claude
Copy link
Copy Markdown

@Claude Claude AI commented May 19, 2026

Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.


This section details on the original issue you should resolve

<issue_title>Make Subroutine.argnames return lower-case names</issue_title>
<issue_description>To avoid patterns like this, and because Fortran is case-insensitive by default, we should make Subroutine.argnames return lower-case arg names .

    routine_arg_names = [arg.lower() for arg in routine.argnames]

[No action] We should make the routine.argnames property lower-case by default.

Originally posted by @reuterbal in #671 (comment)
</issue_description>

<agent_instructions>Start by implementing the lower-casing in Subroutine.argnames and make sure all tests are still passing. If tests are failing, fix the implementation to make tests pass.

Subsequently, check for now unnecessary lower-casing in places that use Subroutine.argnames and clean-up these uses.</agent_instructions>

Comments on the Issue (you are @claude[agent] in this section)

Comment thread loki/subroutine.py Outdated
the expansion is performed.
"""
trafo_data = {'orig_argnames': tuple(arg.lower() for arg in routine.argnames)}
trafo_data = {'orig_argnames': tuple(routine.argnames)}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@claude[agent] The tuple conversion is redundant here.

Suggested change
trafo_data = {'orig_argnames': tuple(routine.argnames)}
trafo_data = {'orig_argnames': routine.argnames}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Removed the redundant tuple conversion in commit 39cdc34 since routine.argnames now returns a tuple directly.

@github-actions
Copy link
Copy Markdown

Documentation for this branch can be viewed at https://sites.ecmwf.int/docs/loki/686/index.html

@reuterbal reuterbal marked this pull request as ready for review May 19, 2026 19:59
@reuterbal reuterbal marked this pull request as draft May 19, 2026 22:18
@Claude Claude AI requested a review from reuterbal May 19, 2026 22:42
@codecov
Copy link
Copy Markdown

codecov Bot commented May 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.20%. Comparing base (03c986f) to head (0f46e15).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #686   +/-   ##
=======================================
  Coverage   94.20%   94.20%           
=======================================
  Files         288      288           
  Lines       47546    47546           
=======================================
  Hits        44790    44790           
  Misses       2756     2756           
Flag Coverage Δ
lint_rules 96.40% <ø> (ø)
loki 94.17% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

Claude AI and others added 5 commits June 1, 2026 09:30
…ary .lower() calls

Agent-Logs-Url: https://github.com/ecmwf-ifs/loki/sessions/6087abd5-a0f2-4dbf-8f83-d7398e3be1bc

Co-authored-by: reuterbal <6384870+reuterbal@users.noreply.github.com>
Agent-Logs-Url: https://github.com/ecmwf-ifs/loki/sessions/38a114b5-1210-49c0-b5ba-cdbf898c5eaf

Co-authored-by: reuterbal <6384870+reuterbal@users.noreply.github.com>
While argnames now returns lowercase for case-insensitive comparisons,
code generation and transpilation need to preserve original case. This
commit fixes those instances by using [arg.name for arg in routine.arguments]
instead of routine.argnames.

Changes:
- fgen.py: Preserve case in function/subroutine headers
- fortran_iso_c_wrapper.py: Preserve case in ISO C wrapper generation
- subroutine.py: Preserve case in clone method
- test_regex_frontend.py: Fix argnames comparisons from [] to ()

Co-authored-by: reuterbal <6384870+reuterbal@users.noreply.github.com>
@reuterbal reuterbal force-pushed the claude/make-subroutine-argnames-lower-case branch from 7106f56 to 0f46e15 Compare June 1, 2026 07:30
@reuterbal reuterbal marked this pull request as ready for review June 1, 2026 07:30
@reuterbal
Copy link
Copy Markdown
Collaborator

OK, this should be ready for a look @mlange05.

It was meant as a small maintenance task after noticing that argnames was case-sensitive, but it turned out to require more modifications than anticipated because particularly case-sensitive transformation paths (e.g., C transpilation) used that property.

So, the question is whether we want to have the property lower-case, like most other things, and accept that we have to be more explicit and case-aware in the case-sensitive code regions (using [arg.name for arg in routine.arguments] or similar.
Or if we retain current behaviour and use explicit lower-casing in those instances where we don't want to be case-sensitive (e.g., [arg_name.lower() for arg_name in routine.argnames])

@reuterbal reuterbal changed the title [WIP] Make Subroutine.argnames return lower-case names Make Subroutine.argnames return lower-case names Jun 1, 2026
Copy link
Copy Markdown
Collaborator

@mlange05 mlange05 left a comment

Choose a reason for hiding this comment

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

Ok, as discussed offline, this API change has a few pro and few con uses. As the number of "pros" seem to outweigh the "con" uses, I think we should accept this.

I'd like the docstring of the property to make this change explicit - and we might want to bundle with with the other impending API-breaking change. But otherwise GTG from me.

Comment thread loki/subroutine.py
@@ -323,7 +323,7 @@ def argnames(self):
"""
Return names of arguments in order of the defined signature (dummy list)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could we update the docstring here please to make the shift in API explicit?

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.

Make Subroutine.argnames return lower-case names

3 participants