Repository navigation
Make scalcs a regular package - #32
Merged
Merged
Conversation
Without scalcs/__init__.py, scalcs was a namespace package: Python merged every directory on the path holding a scalcs folder, so a module missing from the copy under test was quietly imported from another copy - an installed release, a checkout on PYTHONPATH. With __init__.py the first copy found is used whole, and a missing module is an ImportError. __init__.py imports only the version, so scalcs.__version__ now exists, as the release workflow's comment already assumed, and importing scalcs stays cheap. What this does not fix, and the tests say so: an editable install registers a finder that resolves any scalcs.* name straight to its own source tree, ignoring which copy of scalcs was imported, and it still fills in modules the first copy lacks. That finder, not the namespace merging, caused the false pass seen while reproducing Colquhoun & Lape (2012). Nothing inside the package can stop it; testing one copy of SCALCS beside an editable install of another still needs a clean environment, or that finder removed and every module's __file__ checked. The test of the path merging removes any such finder first, so it tests the merging alone: without __init__.py the missing module came from the second copy on the path; with it, importing it fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Without scalcs/init.py, scalcs was a namespace package: Python merged every directory on the path holding a scalcs folder, so a module missing from the copy under test was quietly imported from another copy - an installed release, a checkout on PYTHONPATH. With init.py the first copy found is used whole, and a missing module is an ImportError.
init.py imports only the version, so scalcs.version now exists, as the release workflow's comment already assumed, and importing scalcs stays cheap.
What this does not fix, and the tests say so: an editable install registers a finder that resolves any scalcs.* name straight to its own source tree, ignoring which copy of scalcs was imported, and it still fills in modules the first copy lacks. That finder, not the namespace merging, caused the false pass seen while reproducing Colquhoun & Lape (2012). Nothing inside the package can stop it; testing one copy of SCALCS beside an editable install of another still needs a clean environment, or that finder removed and every module's file checked.
The test of the path merging removes any such finder first, so it tests the merging alone: without init.py the missing module came from the second copy on the path; with it, importing it fails.