Skip to content

fix: fail tests when srfit calls its own deprecated API - #216

Merged
sbillinge merged 2 commits into
diffpy:mainfrom
cadenmyers13:fail-on-internal-deprecations
Oct 8, 2026
Merged

sbillinge merged 2 commits into
diffpy:mainfrom
cadenmyers13:fail-on-internal-deprecations

Conversation

@cadenmyers13

Copy link
Copy Markdown
Contributor

Add a pytest filterwarnings that fails tests if diffpy.srfit calls an internally deprecated function. This catches any internal calls to deprecated functions that might have been missed. I caught a couple from this it looks like: FitRecipe.__init__ (pushFitHook) and initializeRecipe (resultsDictionary).

Add a pytest filterwarnings rule that turns DeprecationWarnings raised by
srfit's own source into errors, and fix the two internal calls it caught:
FitRecipe.__init__ (pushFitHook) and initializeRecipe (resultsDictionary).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>


def _parse_results_dictionary(results):
resstr = inputToString(results)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I had to add this function so the new deprecation catcher passed

@cadenmyers13

Copy link
Copy Markdown
Contributor Author

@sbillinge ready for review

@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.71%. Comparing base (a9eae82) to head (7ad4912).
⚠️ Report is 14 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #216       +/-   ##
===========================================
+ Coverage   71.63%   82.71%   +11.08%     
===========================================
  Files          25       27        +2     
  Lines        3437     4178      +741     
===========================================
+ Hits         2462     3456      +994     
+ Misses        975      722      -253     

see 11 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sbillinge sbillinge left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please see comment

Comment thread pyproject.toml
dependencies = {file = ["requirements/pip.txt"]}

[tool.pytest.ini_options]
# Fail when srfit source calls one of srfit's own deprecated names.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This approach seems like technical debt. The kind of tihng Claude loves but us less so. Are we baking code into our core codebase that will be there forever, just to catch stuff that we did to remove old technical debt? Can't we wjust write scripts that do this, run them, catch all the things, fix the, then delete those scripts? Or rather, have Claude do that...?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@sbillinge I actually requested this from claude because this was/is a problem in diffpy.structure (I think I fixed it but is hasnt been released). An internal call is made to a deprecated function so it emits a deprecation warning that we should've changed which looks bad. I dont view this as technical debt because once all the deprecation work is done and we remove all deprecation markers this can still live here harmlessly. I view this as a safety net to make sure we've changed all internal calls to deprecated functions

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

As for your concern about baking code in, I think we are okay because when the deprecated resultsDictionary is removed, the _parse_results_dictionary() won't be used by anything and should also be removed. I see what you're saying about the technical debt here, but I think its worth it. I'd like to think that the person removing this (likely me) will notice this and remove it. I can also add a note to remove that private function when resultsDictionary is removed. If more complex changes are required later we can remove it, but I think the safety net is nice for now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ok, I am ok with it. Shall we make an issue to remove the private function explicitly? I will merge this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure, I can do that

@cadenmyers13

Copy link
Copy Markdown
Contributor Author

@sbillinge replied to your comment^

@sbillinge
sbillinge merged commit 899c71b into diffpy:main Oct 8, 2026
7 checks passed
@cadenmyers13
cadenmyers13 deleted the fail-on-internal-deprecations branch October 8, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants