Summary
The [pysal/base.py] and [pysal/lib/common.py] modules use outdated Python patterns that should be modernized for better security, maintainability, and to follow current best practices.
Problems Identified
1. Custom cached_property implementation (pysal/base.py, lines 23-39)
PySAL defines its own cached_property class, but since PySAL requires Python >= 3.10 (per pyproject.toml), the standard library's functools.cached_property (available since Python 3.8) should be used instead.
2. Unsafe use of exec() and eval() (pysal/base.py, pysal/lib/common.py)
The codebase uses exec() and eval() for dynamic module imports:
# In base.py
def _installed_version(package):
try:
exec(f'import {package}')
except ModuleNotFoundError:
v = 'NA'
try:
v = eval(f'{package}.__version__')
except AttributeError:
v = 'NA'
return v