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

simpler generic PDK customized components #2609

Open
joamatab opened this issue Mar 8, 2024 · 4 comments
Open

simpler generic PDK customized components #2609

joamatab opened this issue Mar 8, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@joamatab
Copy link
Contributor

joamatab commented Mar 8, 2024

How about using UnPack instead of partial for customizing PDKs?

https://typing.readthedocs.io/en/latest/spec/callables.html#unpack-kwargs

image

import gdsfactory as gf
from typing import Unpack


@gf.cell(post_process=[gf.add_padding, gf.add_pins.add_pins])
def straight_sc(**kwargs: Unpack[gf.c.Straight]):
    return gf.components.straight(**kwargs)


if __name__ == "__main__":
    c = straight_sc()
    c.show()

@nikosavola
@sebastian-goeldi
@tvt173
@flaport

@joamatab joamatab added the enhancement New feature or request label Mar 8, 2024
@joamatab joamatab changed the title no more info and post_process simpler generic PDK customized components Mar 8, 2024
@nikosavola
Copy link
Member

Seems like a nice way to type components based on other components.

I wonder would it be easy to generate the TypedDict from a component function automatically, just by looking at which keyword arguments have defaults available and applying NotRequired to those.

@sebastian-goeldi
Copy link
Collaborator

sebastian-goeldi commented Mar 9, 2024

One caveat through: Unpack seems to only be available in python 3.12+ for kwargs PEP692

@joamatab
Copy link
Contributor Author

joamatab commented Mar 9, 2024

It worked for me on 3.11

@joamatab
Copy link
Contributor Author

I think this is a better solution

#2618

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants