Skip to content

Feat: Added missing numeric literal classes, python string can now support all numerical types #277

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Alexis-Dubois
Copy link
Contributor

Pull Request description

At the start, I wanted to fix a problem with the python string transpiler not supporting most Int, Uint, LiteralInt and LiteralUint node types.

This pull request fix this problem but also reorganize the heritage tree a little bit for numeric literals.

There are 4 types of literal numeric type in astx: int, uint, float and complex. Complex was the only one with its own parent class. The 3 other types had a lot of duplicated code in the implementation of all their variations. I added the parent classes LiterarlInt, LiteralUint, and LiteralFloat.

This issue does not fix any announced issue. But it could touch a little bit of issue #254

How to test these changes

Tests for Literal numeric types got updated to also test the three new classes.
Many tests are also added for the python string transpiler to make sure all numeric node types are being converted correctly.

Pull Request checklists

Note:

This PR is a:

  • [] bug-fix
  • new feature
  • maintenance

About this PR:

  • it includes tests.
  • the tests are executed on CI.
  • the tests generate log file(s) (path).
  • pre-commit hooks were executed locally.
  • this PR requires a project documentation update.

Author's checklist:

  • I have reviewed the changes and it contains no misspelling.
  • The code is well commented, especially in the parts that contain more
    complexity.
  • New and old tests passed locally.

Additional information

Here is a literal diagram to show the new class in the heritage tree, it only show the LiteralInt class but it is the same idea for LiteralUint and LiteralFloat.

Untitled Diagram drawio

Reviewer's Checklist

  • I managed to reproduce the problem locally from the main branch
  • I managed to test the new changes locally
  • I confirm that the issues mentioned were fixed/resolved .

Copy link

github-actions bot commented May 7, 2025

This pull request has been marked as stale because it has been
inactive for more than 5 days. Please update this pull request
or it will be automatically closed in 5 days.

@github-actions github-actions bot added the Stale label May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant