-
-
Notifications
You must be signed in to change notification settings - Fork 281
refactor(BaseConfig): update function name, upgrade mypy version #1444
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: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,19 @@ def settings(self) -> Settings: | |
def path(self) -> Path | None: | ||
return self._path | ||
|
||
""" | ||
mypy does not like the following until 1.16 | ||
See https://github.com/python/mypy/pull/18510 | ||
TODO: update this when 1.16 is available | ||
|
||
@path.setter | ||
def path(self, path: str | Path) -> None: | ||
self._path = Path(path) | ||
""" | ||
|
||
def update_path(self, path: str | Path) -> None: | ||
self._path = Path(path) | ||
|
||
def set_key(self, key, value): | ||
"""Set or update a key in the conf. | ||
|
||
|
@@ -30,8 +43,5 @@ def set_key(self, key, value): | |
def update(self, data: Settings) -> None: | ||
self._settings.update(data) | ||
|
||
def add_path(self, path: str | Path) -> None: | ||
self._path = Path(path) | ||
|
||
Comment on lines
-33
to
-35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just found this method name confusing. It's actually updating the path, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the main reason we make it this way is that we want to handle both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK I was trying the following @property
def path(self) -> Path | None:
return self._path
@path.setter
def path(self, path: str | Path) -> None:
self._path = Path(path) but mypy isn't happy
I'm taking a look at related issues and PRs. Updating mypy to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like python/mypy#18510 will be part of 1.16. |
||
def _parse_setting(self, data: bytes | str) -> None: | ||
raise NotImplementedError() |
Large diffs are not rendered by default.
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.
Or maybe let's use
setter
here with type ignore and update it after 1.16. WDYT?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.
sounds good