Skip to content

Collect CLI arguments into a dataclass#1732

Open
rolandwalker wants to merge 1 commit intomainfrom
RW/collect-cli-args-into-dataclass
Open

Collect CLI arguments into a dataclass#1732
rolandwalker wants to merge 1 commit intomainfrom
RW/collect-cli-args-into-dataclass

Conversation

@rolandwalker
Copy link
Contributor

Description

Using library clickdc, collect CLI arguments into a cli_args dataclass.

A small amount of reordering was done, which affects the output of the helpdoc, but the intention is for this to introduce no other functional changes.

The properties in cli_args are sometimes mutated, for example when reading comparable values from a DSN. But mutating the properties is debatable.

New tests are introduced for the crucial user/host/port/socket coordinates, but we stop short of adding new tests for every single CLI argument.

Motivations

  • clarity
  • click_entrypoint() had too many positional arguments
  • adding an CLI argument required adding both a decorator and a matching positional argument to click_entrypoint()
  • this work can be a step toward breaking up massive main.py and test_main.py

Another related step would be gathering disparate runtime settings into a self.settings property.

Checklist

  • I added this contribution to the changelog.md file.
  • I added my name to the AUTHORS file (or it's already there).
  • To lint and format the code, I ran
    uv run ruff check && uv run ruff format && uv run mypy --install-types .

@rolandwalker rolandwalker self-assigned this Mar 21, 2026
@github-actions
Copy link

No correctness or security regressions stood out in the PR’s code changes.

  1. Low: missing precedence regression tests for clickdc migration
  • After moving CLI parsing into CliArgs, envvar-backed options now depend on clickdc behavior for precedence (--option vs envvar).
  • Current added tests validate “CLI only” and “envvar only”, but not “both set at once”.
  • Add explicit cases to ensure CLI values override envvars for user/host/port/socket.
  • Relevant code: main.py, main.py
  • Existing tests to extend: test_main.py, test_main.py, test_main.py, test_main.py

I couldn’t execute the test suite locally in this environment because pytest is not installed.

Using library "clickdc", collect CLI arguments into a "cli_args"
dataclass.

A small amount of reordering was done, which affects the output of the
helpdoc, but the intention is for this to introduce no other functional
changes.

The properties in "cli_args" are sometimes mutated, for example when
reading comparable values from a DSN.  But mutating the properties is
debatable.

New tests are introduced for the crucial user/host/port/socket
coordinates, but we stop short of adding new tests for every single
CLI argument.

Motivations

 * clarity
 * click_entrypoint() had too many positional arguments
 * adding an CLI argument required adding both a decorator and a
   matching positional argument to click_entrypoint()
 * this work can be a step toward breaking up massive main.py and
   test_main.py

Another related step would be gathering disparate runtime settings into
a self.settings property.
@rolandwalker rolandwalker force-pushed the RW/collect-cli-args-into-dataclass branch from b0b5938 to df2ed72 Compare March 21, 2026 19:11
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