Skip to content

ENH: integrate with pytest 9's strict mode - #111

Open
neutrinoceros wants to merge 1 commit into
astropy:mainfrom
neutrinoceros:enh/strict-flag-integration
Open

neutrinoceros wants to merge 1 commit into
astropy:mainfrom
neutrinoceros:enh/strict-flag-integration

Conversation

@neutrinoceros

Copy link
Copy Markdown
Contributor

based off #110
The idea is that, in line with similar, builtin options such as strict_markers or strict_xfail, enabling pytest's strict mode should implicitly turn on strict_remote_data if it's not explicitly configured.
I'm opening as a draft for now because one of the tests added is failing. I've marked it as xfail to filter out CI noise but this marker needs to be removed before I can undraft the PR

@pllim

pllim commented Nov 19, 2026

Copy link
Copy Markdown
Member

I wonder how backward compatible this is or we have to bump pytest minversion. Hard to tell with failing CI. 🤔

@neutrinoceros

Copy link
Copy Markdown
Contributor Author

This is supposed to be almost fully backwards compatible.
The only case where behavior is supposed to change is for the following config

[tool.pytest]
strict = true

where remote_data_strict would be implicitly treated as false in previous versions and true with this patch.

It's not expected to happen in practice: the global strict option was only introduced in pytest 9 (a bit over a year ago) and adoption is expected to be extremely low among this package's users.

Failures may actually reveal remaining bugs in pytest itself. In any case I need more time to figure it out.

@neutrinoceros
neutrinoceros force-pushed the enh/strict-flag-integration branch 2 times, most recently from 6cdbe18 to 19ca6be Compare November 20, 2026 07:18
@neutrinoceros

neutrinoceros commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

A couple minutes more down the rabbit hole and I found the root causes for failing tests were all contained in the plugin. One defect was with my patch itself, and the other one was in the default value for strict_remote_data, which was previously False, when I assumed it was None, similar to similar builtin options. Changing the default value without changing its truthiness should be backwards compatible in practice, except in the unlikely case a consumer would be relying on the default value being exactly False (I don't expect any code outside this plugin to even inspect this option at runtime).

@neutrinoceros

Copy link
Copy Markdown
Contributor Author

I think I can rework this to avoid dropping support for pytest 7 and 8. Will keep it a draft until then

@neutrinoceros
neutrinoceros force-pushed the enh/strict-flag-integration branch from 19ca6be to 13b6974 Compare November 20, 2026 08:29
@neutrinoceros neutrinoceros changed the title ENH: integrate with pytest's strict mode ENH: integrate with pytest 9's strict mode Nov 20, 2026
@neutrinoceros
neutrinoceros force-pushed the enh/strict-flag-integration branch from 13b6974 to c5a24d3 Compare November 20, 2026 09:13
@neutrinoceros

Copy link
Copy Markdown
Contributor Author

This is now complete with unchanged requirements. Features added here however do need pytest 9 so they are only available at runtime if this requirement is met

@neutrinoceros
neutrinoceros marked this pull request as ready for review November 20, 2026 09:18
@neutrinoceros
neutrinoceros force-pushed the enh/strict-flag-integration branch 4 times, most recently from 6bbb48c to 0b9e847 Compare November 20, 2026 14:34

@pllim pllim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this is a good compromise. Thanks for putting in the extra work for backward compatibility.

I will leave it open for a bit so @astrofrog or @bsipocz have a chance to review. LGTM though.

@neutrinoceros
neutrinoceros force-pushed the enh/strict-flag-integration branch from 0b9e847 to 05ff4a3 Compare November 20, 2026 16:47

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants