Repository navigation
Rewrite configuration to use Pydantic. Make error messages more user-friendly. Allow retrying inputs in the wizard. Improve configuration documentation. - #50
Merged
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors configuration handling to use Pydantic models for validation and normalization, updates the interactive wizard to reprompt on invalid values, and refreshes configuration documentation and examples to match the new schema.
Changes:
- Introduces Pydantic-based config models with validation, case-insensitive keys, and improved error formatting.
- Updates the configuration wizard to validate inputs and reprompt only invalid fields, and writes config via
yaml.safe_dump. - Adds tests covering hostname validation, secret redaction in validation errors, and wizard reprompt behavior; updates README/config examples and dependency list.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_wizard.py | Adds a regression test to ensure wizard validation errors are shown and only invalid fields are reprompted. |
| tests/test_config.py | Adds tests for hostname validation and ensuring validation errors do not leak rejected secret values. |
| src/jira_backup/_wizard.py | Reworks wizard flow to validate with Pydantic and reprompt invalid fields; writes config safely. |
| src/jira_backup/_config.py | Replaces TypedDict config with Pydantic models, validation, case-insensitive key normalization, and formatted errors. |
| src/jira_backup/_backup.py | Updates runtime config usage from dict access to typed model fields; adds --config and friendlier config-load failure handling. |
| README.md | Updates configuration documentation and examples for the new schema and --config option. |
| pyproject.toml | Adds Pydantic v2 dependency. |
| config.yaml | Removes tracked config file (previously contained guidance inline). |
| config.example.yaml | Adds a new example config matching the Pydantic schema. |
| .gitignore | Ignores config.yaml to reduce the chance of committing secrets. |
Comments suppressed due to low confidence (1)
src/jira_backup/_wizard.py:85
- input_boolean() currently treats any unrecognized input as False (because parse_boolean() only recognizes truthy values). This can silently misconfigure booleans when a user mistypes; it should reprompt until the user answers y/n (or equivalent).
def parse_boolean(s: str) -> bool:
return s.lower() in ("yes", "true", "t", "1", "y")
def input_boolean(q: str) -> bool:
return parse_boolean(input(f"{q} (y/n) "))
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR makes configuration cleaner, safer and more understandable.
It also prevents the wizard from crashing when you make typos.
This is technically a breaking change, but since this repo is currently broken anyway, and it's not being released under any kind of semantic versioning, I think it's fine, and a step in the right direction.