test: avoid method-overwrite warnings in forbidproperties.jl#716
test: avoid method-overwrite warnings in forbidproperties.jl#716PatrickHaecker wants to merge 1 commit into
Conversation
`test/forbidproperties.jl` is `include`d from six sibling test modules (`SparseVectorTests`, `SparseLinalgTests`, `SparseTests`, `SparseIssuesTests`, `HigherOrderFnsTests`, `SparseMatrixConstructorIndexingTests`). It defines two methods on `Base.getproperty` for `SparseMatrixCSC` and `SparseVector`. With the [(hopefully) upcoming Julia default `--warn-overwrite=default`](JuliaLang/julia#61430), the second through sixth includes each produce method-overwrite warnings. Make the overrides idempotent by only defining them when undefined. I used Claude Opus 4.7 while preparing this. Co-authored-by: Copilot <copilot@github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #716 +/- ##
==========================================
+ Coverage 84.35% 84.37% +0.02%
==========================================
Files 13 13
Lines 9376 9376
==========================================
+ Hits 7909 7911 +2
+ Misses 1467 1465 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
IIUC then having this is "harmless" regardless of the Julia PR, right? So merging this is safe? |
Yes, exactly. It's already now helping with The reason why this is needed is interesting and I used your question as an opportunity to write it down: It's basically the Luckily, opposed to So we would need to make it a package to use Julia's even more powerful mechanism. This would work, but at this point we are talking about a larger refactor than I was not comfortable doing as a small PR. It would be cleaner, however. |
|
I think this is really just for internal usage in the tests, so this has nothing to do with the actual productive code. This is used to guard SparseArrays.jl of introducing (specific) |
|
Yes, exactly. That's why adding this "guard logic" is the pragmatic solution, even if it is not the "cleanest". |
test/forbidproperties.jlisincluded from six sibling test modules (SparseVectorTests,SparseLinalgTests,SparseTests,SparseIssuesTests,HigherOrderFnsTests,SparseMatrixConstructorIndexingTests). It defines two methods onBase.getpropertyforSparseMatrixCSCandSparseVector. With the (hopefully) upcoming Julia default--warn-overwrite=default, the second through sixth includes each produce method-overwrite warnings.Make the overrides idempotent by only defining them when undefined.
I used Claude Opus 4.7 while preparing this.