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

Implement str and repr magic methods for Events #3601

Merged
merged 1 commit into from
Jul 5, 2024
Merged

Implement str and repr magic methods for Events #3601

merged 1 commit into from
Jul 5, 2024

Conversation

ndonkoHenri
Copy link
Contributor

@ndonkoHenri ndonkoHenri commented Jul 4, 2024

Summary by Sourcery

This pull request introduces string representation methods (__str__ and __repr__) for the Event class, improving debugging and logging capabilities. Additionally, it enhances the ContainerControl to support onTapDown events, expanding its interactivity.

  • New Features:
    • Implemented __str__ and __repr__ magic methods for the Event class to provide string representations.
  • Enhancements:
    • Enhanced ContainerControl to handle onTapDown events in addition to existing event handlers.

@ndonkoHenri ndonkoHenri requested a review from FeodorFitsner July 4, 2024 18:27
Copy link
Contributor

sourcery-ai bot commented Jul 4, 2024

Reviewer's Guide by Sourcery

This pull request implements the __str__ and __repr__ magic methods for the Event class in the flet_core package and makes minor adjustments to the ContainerControl class in the flet package to handle additional event types.

File-Level Changes

Files Changes
sdk/python/packages/flet-core/src/flet_core/event.py Implemented __str__ and __repr__ magic methods for the Event class to enhance debugging and logging capabilities.
packages/flet/lib/src/controls/container.dart Enhanced event handling in ContainerControl to support onTapDown events and updated cursor logic accordingly.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @ndonkoHenri - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 3 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

attrs = ", ".join(
f"{k}={v!r}"
for k, v in self.__dict__.items()
if k not in ["control", "page", "target"] # ignore these keys
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Consider making ignored keys a class-level constant.

Defining the ignored keys as a class-level constant (e.g., IGNORED_KEYS = ["control", "page", "target"]) can improve maintainability and readability.

Suggested change
if k not in ["control", "page", "target"] # ignore these keys
class YourClassName:
IGNORED_KEYS = ["control", "page", "target"]
def your_method(self):
attrs = ", ".join(
f"{k}={v!r}"
for k, v in self.__dict__.items()
if k not in self.IGNORED_KEYS
)
return f"{self.__class__.__name__}({attrs})"

packages/flet/lib/src/controls/container.dart Show resolved Hide resolved
packages/flet/lib/src/controls/container.dart Show resolved Hide resolved
@FeodorFitsner FeodorFitsner merged commit 4d3982e into main Jul 5, 2024
3 checks passed
@ndonkoHenri ndonkoHenri deleted the repr branch July 5, 2024 23:47
zrr1999 pushed a commit to zrr1999/flet that referenced this pull request Jul 17, 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.

2 participants