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

fix flatten #529

Merged
merged 2 commits into from
Jan 1, 2025
Merged

fix flatten #529

merged 2 commits into from
Jan 1, 2025

Conversation

joamatab
Copy link
Contributor

@joamatab joamatab commented Jan 1, 2025

Summary by Sourcery

Bug Fixes:

  • Fixed a bug where flattening a component modified the original component.

Copy link
Contributor

sourcery-ai bot commented Jan 1, 2025

Reviewer's Guide by Sourcery

This pull request fixes a bug in the get_component_with_local_layers function where the returned component was not a copy, resulting in the original component also being flattened. The fix involves creating a copy of the component and flattening the copy instead. This change prevents unintended modifications to the original component.

Sequence diagram for component flattening process

sequenceDiagram
    participant Caller
    participant GetComponent as get_component_with_local_layers
    participant Component

rect rgb(200, 150, 150)
    Note over Caller,Component: Old behavior
    Caller->>GetComponent: component
    GetComponent->>Component: flatten()
    Note right of Component: Original component modified
    GetComponent-->>Caller: flattened component
end

rect rgb(150, 200, 150)
    Note over Caller,Component: New behavior
    Caller->>GetComponent: component
    GetComponent->>Component: copy()
    Component-->>GetComponent: component_copy
    GetComponent->>Component: flatten()
    Note right of Component: Only copy is modified
    GetComponent-->>Caller: flattened component copy
end
Loading

File-Level Changes

Change Details Files
Create a copy of the component before flattening
  • Replaced local_component = component.flatten() with local_component = component.copy() and local_component.flatten()
gplugins/common/utils/get_component_with_local_layers.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

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.

We've reviewed this pull request using the Sourcery rules engine. If you would also like our AI-powered code review then let us know.

@github-actions github-actions bot added the bug Something isn't working label Jan 1, 2025
@joamatab joamatab merged commit 8d6fa2d into main Jan 1, 2025
11 of 15 checks passed
@joamatab joamatab deleted the fix_flatten branch January 1, 2025 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant