8000 fix: add frozen.py module to resolve Versions.released ModuleNotFound Error by samay2504 · Pull Request #1398 · pysal/pysal · GitHub
[go: up one dir, main page]

Skip to content

fix: add frozen.py module to resolve Versions.released ModuleNotFound Error - #1398

Open
samay2504 wants to merge 1 commit into
pysal:mainfrom
samay2504:fix/pysal-versions-released-missing-frozen
Open

samay2504 wants to merge 1 commit into
pysal:mainfrom
samay2504:fix/pysal-versions-released-missing-frozen

Conversation

@samay2504
Copy link
Copy Markdown
Contributor

fixes #1397.

The Versions.released property and Versions.check() method failed with ModuleNotFoundError because pysal/base.py imported from .frozen which did not exist in the package.

Changes:

  • Added pysal/frozen.py with frozen_packages that falls back to installed versions when explicit frozen versions are not available

  • Added tests for Versions.released property and Versions.check() method

…Error

The Versions.released property and Versions.check() method failed with ModuleNotFoundError because pysal/base.py imported from .frozen which did not exist in the package.

Changes:

- Add pysal/frozen.py with frozen_packages that falls back to installed versions when explicit frozen versions are not available

- Add tests for Versions.released property and Versions.check() method
Copilot AI review requested due to automatic review settings January 10, 2026 19:11
Copilot AI left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes issue #1397 where Versions.released property and Versions.check() method failed with ModuleNotFoundError because the pysal.frozen module did not exist in the package.

Changes:

  • Added pysal/frozen.py module that provides a frozen_packages dictionary with fallback to installed versions
  • Added comprehensive tests for Versions.released property and Versions.check() method to prevent regression

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
pysal/frozen.py New module providing frozen package versions with fallback to installed versions when explicit frozen data is not available
pysal/tests/test_base.py Added tests for Versions.released property and Versions.check() method to verify they work without raising exceptions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pysal/tests/test_base.py
Comment on lines +157 to +167
v = Versions()
try:
released = v.released
assert isinstance(released, dict)
except ModuleNotFoundError as e:
if "pysal.frozen" in str(e):
raise AssertionError(
"Versions.released raised ModuleNotFoundError for pysal.frozen. "
"The frozen module is missing from the package distribution."
) from e
raise
Copilot AI Jan 10, 2026
Copy link

Choose a reason for hiding this comment

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

Test complexity: The try-except blocks add unnecessary complexity. Since the frozen module is now included in the PR, the ModuleNotFoundError should never occur. The test can be simplified to just assert that v.released returns a dict without the try-except wrapper. If the module is missing, pytest will provide a clear error message.

Copilot uses AI. Check for mistakes.
Comment thread pysal/frozen.py
Comment on lines +17 to +36
def _get_frozen_packages():
"""
Get the frozen package versions.

For development installations or when frozen versions are not explicitly
set, this falls back to using the installed versions. This ensures that
Versions.released and Versions.check() work without raising errors.

Returns
-------
dict
Dictionary mapping package names to version strings.
"""
versions = {}
for package in memberships:
versions[package] = _installed_version(package)
return versions


frozen_packages = _get_frozen_packages()
Copilot AI Jan 10, 2026
Copy link

Choose a reason for hiding this comment

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

Missing integration with build process: This fallback implementation always returns installed versions, which means Versions.released will always equal Versions.installed. The tools/frozen.py script should be updated to generate this module with actual frozen version data during the release process. Consider adding a check that detects when frozen_packages contains actual release data vs. fallback data, and document that this file should be regenerated by tools/frozen.py during releases.

Copilot uses AI. Check for mistakes.
Comment thread pysal/tests/test_base.py
"The frozen module is missing from the package distribution."
) from e
raise

Copilot AI Jan 10, 2026
Copy link

Choose a reason for hiding this comment

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

Missing direct test coverage: While the frozen module is tested indirectly through test_versions_released_property_does_not_raise and test_versions_check_does_not_raise, there are no direct tests for the _get_frozen_packages function or the frozen_packages variable. Consider adding tests that directly verify: (1) frozen_packages is a dictionary, (2) it contains all packages from memberships, and (3) all values are strings.

Copilot uses AI. Check for mistakes.
Comment thread pysal/tests/test_base.py
Comment on lines +182 to +195
v = Versions()
try:
v.check()
captured = capsys.readouterr()
assert "Package" in captured.out
assert "Installed" in captured.out
assert "Released" in captured.out
except ModuleNotFoundError as e:
if "pysal.frozen" in str(e):
raise AssertionError(
"Versions.check() raised ModuleNotFoundError for pysal.frozen. "
"The frozen module is missing from the package distribution."
) from e
raise
Copilot AI Jan 10, 2026
Copy link

Choose a reason for hiding this comment

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

Test complexity: Similar to test_versions_released_property_does_not_raise, this try-except block adds unnecessary complexity. The test can be simplified to just call v.check() and verify the output without the try-except wrapper. If the frozen module is missing, pytest will provide a clear error message.

Copilot uses AI. Check for mistakes.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Versions.check() and Versions.released raise ModuleNotFoundError for missing pysal.frozen module

2 participants

0