Skip to content

MNT: Run PTH flake test in prep for supporting pathlib (config)#16997

Merged
pllim merged 1 commit intoastropy:mainfrom
neutrinoceros:config/rfc/pth_checks
Sep 20, 2024
Merged

MNT: Run PTH flake test in prep for supporting pathlib (config)#16997
pllim merged 1 commit intoastropy:mainfrom
neutrinoceros:config/rfc/pth_checks

Conversation

@neutrinoceros
Copy link
Contributor

Description

Ref #16924
This is in the continuation of #16060

  • By checking this box, the PR author has requested that maintainers do NOT use the "Squash and Merge" button. Maintainers should respect this when possible; however, the final decision is at the discretion of the maintainer that merges the PR.

@github-actions
Copy link
Contributor

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.

  • Do the proposed changes actually accomplish desired goals?
  • Do the proposed changes follow the Astropy coding guidelines?
  • Are tests added/updated as required? If so, do they follow the Astropy testing guidelines?
  • Are docs added/updated as required? If so, do they follow the Astropy documentation guidelines?
  • Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see instructions for rebase and squash.
  • Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the "Extra CI" label. Codestyle issues can be fixed by the bot.
  • Is a change log needed? If yes, did the change log check pass? If no, add the "no-changelog-entry-needed" label. If this is a manual backport, use the "skip-changelog-checks" label unless special changelog handling is necessary.
  • Is this a big PR that makes a "What's new?" entry worthwhile and if so, is (1) a "what's new" entry included in this PR and (2) the "whatsnew-needed" label applied?
  • At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate "backport-X.Y.x" label(s) before merge.

@github-actions
Copy link
Contributor

👋 Thank you for your draft pull request! Do you know that you can use [ci skip] or [skip ci] in your commit messages to skip running continuous integration tests until you are ready?

homedir = os.path.expanduser("~")
except Exception:
return Path.home()
except RuntimeError:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the content of this except block could be dedented but that would make the diff much harder to read.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@neutrinoceros neutrinoceros marked this pull request as ready for review September 11, 2024 13:24


def _find_home():
def _find_home() -> Path:
Copy link
Member

@eerovaher eerovaher Sep 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, codecov seems useful for once and shows that none of the except block is used in any test.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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? 🤷‍♀️

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, I'll do it here to make sure it's done consistently (and avoid stacking PRs)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no good reason why changes in the private API should be mentioned in the change log at all.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xref for future case studies: astropy/halotools#1107

@pllim pllim added this to the v7.0.0 milestone Sep 11, 2024
@neutrinoceros neutrinoceros marked this pull request as draft September 12, 2024 16:45
@neutrinoceros neutrinoceros marked this pull request as ready for review September 12, 2024 16:51
@pllim pllim added Build all wheels Run all the wheel builds rather than just a selection Extra CI Run cron CI as part of PR no-changelog-entry-needed labels Sep 12, 2024


def get_config_dir(rootname="astropy"):
def get_config_dir(rootname: str = "astropy") -> str:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Followup PR to return a Path object?

Copy link
Contributor Author

@neutrinoceros neutrinoceros Sep 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 :).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dully noted. I'll circle back to this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. I'll make sure to do the follow up too !

Copy link
Contributor Author

@neutrinoceros neutrinoceros Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for posterity, this is #17188

Copy link
Member

@nstarman nstarman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also flagging for followup... maybe ConfigObj should primarily work with paths as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class lives in astropy.extern so we should probably not tinker with it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is one...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#16476 ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in the old logic, there should also be a resolve in else?

Suggested change
linkto = xchpth
linkto = xchpth.resolve()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But looks like _find_or_create_root_dir calls resolve anyway. 🤷‍♀️

@pllim pllim merged commit ee084c7 into astropy:main Sep 20, 2024
@pllim
Copy link
Member

pllim commented Sep 20, 2024

Thanks, all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Build all wheels Run all the wheel builds rather than just a selection config dev-automation Extra CI Run cron CI as part of PR no-changelog-entry-needed testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants