MNT: Run PTH flake test in prep for supporting pathlib (config)#16997
MNT: Run PTH flake test in prep for supporting pathlib (config)#16997pllim merged 1 commit intoastropy:mainfrom
Conversation
|
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
|
👋 Thank you for your draft pull request! Do you know that you can use |
astropy/config/paths.py
Outdated
| homedir = os.path.expanduser("~") | ||
| except Exception: | ||
| return Path.home() | ||
| except RuntimeError: |
There was a problem hiding this comment.
the content of this except block could be dedented but that would make the diff much harder to read.
There was a problem hiding this comment.
It is very simple to ignore lines where the only change is in the indentation level, both with Git (git diff --ignore-space-change) and in the GitHub UI.
There was a problem hiding this comment.
oh I didn't know GitHub supported that, good to know. Still, I'll only do it if requested, as I'd like these PRs to be small and quick to expedite.
879a17a to
64e6c65
Compare
astropy/config/paths.py
Outdated
|
|
||
|
|
||
| def _find_home(): | ||
| def _find_home() -> Path: |
There was a problem hiding this comment.
It's not at all obvious to me why we need this function at all. Why couldn't we just use Path.home()? The vast majority of this function is for Windows, so we need @pllim to have a look at this.
There was a problem hiding this comment.
yeah, codecov seems useful for once and shows that none of the except block is used in any test.
There was a problem hiding this comment.
Blame says this code was added at least 13 years ago (#73), so probably predated a lot of Path stuff and maybe even os.path was incomplete back then.
There was a problem hiding this comment.
I am okay with removing it but should probably be a separate PR. Unless you want to do that first and then come back to this PR? 🤷♀️
There was a problem hiding this comment.
Unless you want to do that first and then come back to this PR? 🤷♀️
It makes more sense to me. Let me open a PR now.
There was a problem hiding this comment.
Nevermind, I'll do it here to make sure it's done consistently (and avoid stacking PRs)
There was a problem hiding this comment.
Removal of legacy things like this tend to cause havoc downstream, so it would be superb to do these removals more carefully, and at least mention them in the changelog as it would save time for those who try to investigate why packages became incompatible with the latest release (specifics are not really important, but this time you broke halotools).
There was a problem hiding this comment.
There's no good reason why changes in the private API should be mentioned in the change log at all.
There was a problem hiding this comment.
xref for future case studies: astropy/halotools#1107
64e6c65 to
657c91a
Compare
|
|
||
|
|
||
| def get_config_dir(rootname="astropy"): | ||
| def get_config_dir(rootname: str = "astropy") -> str: |
There was a problem hiding this comment.
Followup PR to return a Path object?
There was a problem hiding this comment.
I depends whether this API is considered public or private: if it's private, I can do it now, and if it's public, we probably shouldn't do it at all. In doubt, I erred on the side of caution.
There was a problem hiding this comment.
It looks to be public. So followup?
I think it's a very good thing to return Path objects, not string, when dealing with paths. Backwards compatibility is very easy for downstream libraries: just call str. But probably they want Paths long term :).
There was a problem hiding this comment.
Dully noted. I'll circle back to this.
There was a problem hiding this comment.
Let's not break downstream just because ruff is complaining here...
|
|
||
|
|
||
| def get_cache_dir(rootname="astropy"): | ||
| def get_cache_dir(rootname: str = "astropy") -> str: |
There was a problem hiding this comment.
Is this function essentially the same as get_config_dir ?
Maybe a good pre or followup PR is to make a private function which these both call. Consolidate the code.
There was a problem hiding this comment.
Good call. I'll make sure to do the follow up too !
nstarman
left a comment
There was a problem hiding this comment.
LGTM. Let's get an infrastructure person to sign off on this as well.
| .joinpath(pkgname) | ||
| .with_suffix(".cfg") | ||
| ) | ||
| cobj = configobj.ConfigObj(str(cfgfn), interpolation=False) |
There was a problem hiding this comment.
Also flagging for followup... maybe ConfigObj should primarily work with paths as well.
There was a problem hiding this comment.
This class lives in astropy.extern so we should probably not tinker with it.
There was a problem hiding this comment.
The OG project is pretty much dead. So it's not like we're going to update from extern.
We really should eventually replace the whole thing, e.g. with https://traitlets.readthedocs.io/en/stable/config.html
There was a problem hiding this comment.
This seems like quite an undertaking, and I'm not sure that there would be a consensus on this as long as it's not broken. Would you like to open an issue for that ?
There was a problem hiding this comment.
I'll have a look in a day or two unless someone else beats me to it. I think @eteq might have done some of the original work but he is also very busy nowadays. 🤷♀️
| if xchpth.exists(): | ||
| return str(xchpth.resolve()) | ||
| else: | ||
| linkto = xchpth |
There was a problem hiding this comment.
I think in the old logic, there should also be a resolve in else?
| linkto = xchpth | |
| linkto = xchpth.resolve() |
There was a problem hiding this comment.
But looks like _find_or_create_root_dir calls resolve anyway. 🤷♀️
|
Thanks, all! |
Description
Ref #16924
This is in the continuation of #16060