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 ruff Naming rule and fix most errors #591

Merged
merged 9 commits into from
Jan 30, 2025
Merged

Conversation

MatthewMckee4
Copy link
Member

@MatthewMckee4 MatthewMckee4 commented Jan 30, 2025

Summary by Sourcery

Tests:

  • Rename the "LAYER" fixture to "layers" for consistency.

Copy link
Contributor

sourcery-ai bot commented Jan 30, 2025

Reviewer's Guide by Sourcery

This pull request introduces a new ruff Naming rule and fixes most of the errors that were raised by it. The changes primarily involve renaming variables and parameters to adhere to the new naming conventions.

Class diagram showing renamed error classes

classDiagram
    class PortWidthMismatchError {
        +__init__(instance1, instance2, port1, port2)
    }
    class PortLayerMismatchError {
        +__init__(kcl, instance1, instance2, port1, port2)
    }
    class PortTypeMismatchError {
        +__init__(instance1, instance2, port1, port2)
    }
    ValueError <|-- PortWidthMismatchError
    ValueError <|-- PortLayerMismatchError
    ValueError <|-- PortTypeMismatchError
    note for PortWidthMismatchError "Renamed from PortWidthMismatch"
    note for PortLayerMismatchError "Renamed from PortLayerMismatch"
    note for PortTypeMismatchError "Renamed from PortTypeMismatch"
Loading

Class diagram showing validator changes in LayerPropertiesModel

classDiagram
    class LayerPropertiesModel {
        +valid: bool
        +@classmethod color_to_frame_fill(cls, data)
        +@classmethod dither_to_index(cls, v)
        +@classmethod line_to_index(cls, v)
        +@staticmethod dither_to_json(value)
        +@staticmethod line_to_json(value)
    }
    note for LayerPropertiesModel "Added @classmethod and @staticmethod decorators"
Loading

File-Level Changes

Change Details Files
Renamed test function parameters to follow ruff naming conventions.
  • Renamed LAYER to layers in test functions.
tests/test_enclosure.py
tests/test_pdk.py
tests/test_instance.py
tests/test_ports.py
tests/test_routing.py
tests/conftest.py
tests/test_cell.py
tests/test_cells.py
tests/test_instances.py
tests/test_fill.py
tests/test_layers.py
tests/test_violations.py
tests/test_extrude.py
tests/test_spiral.py
tests/test_virtual.py
tests/test_all_angle.py
tests/test_cplxcells.py
tests/test_layerstack.py
tests/test_layout.py
tests/test_transformations.py
tests/test_meta.py
tests/test_partial.py
tests/test_rename.py
Fixed a typo in an exception name.
  • Renamed PortWidthMismatch to PortWidthMismatchError.
  • Renamed PortLayerMismatch to PortLayerMismatchError.
  • Renamed PortTypeMismatch to PortTypeMismatchError.
src/kfactory/instance.py
src/kfactory/exceptions.py
Added a class method decorator to model validators.
  • Added @classmethod decorator to color_to_frame_fill.
  • Added @classmethod decorator to dither_to_index.
  • Added @classmethod decorator to line_to_index.
  • Added @classmethod decorator to enclosures_must_have_main_layer.
  • Added @classmethod decorator to _validate_layers.
  • Added @classmethod decorator to restrict_types.
src/kfactory/technology/layer_map.py
src/kfactory/settings.py
src/kfactory/enclosure.py
src/kfactory/layout.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. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the 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 exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

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

@github-actions github-actions bot added enhancement New feature or request routing labels Jan 30, 2025
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.

Copy link

codecov bot commented Jan 30, 2025

Codecov Report

Attention: Patch coverage is 86.20690% with 8 lines in your changes missing coverage. Please review.

Project coverage is 63.52%. Comparing base (ecd5005) to head (6e10f48).
Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
src/kfactory/factories/euler.py 70.58% 5 Missing ⚠️
src/kfactory/instance.py 86.66% 2 Missing ⚠️
src/kfactory/layout.py 83.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #591      +/-   ##
==========================================
+ Coverage   63.45%   63.52%   +0.06%     
==========================================
  Files          64       64              
  Lines        9566     9573       +7     
  Branches     1786     1785       -1     
==========================================
+ Hits         6070     6081      +11     
+ Misses       2945     2943       -2     
+ Partials      551      549       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -901,11 +901,11 @@ def connect(
assert isinstance(p, Port) and isinstance(op, Port)

if p.width != op.width and not allow_width_mismatch:
raise PortWidthMismatch(self, other, p, op)
raise PortWidthMismatchError(self, other, p, op)
Copy link
Collaborator

Choose a reason for hiding this comment

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

why no self.cell.kcl here?

Copy link
Member Author

Choose a reason for hiding this comment

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

im not sure what you mean

Copy link
Member Author

Choose a reason for hiding this comment

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

PortWidthMismatch doesnt take kcl as an argument

@MatthewMckee4 MatthewMckee4 merged commit 2d6c317 into main Jan 30, 2025
16 checks passed
@MatthewMckee4 MatthewMckee4 deleted the add-ruff-naming branch January 30, 2025 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request routing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants