Skip to content

Allow arbitrary attributes in HTMLDependency's stylesheet and script objects #83

@gadenbuie

Description

@gadenbuie

I appreciate the effort in this type (and the one for script objects as well), but I think it might be overly limiting.

StylesheetItemExtraAttrs = TypedDict(
"StylesheetItemExtraAttrs",
{
"as": str,
"crossorigin": str,
"disabled": str,
"hreflang": str,
"imagesizes": str,
"imagesrcset": str,
"integrity": str,
"media": str,
"prefetch": str,
"referrerpolicy": str,
"rel": str,
"sizes": str,
"title": str,
"type": str,
},
total=False,
)

I recently wanted to add a data- attribute to the <link> tag for a set of stylesheets in the shinyswatch HTMLDependency. I was pleased that stylesheet implementation lets me pass arbitrary attributes, but I had to disable type checking for the input.

I also noticed that the presence of these types did not lead to any hints in the IDE, just type errors when checked. That might be a configuration issue on my end, or it might signal that the type annotation isn't as useful as expected.

Personally, I think the TagAttrValues type would balance flexibility and type checking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions