Skip to content

Relax tags parameter type in duplicate_inames to accept string tags#997

Merged
inducer merged 2 commits intomainfrom
copilot/improve-tags-parameter-strictness
Mar 31, 2026
Merged

Relax tags parameter type in duplicate_inames to accept string tags#997
inducer merged 2 commits intomainfrom
copilot/improve-tags-parameter-strictness

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 29, 2026

duplicate_inames required tags: Mapping[str, Tag], rejecting string shorthand values like "unr" that are accepted everywhere else in the API.

Changes

  • loopy/transform/iname.py: Change tags parameter type from Mapping[str, Tag] to Mapping[str, ToInameTagConvertible] (str | Tag | None), consistent with how split_iname, chunk_iname, and tag_inames handle tag inputs.

No runtime changes needed — tag_inames (called internally to apply the tags) already handles string→Tag conversion via parse_tag().

Example

# Previously caused a type error; now valid:
lp.duplicate_inames(knl, "i", within=None, tags={"i": "unr"})

# Still works:
lp.duplicate_inames(knl, "i", within=None, tags={"i": UnrollTag()})

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI linked an issue Mar 29, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix strict typing for tags parameter in lp.duplicate_inames Relax tags parameter type in duplicate_inames to accept string tags Mar 29, 2026
Copilot AI requested a review from inducer March 29, 2026 18:14
@inducer inducer marked this pull request as ready for review March 29, 2026 19:11
Copilot AI review requested due to automatic review settings March 29, 2026 19:11
@inducer inducer force-pushed the copilot/improve-tags-parameter-strictness branch from 54000a9 to ba3b5fd Compare March 29, 2026 19:11
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aligns duplicate_inames’s tags parameter typing with the rest of Loopy’s iname-tagging API by allowing the same shorthand tag inputs (e.g. "unr") that tag_inames already supports.

Changes:

  • Relax duplicate_inames(..., tags=...) type annotation from Mapping[str, Tag] to Mapping[str, ToInameTagConvertible] to accept string tag shorthands (and None).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@inducer inducer enabled auto-merge (squash) March 31, 2026 17:03
@inducer inducer merged commit c860947 into main Mar 31, 2026
17 checks passed
@inducer inducer deleted the copilot/improve-tags-parameter-strictness branch March 31, 2026 17:39
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.

lp.duplcate_inames type of "tags" parameter is too strict?

3 participants