-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add TypeCastExpr class #130
Merged
Merged
Conversation
This file contains 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
TO-DO:
|
Below are the ascii and png AST reprs for from astx.types import TypeCastExpr
from astx.datatypes import Int32
from astx.variables import Variable
# Expression to cast
expr = Variable(name="x")
# Target type for casting
target_type = Int32()
# Create the TypeCastExpr
cast_expr = TypeCastExpr(expr=expr, target_type=target_type)
cast_expr The difference is due to modifications in the Case 1: def get_struct(self, simplified: bool = False) -> ReprStruct:
"""Return the AST structure of the TypeCast expression."""
key = "TypeCastExpr"
value: ReprStruct = {
"expression": self.expr.get_struct(simplified=True),
"target_type": self.target_type.get_struct(simplified=True),
}
return self._prepare_struct(key, value, simplified) Case 2: def get_struct(self, simplified: bool = False) -> ReprStruct:
"""Return the AST structure of the TypeCast expression."""
key = "TypeCastExpr"
value: ReprStruct = {
"expression": self.expr.get_struct(),
"target_type": self.target_type.get_struct(),
}
return self._prepare_struct(key, value, simplified) |
xmnlab
reviewed
Oct 25, 2024
xmnlab
reviewed
Oct 25, 2024
new AST repr, for both png and ascii: from astx.types import TypeCastExpr
from astx.datatypes import Int32
from astx.variables import Variable
# Expression to cast
expr = Variable(name="x")
# Target type for casting
target_type = Int32()
# Create the TypeCastExpr
cast_expr = TypeCastExpr(expr=expr, target_type=target_type)
cast_expr
|
I will fix the linter issue in a follow up PR |
thanks for working on that @apkrelling ! |
🎉 This PR is included in version 0.16.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
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.
Pull Request description
This PR adds TypeCastExpr class.
This PR is an attempt to solve #110 .
__init__.py
to include the new imports and classes in the__all__
listHow to test these changes
Pull Request checklists
This PR is a:
About this PR:
Author's checklist:
complexity.