Skip to content

Warn for unknown render keyword arguments - #380

Open
gpeairs wants to merge 1 commit into
mainfrom
gp/render-kwargs
Open

gpeairs wants to merge 1 commit into
mainfrom
gp/render-kwargs

Conversation

@gpeairs

@gpeairs gpeairs commented Nov 13, 2026

Copy link
Copy Markdown
Member

Closes the 1.x part of #7.

render! accepts arbitrary keyword arguments so that options can reach to_polygons methods and OptionalStyles, but that means a typo like atoll=0.1nm or simulaton=true is silently ignored. This PR makes the top-level render! methods warn about any keyword argument that isn't a known rendering option:

┌ Warning: `render!` does not recognize the keyword argument `atoll`, which may have no effect. Check the spelling, or register a custom rendering option with `DeviceLayout.register_render_kwarg!(:atoll)`.
  • Keywords that a render! method declares are never reported. The other known options are the ones built-in rendering reads (atol, rtol, Δθ, map_meta, and the simulation/artwork/solidmodel flags), plus the flags of every OptionalStyle constructed so far, which register themselves.
  • Custom options read some other way can be registered with DeviceLayout.register_render_kwarg!.
  • Each unknown keyword warns once per session, and once per schematic render, so it doesn't flood batch renders or schematic log files, and a second typo is still reported. Every schematic's log file gets the warning, so strict=:warn fails on it.
  • SolidModels.populate_size_fields! checks its keywords the same way, and its warning names it.

This is a warning rather than an error for now. Making unknown options an error, or replacing the keywords with an options struct, is left for 2.0 (#300). The render! → place! path for coordinate systems (#275) is unchanged.

Notes:

  • The list doesn't depend on the destination, so a built-in flag passed to a target that ignores it doesn't warn. An option for one destination passed when rendering to another (zmap when rendering to a Cell) does warn, since it has no effect there.
  • A package that constructs an OptionalStyle at top level should call register_render_kwarg! for its flag in __init__, since registrations made during precompilation aren't kept.
  • The check found a typo in our own tests: fine_mesh=true was meant to be the finemesh flag of an OptionalStyle defined in the same test, so the fine-mesh branch was never exercised. Fixed, and the assertion that accepted either mesh size now requires the fine one.

@codecov

codecov Bot commented Nov 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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