Releases: zerlok/astlab
Releases · zerlok/astlab
v0.6.0
v0.6.0
New Features
-
Click integration (astlab[click])
-
A new optional extra adds PythonVersionParamType, a click.ParamType for parsing Python version CLI options:
import click
from astlab.click import PythonVersionParamType
@click.option("--python", type=PythonVersionParamType(), default=None)
def generate(python):
...
-
The metavar displays all supported versions (e.g. 3.9|3.10|3.11|3.12|3.13|3.14) and invalid input produces a clear error message.
-
PythonVersion improvements
- PythonVersion.get_current() — returns the PythonVersion matching the running interpreter
- PythonVersion.get_all_supported(*, ignore_outdated_runtime=False) — iterates over all supported versions, optionally including those newer than the current runtime
- PythonVersion.parse() now accepts None (resolves to current runtime version) and respects the ignore_outdated_runtime flag
Bug Fixes
- Fixed typing.Union and typing.Optional not being correctly loaded, inspected, and annotated — they are now consistently represented as UnionTypeInfo
- Fixed Optional annotation to emit Optional[X] on Python < 3.10 (instead of X | None)
- Fixed get_metavar signature in PythonVersionParamType for Python 3.9 compatibility (click 8.3+ changed the signature on 3.10+)
- Fixed mypy errors on Python 3.9 and 3.10 in version.py and click tests
Installation
# Core library
pip install astlab
# With click integration
pip install astlab[click]
v0.5.2
New Features
- Support for Python Version Customization
- Introduce the
PythonVersionenum to provide flexibility in specifying the desired Python version for the project's runtime.
- Introduce the
Improvements
- AST Generation Simplification
- Modifications made to AST builder, default AST resolver, type loader, and annotator to adjust their behavior based on the specified Python version. This allows for generating AST code optimized for versions older than the current runtime (e.g., using astlab for Python 3.14 while generating code for Python 3.10).
v0.5.1
New Features
- Union Type Support (Python >= 3.10)
- Introduces support for union types in the project, enabling more flexible type handling.
Improvements
- AST Inspector Union Case
- Modifies the AST inspector to return
t.Optional[T]instead oft.Union[T, None].
- Modifies the AST inspector to return
- AST Builders Refactor
- Implemented
TypeDefinitionBuilderto improveTypeRefBuilder. - Added
_normalize_type_refand incorporated it in builders for normalizing type references. - Improved type inspector support for literal and union types.
- Implemented
- Test Case Refactor
- Moved test cases related to types and builders to respective files (case_types.py, case_builder.py) using the pytest-case-provider plugin.
- Builder Test Cases Improvement
- Fixed Ruff issues in builder test cases.
- AST Builders Bug Fixes
- Various improvements and bug fixes to address issues introduced by new features in AST builders.
- Fix Indented Flag in parse_module function
- Corrected the
parse_modulefunction for proper handling of indented flag.
- Corrected the
- Compatibility Fix
- Omitted union type support for Python 3.9 to maintain compatibility with older versions.
v0.5.0
Release Notes
New Features
- Added type alias AST builder with full support for defining and rendering
TypeAliasconstructs. - Introduced type variable (TypeVar) and enum support within the AST model.
- Implemented comprehensive handling of type variables and aliases across all Python versions (<3.12 and ≥3.12).
- Enabled forward reference resolution in AST generation, limited to Python 3.14 and above.
Improvements
-
Enhanced TypeLoader error reporting for clearer diagnostics.
-
Refactored DefaultASTResolver to use DFS post-order traversal and partially support forward references.
-
Simplified and improved ASTResolver interface:
- Removed
ExprfromTypeRefalias. - Introduced a dedicated
TypeExpralias. - Removed redundant
resolve_annotationmethod.
- Removed
Documentation
- Updated
README.mdto reflect new type alias, enum, and TypeVar features. - Bumped minor version to mark API enhancement.
Full Changelog: v0.4.5...v0.5.0
v0.4.5
v0.4.4
Release Notes – v0.x.x
Features:
- Added support for Python 3.14.
- Added
indexandsliceexpression support.
Bug Fixes:
- Fixed
TypeInspectoroptional handling for Python 3.14 compatibility.
Dependency Updates:
mypyupdated from 1.17.1 → 1.18.2pytestupdated from 8.4.1 → 8.4.2pytest-covupdated from 6.2.1 → 7.0.0ruffupdated from 0.12.11 → 0.13.2
Other:
- Patch version bump.
v0.4.3
v0.4.2
v0.4.1
Features:
- Added
ModuleInfoas part of theTypeInfounion. - Added support for
inandnot incomparison expressions.
Bug Fixes:
- Fixed
mypytype issues after dependency updates. - Fixed
mypyhandling of ellipsis (...) for Python 3.9.
Dependency Updates:
mypyupdated from 1.16.1 → 1.17.1ruffupdated from 0.12.1 → 0.12.7
v0.4.0
Release Notes – v0.4.0
Refactoring and Code Improvements:
- Restructured
info.pyinto a dedicatedtypespackage. - Refactored
BuildContext,ASTResolver, andbuilder.pyfor improved clarity and correctness. - Improved dependency resolution logic and import path handling.
- Fixed
TypeInspectorandTypeLoadercompatibility for Python versions < 3.11. - Resolved
mypyand docstring issues to improve static analysis compatibility, including fixes for Python 3.9.
Development Dependencies Updated:
ruffupdated from 0.9.5 → 0.9.7 → 0.11.4 → 0.12.1pytestupdated from 8.3.4 → 8.3.5 → 8.4.1pytest-covupdated from 6.0.0 → 6.1.1 → 6.2.1mypyupdated from 1.15.0 → 1.16.1