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

Enhanced support for @Property decorator in pyreverse #10057

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

Conversation

Julfried
Copy link
Contributor

@Julfried Julfried commented Oct 30, 2024

Type of Changes

Type
✨ New feature

Description

Closes #9212

Closes #7644

This PR improves pyreverse's handling of Python properties by:

  1. Detecting properties decorated with @property
  2. Inferring property types from:
    • Return type annotations
    • Special handling for Enum.name property (-> str)
    • Type inference as fallback
  3. Displaying properties in UML diagrams with:
    • «property» stereotype
    • Inferred type information

Implementation Details

  • Added property detection and type inference in inspector.py
  • Properties are stored in node's properties list
  • Types are stored in instance_attrs_type dictionary
  • UML diagram shows property stereotype and type

Implementation Notes

This is a first implementation to get feedback. I welcome feedback on whether this approach aligns with pyreverse's architecture and design principles.

Future Work

Future improvements could include:

  • Refactoring property handling to align with regular attribute processing

  • Adding additional type inference strategies

  • Add tests for property handling

Copy link
Contributor

🤖 According to the primer, this change has no effect on the checked open source code. 🤖🎉

This comment was generated for commit a380c46

@Pierre-Sassoulas Pierre-Sassoulas changed the title Property decorator Enhanced support for @Property decorator in pyreverse Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Return type as type for property methods Enhanced support for @property decorator
1 participant