Skip to content
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

Add typing.Final and simplify type inference #1683

Merged
merged 59 commits into from
Jan 31, 2024
Merged

Add typing.Final and simplify type inference #1683

merged 59 commits into from
Jan 31, 2024

Conversation

EmilyBourne
Copy link
Member

@EmilyBourne EmilyBourne commented Jan 22, 2024

Add support for typing.Final. Fixes #1680 . This means that the AST can describe everything that textx parses in type string annotations. Therefore the type annotation methods are simplified and unified to reduce code duplication. Fixes #1581. This should make it simpler to add support for tuple/list/set type annotations

Commit Summary

  • Fix pickling of Variable and AnnotatedPyccelSymbol (lambda expressions can't be pickled) by moving ast.core.apply->ast.core.apply_pickle
  • Remove unused redundant class UnionType
  • Simplify SyntacticTypeAnnotation to only handle one type (instead of all textx output).
  • Add support for typing.Final (represents is_const concept)
  • Remove python_builtin_datatypes and simply use _visit_PyccelSymbol to collect type.
    It is not useful to differentiate between datatypes and functions. The two dictionaries point at the same objects and Python itself doesn't differentiate between the two. Anything that was missing was moved into buitin_functions.
  • Fix unnecessary import of deprecated types from NumPy in generated Python code.
  • Stop duplicating textx logic.
  • Add _get_indexed_type function to handle IndexedElement objects which describe a type.
  • Use textx class descriptors to generate Pyccel AST elements that can be parsed in the semantic stage.
  • Fix bug in test where floats were passed instead of NumPy floats.
  • Stop raising a warning when the order is provided unnecessarily.
  • Fix minor bot bug when whole file is new code.
  • Add is_const setter to type annotations.
  • Fix pyccel-init script which was not calling the related function.

@pyccel-bot
Copy link

pyccel-bot bot commented Jan 22, 2024

Hello again! Thank you for this new pull request 🤩.

Please begin by requesting your checklist using the command /bot checklist

Copy link
Contributor

@Farouk-Echaref Farouk-Echaref left a comment

Choose a reason for hiding this comment

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

Features I haven't used yet have helped me gain more insights for the project.

@pyccel-bot
Copy link

pyccel-bot bot commented Jan 25, 2024

Hey @yguclu, @EmilyBourne, this PR is looking pretty good. @EmilyBourne and @Farouk-Echaref think it is ready to merge. Could you add your expertise to confirm that this follows all the coding conventions and fits in Pyccel's future plans? Thanks 😄

@pyccel-bot pyccel-bot bot added the Ready_for_review Received at least one approval. Requires review from senior developer label Jan 25, 2024
@pyccel-bot pyccel-bot bot added Ready_to_merge Approved by senior developer. Ready for final approval and merge and removed Ready_for_review Received at least one approval. Requires review from senior developer labels Jan 30, 2024
@yguclu
Copy link
Member

yguclu commented Jan 30, 2024

/bot run pr_tests

Copy link

@pyccel-bot pyccel-bot bot left a comment

Choose a reason for hiding this comment

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

There seems to be lines in this PR which aren't tested. Please take a look at my comments and add tests which cover the new code.

If this is modified code which cannot be easily tested in this PR please open an issue to request that this code be either removed or tested. Once you have done that please leave a message on the relevant conversation beginning with the line /bot accept and referencing the issue.

Similarly if the new code cannot be tested for some reason, please leave a comment beginning with the line /bot accept on the relevant conversation explaining why the code can't be tested.


@is_const.setter
def is_const(self, val):
if not isinstance(val, bool):
Copy link

Choose a reason for hiding this comment

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

This code isn't tested. Please can you take a look

Copy link
Member Author

Choose a reason for hiding this comment

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

/bot accept

This doesn't really make sense at the moment but it is necessary to describe everything that is possible according to our type grammar.

@github-actions github-actions bot marked this pull request as draft January 30, 2024 18:54
@pyccel-bot
Copy link

pyccel-bot bot commented Jan 30, 2024

Unfortunately your PR is not passing the tests so it is not quite ready for review yet. Let me know when it is fixed with /bot mark as ready.

@pyccel-bot pyccel-bot bot removed the Ready_to_merge Approved by senior developer. Ready for final approval and merge label Jan 30, 2024
Copy link

@pyccel-bot pyccel-bot bot left a comment

Choose a reason for hiding this comment

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

Good job ! Your PR is using all the code it added/changed.

@EmilyBourne EmilyBourne marked this pull request as ready for review January 30, 2024 18:58
@pyccel-bot pyccel-bot bot added Ready_to_merge Approved by senior developer. Ready for final approval and merge and removed Ready_to_merge Approved by senior developer. Ready for final approval and merge labels Jan 30, 2024
@yguclu yguclu merged commit c06172f into devel Jan 31, 2024
22 checks passed
@yguclu yguclu deleted the devel-issue1680 branch January 31, 2024 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready_to_merge Approved by senior developer. Ready for final approval and merge Type specification
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for Final from the typing module Stop using separate treatment for textx type annotations
3 participants