Skip to content

Refactor non-standard object identity test#996

Merged
zerothi merged 4 commits into
zerothi:mainfrom
ahkole:995-fix-non-standard-object-test
Jun 11, 2026
Merged

Refactor non-standard object identity test#996
zerothi merged 4 commits into
zerothi:mainfrom
ahkole:995-fix-non-standard-object-test

Conversation

@ahkole

@ahkole ahkole commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

It also refactors all other occurrences of not [object_name] is None to [object_name] is not None.

@zerothi

zerothi commented Jun 8, 2026

Copy link
Copy Markdown
Owner

If you think this should be fixed, then there are plenty of other places where this is done:

grep "is None" **/*.py | grep not | grep -v "is not None" 

@ahkole

ahkole commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

If you think this should be fixed, then there are plenty of other places where this is done:

grep "is None" **/*.py | grep not | grep -v "is not None" 

Ah okay, I see now yes. I personally think object is not None is easier to read than not object is None. If you agree maybe I could just replace all of them?

@codecov

codecov Bot commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.46154% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.64%. Comparing base (fc153f0) to head (b606152).

Files with missing lines Patch % Lines
src/sisl/_core/_ufuncs_grid.py 50.00% 1 Missing ⚠️
src/sisl/_core/sparse_geometry.py 50.00% 1 Missing ⚠️
src/sisl/io/openmx/omx.py 0.00% 1 Missing ⚠️
src/sisl/io/siesta/stdout.py 66.66% 1 Missing ⚠️
src/sisl/io/tbtrans/se.py 0.00% 1 Missing ⚠️
src/sisl/physics/hamiltonian.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #996   +/-   ##
=======================================
  Coverage   86.64%   86.64%           
=======================================
  Files         414      414           
  Lines       54741    54741           
=======================================
  Hits        47430    47430           
  Misses       7311     7311           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

@zerothi

zerothi commented Jun 8, 2026

Copy link
Copy Markdown
Owner

yeah, it would make sense to catch them all, while at it. Also, I wouldn't call it a fix, but a refactor/maintenance. So your changes should be named <>.dev.rst, so users don't think it will affect their code.

@ahkole ahkole changed the title Fix non-standard object identity test Refactor non-standard object identity test Jun 8, 2026
@ahkole

ahkole commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

I have used sed to replace all occurrences of not [object_name] is None to [object_name] is not None. Hopefully that should catch all of them.

I also checked after the replacement with your suggested grep command and the only remaining matches are lines that I agree should not be changed, either because they were false positives or the current expression is actually more readable.

Finally I also updated the PR title and the news fragment to call this a refactor instead of a fix.

@zerothi

zerothi commented Jun 11, 2026

Copy link
Copy Markdown
Owner

thank!

@zerothi zerothi merged commit 6340ad8 into zerothi:main Jun 11, 2026
13 checks passed
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