-
-
Notifications
You must be signed in to change notification settings - Fork 299
refactor(BaseConfig): update docstring, extract factory method and re… #1601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v4-9-2
Are you sure you want to change the base?
refactor(BaseConfig): update docstring, extract factory method and re… #1601
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v4-9-2 #1601 +/- ##
=========================================
Coverage ? 98.25%
=========================================
Files ? 59
Lines ? 2690
Branches ? 0
=========================================
Hits ? 2643
Misses ? 47
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
commitizen/config/json_config.py
Outdated
|
||
|
||
class JsonConfig(BaseConfig): | ||
def __init__(self, *, data: bytes | str, path: Path | str) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove the str
of the parameter path
in the future? I'm not sure if that will be a breaking change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine to remove the str
, at most, it would generate a mypy
error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed | str
bf6fef4
to
94b34ee
Compare
def __init__(self) -> None: | ||
self.is_empty_config = False | ||
self._settings: Settings = DEFAULT_SETTINGS.copy() | ||
self.encoding = self.settings["encoding"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why this member variable exists. It will be stale if self._settings
is updated somewhere.
from typing import Self | ||
|
||
|
||
class BaseConfig: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be an abstract class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, a Protocol
, but it doesn't hurt like this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I found it odd that we can create BaseConfig
objects and it's sometimes confusing. I attempted to refactor it on another branch (not published yet) but many tests would be affected.
94b34ee
to
61a1f85
Compare
61a1f85
to
ae0b73e
Compare
44419b9
to
02d15ef
Compare
…move unnecessary variable assignment
02d15ef
to
341e1c6
Compare
…move unnecessary variable assignment
Description
Checklist
Code Changes
poetry all
locally to ensure this change passes linter check and testsDocumentation Changes
poetry doc
locally to ensure the documentation pages renders correctlyExpected Behavior
Steps to Test This Pull Request
Additional Context