Repository navigation
API: avoid creating cache directories on discovery - #19631
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.
|
|
My personal take is that if you can get this to a merge-able state in the next few hours, it might be good to get it in since #19575 is a breaking change anyway. It would be easier on users to adapt all at once rather than have to adapt again in the next release. @astrofrog , what do you think? |
|
We would also need to run Extra CI to make sure your solution work across the board (as far as we can test). |
|
On it |
df99e0c to
7ac086e
Compare
|
Running again with a more refined version and extra CI enabled |
|
|
||
| # if the file already exists, check that it has not been modified | ||
| if cfgfn is not None and cfgfn.is_file(): | ||
| if cfgfn.is_file(): |
There was a problem hiding this comment.
the is not None part was always True (cfgfn is unconditionally initialized as a Path a couple lines above) so I simplified it out while I was in there.
|
Looks stable on all platforms for which tests finished up to now. I'll undraft now. 🤞 |
| interpolation=False, | ||
| ) | ||
| cobj = configobj.ConfigObj(cfgfile, interpolation=False) | ||
| except OSError: |
There was a problem hiding this comment.
Would OSError even happen now that it does not try to create the directory?
There was a problem hiding this comment.
Good question. I'm not really sure I can test for the condition described in the accompanying inline comment though; unsetting HOME just immediately breaks pytest in my setup. Maybe I could run just this function though... but I'm out of time for today, so it'd need to be explored in a follow up PR, if that seems acceptable.
There was a problem hiding this comment.
Well, looks like it got merged, so I guess I will make follow-up issue... 😅
There was a problem hiding this comment.
Found a typo after merge. In the interest of time, I fixed it directly on main via f961612 . FYI.
Description
This resolves remaining pollution with (empty) cache and config directories being created at the user level from a test session.
Closes #19611
Note that none of the problems this solve were caused by #19575
I'm marking this as a breaking change, although I'm really unsure anyone really relies on the behavior being changed here: cache directories are still being created when they are actually needed. This branch only avoids creating them the instant paths are being discovered.
I'm opening this including a first, temporary commit, that acts as a safe guard and helped discovering where pollution happened. It is not meant to be merged, or even work on windows. But, short of changing the default of
ensure_existstoFalse, which is probably much more impactful of a breaking change, this is the best I can come up with to verify that I wiped all problems in CI.