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 common TypedDicts used for M2M into contrib.py #310

Closed
qduk opened this issue Dec 22, 2023 · 2 comments · Fixed by #565
Closed

Add common TypedDicts used for M2M into contrib.py #310

qduk opened this issue Dec 22, 2023 · 2 comments · Fixed by #565
Assignees
Labels
integration: contrib Contrib related issues and PRs type: enhancement New feature or request

Comments

@qduk
Copy link
Contributor

qduk commented Dec 22, 2023

Environment

  • Nautobot version: 1.6.4
  • nautobot-ssot version: 1.6.0

Proposed Functionality

Add common typeddict's that would be commonly used for many-to-many relationships to a a new file (or contrib.py) so that they can be imported and used without the end developer having to define them.

Some example TypedDicts we could include:

class TagDict(TypedDict):
    """Many-to-many relationship typed dict explaining which fields are interesting."""

    name: str

class IPAddressDict(TypedDict):
    """Many-to-many relationship typed dict explaining which fields are interesting."""

    host: str
    prefix_length: int

class ContentTypeDict(TypedDict):
    """Many-to-many relationship typed dict explaining which fields are interesting.
    Needed for content_types:
    """

    app_label: str
    model: str

Use Case

If I am creating an SSoT and need to use Tags or ContentTypes, I would typically have to define the TypedDict myself. Implementing this would allow us to import commonly used ones for ease of use.

@jdrew82 jdrew82 added integration: contrib Contrib related issues and PRs type: enhancement New feature or request labels Feb 1, 2024
@Renrut5 Renrut5 self-assigned this Oct 7, 2024
@Renrut5
Copy link
Contributor

Renrut5 commented Oct 7, 2024

@jdrew82 @Kircheneer I would suggest this include TypedDicts not just for commonly used M2M objects, but all main Nautobot objects. This way the TypedDicts are already made and reusable in instances like custom relationships.

Thoughts?

@jdrew82
Copy link
Contributor

jdrew82 commented Oct 8, 2024

This is something that @Kircheneer and I have discussed and I think we agree that it makes sense to have the common ones as an easily importable class in the framework so people don't have to recreate them all individually.

@Renrut5 Renrut5 linked a pull request Oct 8, 2024 that will close this issue
@jdrew82 jdrew82 mentioned this issue Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration: contrib Contrib related issues and PRs type: enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants