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

FEAT: Add min version decorator #5631

Merged
merged 19 commits into from
Jan 15, 2025
Merged

Conversation

SMoraisAnsys
Copy link
Collaborator

@SMoraisAnsys SMoraisAnsys commented Jan 7, 2025

Description

This feature adds the ability to decorate a method with a check on AEDT version.
This way, check the version inside the method is no longer required and one can see right away that there is a limitation on the method.

The decorator should be compatible in many classes of PyAEDT. However, there is a limitation which requires the decorated object to be able to access the AEDT desktop.
Current ways to achieve such check is to leverage any existing attribute among odesktop, _odesktop and _desktop.

Issue linked

Associated to #5504

Checklist

  • I have tested my changes locally.
  • I have added necessary documentation or updated existing documentation.
  • I have followed the coding style guidelines of this project.
  • I have added appropriate tests (unit, integration, system).
  • I have reviewed my changes before submitting this pull request.
  • I have linked the issue or issues that are solved by the PR if any.
  • I have agreed with the Contributor License Agreement (CLA).

Note

The test are performed on a mock object to simplify things but I also tested it on a fake Desktop and it worked just fine, here is the class I used to test with real AEDT object

class DummyDesktop(Desktop):
    """Dummy class to test min version."""

    def __new__(cls, *args, **kwargs):
        instance = super(Desktop, cls).__new__(cls, *args, **kwargs)
        return instance

    def __init__(self):
        super().__init__()

    @min_aedt_version(PREVIOUS_YEAR_VERSION)
    def old_method(self):
        pass

    @min_aedt_version(NEXT_YEAR_VERSION)
    def future_method(self):
        pass

This decorator should be compatible in many classes of PyAEDT.
However, there is a limitation which requires the decorated object to
be able to access the AEDT desktop.
Current ways to achieve such check is to leverage any existing attribute
among odesktop, _odesktop and _desktop.
@ansys-reviewer-bot
Copy link
Contributor

Thanks for opening a Pull Request. If you want to perform a review write a comment saying:

@ansys-reviewer-bot review

@SMoraisAnsys SMoraisAnsys self-assigned this Jan 7, 2025
@SMoraisAnsys SMoraisAnsys requested a review from gmalinve January 7, 2025 08:25
@github-actions github-actions bot added the enhancement New features or code improvements label Jan 7, 2025
Copy link

codecov bot commented Jan 7, 2025

Codecov Report

Attention: Patch coverage is 94.28571% with 4 lines in your changes missing coverage. Please review.

Project coverage is 85.27%. Comparing base (75f139e) to head (f1c7db9).
Report is 16 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5631   +/-   ##
=======================================
  Coverage   85.27%   85.27%           
=======================================
  Files         152      154    +2     
  Lines       61017    60981   -36     
=======================================
- Hits        52033    52004   -29     
+ Misses       8984     8977    -7     

MaxJPRey
MaxJPRey previously approved these changes Jan 8, 2025
Copy link
Collaborator

@MaxJPRey MaxJPRey left a comment

Choose a reason for hiding this comment

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

This is clearly a must have feature. Thanks @SMoraisAnsys . Let's make sure we promote its extensive usage.

Copy link
Member

@Samuelopez-ansys Samuelopez-ansys left a comment

Choose a reason for hiding this comment

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

Great job!

@Samuelopez-ansys Samuelopez-ansys merged commit 685b8a9 into main Jan 15, 2025
43 checks passed
@Samuelopez-ansys Samuelopez-ansys deleted the feat/add-min-version-decorator branch January 15, 2025 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features or code improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants