diff --git a/meta/generate_tag_defs.py b/meta/generate_tag_defs.py index 0ab9d83..fd7a3cc 100644 --- a/meta/generate_tag_defs.py +++ b/meta/generate_tag_defs.py @@ -21,7 +21,7 @@ def _escape_children(self) -> bool: """ GET_PRE_CONTENT = """ - def _get_tag_pre_content(self) -> Optional[str]: + def _get_tag_pre_content(self) -> str | None: return {} """ diff --git a/meta/scrape_tags.py b/meta/scrape_tags.py index 08ff32a..ffef4f7 100644 --- a/meta/scrape_tags.py +++ b/meta/scrape_tags.py @@ -10,7 +10,7 @@ import sys from collections.abc import Iterator from dataclasses import dataclass -from typing import Any, Optional, TypedDict, Union +from typing import Any, TypedDict import requests import yaml @@ -42,7 +42,7 @@ """ -def htmlElementReplace(lookup: str, presentation: Optional[str] = None) -> str: +def htmlElementReplace(lookup: str, presentation: str | None = None) -> str: """ Replace text in an HTML reference """ @@ -54,7 +54,7 @@ def htmlElementReplace(lookup: str, presentation: Optional[str] = None) -> str: return f"[{presentation}]({url})" -def glossaryReplace(lookup: str, presentation: Optional[str] = None) -> str: +def glossaryReplace(lookup: str, presentation: str | None = None) -> str: """ Replace text in a glossary reference """ @@ -66,7 +66,7 @@ def glossaryReplace(lookup: str, presentation: Optional[str] = None) -> str: return f"[{presentation}]({url})" -def cssXrefReplace(lookup: str, presentation: Optional[str] = None) -> str: +def cssXrefReplace(lookup: str, presentation: str | None = None) -> str: """ Replace text for CSS cross reference lookup """ @@ -78,7 +78,7 @@ def cssXrefReplace(lookup: str, presentation: Optional[str] = None) -> str: return f"[{presentation}]({url})" -def domXrefReplace(lookup: str, presentation: Optional[str] = None) -> str: +def domXrefReplace(lookup: str, presentation: str | None = None) -> str: """ Replace text for DOM cross reference lookup """ @@ -137,7 +137,7 @@ class TagsYmlItem(TypedDict): skip: NotRequired[bool] """Whether to skip this tag when generating tags""" - attributes: NotRequired[dict[str, Union[str, AttrYmlItem]]] + attributes: NotRequired[dict[str, str | AttrYmlItem]] """Mapping of attributes used by the tag (name: description)""" base: NotRequired[str] @@ -175,7 +175,7 @@ class Attr: Name of the attribute """ - doc: Optional[str] + doc: str | None """ Documentation of the attribute if applicable """ @@ -185,7 +185,7 @@ class Attr: Type to accept for the attribute """ - default: Optional[Any] + default: Any | None """ Default value for the attribute """ @@ -227,12 +227,12 @@ class TagInfo: List of attributes and their documentation. """ - pre_content: Optional[str] + pre_content: str | None """ Pre-content for the element (eg ``) """ - render_options: Optional[RenderOptions] + render_options: RenderOptions | None """ Render options """ @@ -419,8 +419,8 @@ def attr_entries_to_object(tags: TagsYaml, tag_name: str) -> list[Attr]: attrs = [] for name, value in tag_data["attributes"].items(): if isinstance(value, str): - doc: Optional[str] = value - default: Optional[str] = None + doc: str | None = value + default: str | None = None type = "AttributeType" else: doc = value.get("doc") @@ -479,7 +479,7 @@ def get_tag_escape_children(tags: TagsYaml, tag_name: str) -> bool: return tag.get("escape_children", True) -def get_tag_pre_content(tags: TagsYaml, tag_name: str) -> Optional[str]: +def get_tag_pre_content(tags: TagsYaml, tag_name: str) -> str | None: """ Return pre-content for the tag """ @@ -491,7 +491,7 @@ def get_tag_pre_content(tags: TagsYaml, tag_name: str) -> Optional[str]: def get_tag_render_options( tags: TagsYaml, tag_name: str -) -> Optional[RenderOptions]: +) -> RenderOptions | None: """ Return pre-content for the tag """ diff --git a/meta/tags.yml b/meta/tags.yml index 75e6f81..36cbdd3 100644 --- a/meta/tags.yml +++ b/meta/tags.yml @@ -6,7 +6,7 @@ html: attributes: lang: doc: Language used by the document - type: Optional[str] + type: "str | None" # Rename tag as it is a reserved keyword in Python del: @@ -23,20 +23,20 @@ link: attributes: href: doc: Location of the file being linked to - type: Optional[str] + type: "str | None" rel: doc: Kind of file being loaded (eg `"stylesheet"`) - type: Optional[str] + type: "str | None" a: base: StylableTag attributes: href: doc: URL of page to link to - type: Optional[str] + type: "str | None" target: doc: Use "_blank" to open in a new tab - type: "Union[Literal['_self', '_blank', '_parent', '_top'], str, None]" + type: "Literal['_self', '_blank', '_parent', '_top'] | str | None" script: escape_children: false @@ -44,7 +44,7 @@ script: type: doc: Type of script to use default: "'text/javascript'" - type: Optional[str] + type: "str | None" src: The location from which to load the script. If present, this will be used rather than the contents of the element. style: @@ -53,14 +53,14 @@ style: type: doc: Type of style to use default: "'text/css'" - type: Optional[str] + type: "str | None" form: attributes: method: doc: The HTTP request method to use when submitting this form. In almost all cases, you'll want this to be POST. default: "'post'" - type: "Optional[Literal['post', 'get']]" + type: "Literal['post', 'get'] | None" action: The URL to request to when submitting this form. By default, requests will be sent to the same URL as the current page. input: @@ -80,7 +80,7 @@ th: attributes: scope: doc: 'The area of the table that this heading applies to. Allowed values: `"col"`, `"row"`, `"colgroup"`, `"rowgroup"`' - type: "Optional[Literal['col', 'row', 'colgroup', 'rowgroup']]" + type: "Literal['col', 'row', 'colgroup', 'rowgroup'] | None" colspan: The number of columns in the table that this heading spans. rowspan: The number of rows in the table that this heading spans. @@ -151,34 +151,34 @@ textarea: attributes: required: doc: Whether the input is required to submit the form it is contained within. - type: "Optional[bool]" + type: "bool | None" name: The name to use for this value when submitting the form. rows: doc: The number of rows (lines) to use in the text area. Value should be an integer, but given as type `str`. - type: "Optional[str]" + type: "str | None" cols: doc: The number of columns (length of each line) to use in the text area. Value should be an integer, but given as type `str`. - type: "Optional[str]" + type: "str | None" placeholder: Placeholder text to use when the field is empty. disabled: doc: "Whether this option is disabled, meaning it cannot be selected, and will not be submitted with the form." - type: "Optional[bool]" + type: "bool | None" maxlength: The maximum number of characters permitted in the textarea wrap: doc: How to perform word wrapping ("hard" or "soft") - type: "Union[Literal['hard', 'soft'], None]" + type: "Literal['hard', 'soft'] | None" readonly: doc: "Whether this option is read-only, meaning it cannot be modified" - type: "Optional[bool]" + type: "bool | None" option: attributes: selected: doc: "Whether this option is the default selection within the `select` element" - type: "Optional[bool]" + type: "bool | None" disabled: doc: "Whether this option is disabled, meaning it cannot be selected." - type: "Optional[bool]" + type: "bool | None" value: doc: "The value to use if this option is selected when submitting the form" @@ -187,11 +187,11 @@ select: attributes: required: doc: Whether the input is required to submit the form it is contained within. - type: "Optional[bool]" + type: "bool | None" name: The name to use for this value when submitting the form. disabled: doc: "Whether this form element is disabled, meaning it cannot be selected, and will not be submitted with the form." - type: "Optional[bool]" + type: "bool | None" multiple: doc: "Whether multiple options can be simultaneously selected." - type: "Optional[bool]" + type: "bool | None" diff --git a/meta/templates/class_attrs_StylableTag.py b/meta/templates/class_attrs_StylableTag.py index 2372a68..79317f9 100644 --- a/meta/templates/class_attrs_StylableTag.py +++ b/meta/templates/class_attrs_StylableTag.py @@ -10,9 +10,9 @@ def __init__( self, *children: ChildrenType, {attr_args} - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ) -> None: """ @@ -34,9 +34,9 @@ def __call__( # type: ignore self, *children: ChildrenType, {attr_args} - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ): """ diff --git a/meta/templates/main.py b/meta/templates/main.py index 942dab3..d08cf1e 100644 --- a/meta/templates/main.py +++ b/meta/templates/main.py @@ -7,7 +7,7 @@ https://creativecommons.org/licenses/by-sa/2.5/ """ -from typing import Literal, Optional, Union +from typing import Literal from ..__render_options import RenderOptions from ..__tag_base import SelfClosingTag, Tag, WhitespaceSensitiveTag diff --git a/poetry.lock b/poetry.lock index 98ad1b2..be14035 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1551,5 +1551,5 @@ watchdog = ["watchdog (>=2.3)"] [metadata] lock-version = "2.1" -python-versions = "^3.10" -content-hash = "ef818b5263f5c19eb619288f9feb29283b64fc669fcdf6bc43a90bdfeed7bc7a" +python-versions = ">=3.10" +content-hash = "415c26c88c89c9056e1cffa85ba28f5044bfbc5cd16832f882e6bc3b3ae30244" diff --git a/pyhtml/__render_options.py b/pyhtml/__render_options.py index 00dc23a..62114a3 100644 --- a/pyhtml/__render_options.py +++ b/pyhtml/__render_options.py @@ -5,7 +5,6 @@ """ from dataclasses import asdict, dataclass -from typing import Optional # While it could be cleaner (and far less-repetitive) to use a TypedDict and # declare the partial options class as per @@ -50,7 +49,7 @@ class RenderOptions: PyHTML rendering options. """ - indent: Optional[str] = None + indent: str | None = None """ String to add to indentation for non-inline child elements. For example, to indent using a tab, you could use `'\\t'`. @@ -58,7 +57,7 @@ class RenderOptions: Defaults to 2 spaces (`' '`). """ - spacing: Optional[str] = None + spacing: str | None = None """ String to use for spacing between child elements. When this is set to `'\\n'`, each child element will be placed on its own line, and indentation diff --git a/pyhtml/__tag_base.py b/pyhtml/__tag_base.py index 8f2c274..ce97eaf 100644 --- a/pyhtml/__tag_base.py +++ b/pyhtml/__tag_base.py @@ -4,7 +4,7 @@ Tag base class, including rendering logic """ -from typing import Optional, TypeVar +from typing import TypeVar from . import __util as util from .__render_options import FullRenderOptions, RenderOptions @@ -98,7 +98,7 @@ def _get_default_render_options(self) -> RenderOptions: # By default, don't override any options return RenderOptions() - def _get_tag_pre_content(self) -> Optional[str]: + def _get_tag_pre_content(self) -> str | None: """ Return "pre-content" for the tag. diff --git a/pyhtml/__tags/generated.py b/pyhtml/__tags/generated.py index 3938101..52b0621 100644 --- a/pyhtml/__tags/generated.py +++ b/pyhtml/__tags/generated.py @@ -7,7 +7,7 @@ https://creativecommons.org/licenses/by-sa/2.5/ """ -from typing import Literal, Optional, Union +from typing import Literal from ..__render_options import RenderOptions from ..__tag_base import SelfClosingTag, Tag, WhitespaceSensitiveTag @@ -25,7 +25,7 @@ class html(Tag): def __init__( self, *children: ChildrenType, - lang: Optional[str] = None, + lang: str | None = None, **attributes: AttributeType, ) -> None: """ @@ -43,7 +43,7 @@ def __init__( def __call__( # type: ignore self, *children: ChildrenType, - lang: Optional[str] = None, + lang: str | None = None, **attributes: AttributeType, ): """ @@ -62,7 +62,7 @@ def _get_default_attributes(self, given: dict[str, AttributeType]) -> dict[str, return {'lang': None} - def _get_tag_pre_content(self) -> Optional[str]: + def _get_tag_pre_content(self) -> str | None: return '' @@ -181,8 +181,8 @@ class link(SelfClosingTag): def __init__( self, *options: RenderOptions, - href: Optional[str] = None, - rel: Optional[str] = None, + href: str | None = None, + rel: str | None = None, **attributes: AttributeType, ) -> None: """ @@ -202,8 +202,8 @@ def __init__( def __call__( # type: ignore self, *options: RenderOptions, - href: Optional[str] = None, - rel: Optional[str] = None, + href: str | None = None, + rel: str | None = None, **attributes: AttributeType, ): """ @@ -283,7 +283,7 @@ class style(Tag): def __init__( self, *children: ChildrenType, - type: Optional[str] = None, + type: str | None = None, **attributes: AttributeType, ) -> None: """ @@ -301,7 +301,7 @@ def __init__( def __call__( # type: ignore self, *children: ChildrenType, - type: Optional[str] = None, + type: str | None = None, **attributes: AttributeType, ): """ @@ -672,9 +672,9 @@ def __init__( self, *children: ChildrenType, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ) -> None: """ @@ -696,9 +696,9 @@ def __call__( # type: ignore self, *children: ChildrenType, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ): """ @@ -732,9 +732,9 @@ def __init__( self, *children: ChildrenType, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ) -> None: """ @@ -756,9 +756,9 @@ def __call__( # type: ignore self, *children: ChildrenType, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ): """ @@ -792,9 +792,9 @@ def __init__( self, *children: ChildrenType, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ) -> None: """ @@ -816,9 +816,9 @@ def __call__( # type: ignore self, *children: ChildrenType, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ): """ @@ -852,9 +852,9 @@ def __init__( self, *children: ChildrenType, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ) -> None: """ @@ -876,9 +876,9 @@ def __call__( # type: ignore self, *children: ChildrenType, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ): """ @@ -912,9 +912,9 @@ def __init__( self, *children: ChildrenType, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ) -> None: """ @@ -936,9 +936,9 @@ def __call__( # type: ignore self, *children: ChildrenType, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ): """ @@ -972,9 +972,9 @@ def __init__( self, *children: ChildrenType, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ) -> None: """ @@ -996,9 +996,9 @@ def __call__( # type: ignore self, *children: ChildrenType, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ): """ @@ -1368,9 +1368,9 @@ def __init__( self, *children: ChildrenType, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ) -> None: """ @@ -1392,9 +1392,9 @@ def __call__( # type: ignore self, *children: ChildrenType, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ): """ @@ -1812,9 +1812,9 @@ def __init__( self, *children: ChildrenType, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ) -> None: """ @@ -1836,9 +1836,9 @@ def __call__( # type: ignore self, *children: ChildrenType, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ): """ @@ -1972,11 +1972,11 @@ class a(Tag): def __init__( self, *children: ChildrenType, - href: Optional[str] = None, - target: Union[Literal['_self', '_blank', '_parent', '_top'], str, None] = None, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + href: str | None = None, + target: Literal['_self', '_blank', '_parent', '_top'] | str | None = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ) -> None: """ @@ -1999,11 +1999,11 @@ def __init__( def __call__( # type: ignore self, *children: ChildrenType, - href: Optional[str] = None, - target: Union[Literal['_self', '_blank', '_parent', '_top'], str, None] = None, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + href: str | None = None, + target: Literal['_self', '_blank', '_parent', '_top'] | str | None = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ): """ @@ -2087,9 +2087,9 @@ def __init__( self, *children: ChildrenType, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ) -> None: """ @@ -2111,9 +2111,9 @@ def __call__( # type: ignore self, *children: ChildrenType, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ): """ @@ -2483,9 +2483,9 @@ def __init__( self, *children: ChildrenType, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ) -> None: """ @@ -2507,9 +2507,9 @@ def __call__( # type: ignore self, *children: ChildrenType, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ): """ @@ -2543,9 +2543,9 @@ def __init__( self, *children: ChildrenType, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ) -> None: """ @@ -2567,9 +2567,9 @@ def __call__( # type: ignore self, *children: ChildrenType, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ): """ @@ -3035,9 +3035,9 @@ def __init__( self, *children: ChildrenType, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ) -> None: """ @@ -3059,9 +3059,9 @@ def __call__( # type: ignore self, *children: ChildrenType, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ): """ @@ -3095,9 +3095,9 @@ def __init__( self, *children: ChildrenType, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ) -> None: """ @@ -3119,9 +3119,9 @@ def __call__( # type: ignore self, *children: ChildrenType, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ): """ @@ -4122,7 +4122,7 @@ class script(Tag): def __init__( self, *children: ChildrenType, - type: Optional[str] = None, + type: str | None = None, src: AttributeType = None, **attributes: AttributeType, ) -> None: @@ -4143,7 +4143,7 @@ def __init__( def __call__( # type: ignore self, *children: ChildrenType, - type: Optional[str] = None, + type: str | None = None, src: AttributeType = None, **attributes: AttributeType, ): @@ -4421,9 +4421,9 @@ def __init__( self, *children: ChildrenType, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ) -> None: """ @@ -4445,9 +4445,9 @@ def __call__( # type: ignore self, *children: ChildrenType, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ): """ @@ -4531,9 +4531,9 @@ def __init__( *children: ChildrenType, colspan: AttributeType = None, rowspan: AttributeType = None, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ) -> None: """ @@ -4558,9 +4558,9 @@ def __call__( # type: ignore *children: ChildrenType, colspan: AttributeType = None, rowspan: AttributeType = None, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ): """ @@ -4645,12 +4645,12 @@ class th(Tag): def __init__( self, *children: ChildrenType, - scope: Optional[Literal['col', 'row', 'colgroup', 'rowgroup']] = None, + scope: Literal['col', 'row', 'colgroup', 'rowgroup'] | None = None, colspan: AttributeType = None, rowspan: AttributeType = None, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ) -> None: """ @@ -4675,12 +4675,12 @@ def __init__( def __call__( # type: ignore self, *children: ChildrenType, - scope: Optional[Literal['col', 'row', 'colgroup', 'rowgroup']] = None, + scope: Literal['col', 'row', 'colgroup', 'rowgroup'] | None = None, colspan: AttributeType = None, rowspan: AttributeType = None, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ): """ @@ -4816,9 +4816,9 @@ def __init__( *children: ChildrenType, formmethod: AttributeType = None, formaction: AttributeType = None, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ) -> None: """ @@ -4843,9 +4843,9 @@ def __call__( # type: ignore *children: ChildrenType, formmethod: AttributeType = None, formaction: AttributeType = None, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ): """ @@ -4977,7 +4977,7 @@ class form(Tag): def __init__( self, *children: ChildrenType, - method: Optional[Literal['post', 'get']] = None, + method: Literal['post', 'get'] | None = None, action: AttributeType = None, **attributes: AttributeType, ) -> None: @@ -4998,7 +4998,7 @@ def __init__( def __call__( # type: ignore self, *children: ChildrenType, - method: Optional[Literal['post', 'get']] = None, + method: Literal['post', 'get'] | None = None, action: AttributeType = None, **attributes: AttributeType, ): @@ -5225,8 +5225,8 @@ class option(Tag): def __init__( self, *children: ChildrenType, - selected: Optional[bool] = None, - disabled: Optional[bool] = None, + selected: bool | None = None, + disabled: bool | None = None, value: AttributeType = None, **attributes: AttributeType, ) -> None: @@ -5249,8 +5249,8 @@ def __init__( def __call__( # type: ignore self, *children: ChildrenType, - selected: Optional[bool] = None, - disabled: Optional[bool] = None, + selected: bool | None = None, + disabled: bool | None = None, value: AttributeType = None, **attributes: AttributeType, ): @@ -5384,13 +5384,13 @@ class select(Tag): def __init__( self, *children: ChildrenType, - required: Optional[bool] = None, + required: bool | None = None, name: AttributeType = None, - disabled: Optional[bool] = None, - multiple: Optional[bool] = None, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + disabled: bool | None = None, + multiple: bool | None = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ) -> None: """ @@ -5417,13 +5417,13 @@ def __init__( def __call__( # type: ignore self, *children: ChildrenType, - required: Optional[bool] = None, + required: bool | None = None, name: AttributeType = None, - disabled: Optional[bool] = None, - multiple: Optional[bool] = None, - id: Optional[str] = None, - _class: Optional[str] = None, - style: Optional[str] = None, + disabled: bool | None = None, + multiple: bool | None = None, + id: str | None = None, + _class: str | None = None, + style: str | None = None, **attributes: AttributeType, ): """ @@ -5470,15 +5470,15 @@ class textarea(WhitespaceSensitiveTag): def __init__( self, *children: ChildrenType, - required: Optional[bool] = None, + required: bool | None = None, name: AttributeType = None, - rows: Optional[str] = None, - cols: Optional[str] = None, + rows: str | None = None, + cols: str | None = None, placeholder: AttributeType = None, - disabled: Optional[bool] = None, + disabled: bool | None = None, maxlength: AttributeType = None, - wrap: Union[Literal['hard', 'soft'], None] = None, - readonly: Optional[bool] = None, + wrap: Literal['hard', 'soft'] | None = None, + readonly: bool | None = None, **attributes: AttributeType, ) -> None: """ @@ -5512,15 +5512,15 @@ def __init__( def __call__( # type: ignore self, *children: ChildrenType, - required: Optional[bool] = None, + required: bool | None = None, name: AttributeType = None, - rows: Optional[str] = None, - cols: Optional[str] = None, + rows: str | None = None, + cols: str | None = None, placeholder: AttributeType = None, - disabled: Optional[bool] = None, + disabled: bool | None = None, maxlength: AttributeType = None, - wrap: Union[Literal['hard', 'soft'], None] = None, - readonly: Optional[bool] = None, + wrap: Literal['hard', 'soft'] | None = None, + readonly: bool | None = None, **attributes: AttributeType, ): """ diff --git a/pyhtml/__tags/input_tag.py b/pyhtml/__tags/input_tag.py index 8834743..d67cbd1 100644 --- a/pyhtml/__tags/input_tag.py +++ b/pyhtml/__tags/input_tag.py @@ -5,7 +5,7 @@ custom behaviour. """ -from typing import Literal, Optional, overload +from typing import Literal, overload from ..__render_options import RenderOptions from ..__tag_base import SelfClosingTag @@ -112,11 +112,11 @@ def __init__( self, *options: RenderOptions, type: Literal["submit"] = "submit", - id: Optional[str] = None, - name: Optional[str] = None, - value: Optional[str] = None, - disabled: Optional[bool] = None, - autofocus: Optional[bool] = None, + id: str | None = None, + name: str | None = None, + value: str | None = None, + disabled: bool | None = None, + autofocus: bool | None = None, **attributes: AttributeType, ) -> None: ... @@ -126,15 +126,15 @@ def __init__( self, *options: RenderOptions, type: Literal["text"] = "text", - id: Optional[str] = None, - name: Optional[str] = None, - value: Optional[str] = None, - readonly: Optional[bool] = None, - required: Optional[bool] = None, - placeholder: Optional[str] = None, - spellcheck: Optional[Literal["true", "false", ""]] = None, - disabled: Optional[bool] = None, - autofocus: Optional[bool] = None, + id: str | None = None, + name: str | None = None, + value: str | None = None, + readonly: bool | None = None, + required: bool | None = None, + placeholder: str | None = None, + spellcheck: Literal["true", "false", ""] | None = None, + disabled: bool | None = None, + autofocus: bool | None = None, **attributes: AttributeType, ) -> None: ... @@ -144,12 +144,12 @@ def __init__( self, *options: RenderOptions, type: Literal["button"] = "button", - id: Optional[str] = None, - name: Optional[str] = None, - value: Optional[str] = None, - disabled: Optional[bool] = None, - readonly: Optional[bool] = None, - autofocus: Optional[bool] = None, + id: str | None = None, + name: str | None = None, + value: str | None = None, + disabled: bool | None = None, + readonly: bool | None = None, + autofocus: bool | None = None, **attributes: AttributeType, ) -> None: ... @@ -159,13 +159,13 @@ def __init__( self, *options: RenderOptions, type: Literal["checkbox"] = "checkbox", - id: Optional[str] = None, - name: Optional[str] = None, - value: Optional[str] = None, - checked: Optional[bool] = None, - disabled: Optional[bool] = None, - readonly: Optional[bool] = None, - autofocus: Optional[bool] = None, + id: str | None = None, + name: str | None = None, + value: str | None = None, + checked: bool | None = None, + disabled: bool | None = None, + readonly: bool | None = None, + autofocus: bool | None = None, **attributes: AttributeType, ) -> None: ... @@ -175,14 +175,14 @@ def __init__( self, *options: RenderOptions, type: Literal["email"] = "email", - id: Optional[str] = None, - name: Optional[str] = None, - value: Optional[str] = None, - disabled: Optional[bool] = None, - readonly: Optional[bool] = None, - required: Optional[bool] = None, - placeholder: Optional[str] = None, - autofocus: Optional[bool] = None, + id: str | None = None, + name: str | None = None, + value: str | None = None, + disabled: bool | None = None, + readonly: bool | None = None, + required: bool | None = None, + placeholder: str | None = None, + autofocus: bool | None = None, **attributes: AttributeType, ) -> None: ... @@ -192,14 +192,14 @@ def __init__( self, *options: RenderOptions, type: Literal["file"] = "file", - id: Optional[str] = None, - name: Optional[str] = None, - value: Optional[str] = None, - disabled: Optional[bool] = None, - readonly: Optional[bool] = None, - accept: Optional[str] = None, - multiple: Optional[bool] = None, - autofocus: Optional[bool] = None, + id: str | None = None, + name: str | None = None, + value: str | None = None, + disabled: bool | None = None, + readonly: bool | None = None, + accept: str | None = None, + multiple: bool | None = None, + autofocus: bool | None = None, **attributes: AttributeType, ) -> None: ... @@ -209,15 +209,15 @@ def __init__( self, *options: RenderOptions, type: Literal["number"] = "number", - id: Optional[str] = None, - name: Optional[str] = None, - value: Optional[str] = None, - disabled: Optional[bool] = None, - readonly: Optional[bool] = None, - min: Optional[str] = None, - max: Optional[str] = None, - placeholder: Optional[str] = None, - autofocus: Optional[bool] = None, + id: str | None = None, + name: str | None = None, + value: str | None = None, + disabled: bool | None = None, + readonly: bool | None = None, + min: str | None = None, + max: str | None = None, + placeholder: str | None = None, + autofocus: bool | None = None, **attributes: AttributeType, ) -> None: ... @@ -227,14 +227,14 @@ def __init__( self, *options: RenderOptions, type: Literal["password"] = "password", - id: Optional[str] = None, - name: Optional[str] = None, - value: Optional[str] = None, - disabled: Optional[bool] = None, - readonly: Optional[bool] = None, - required: Optional[bool] = None, - placeholder: Optional[str] = None, - autofocus: Optional[bool] = None, + id: str | None = None, + name: str | None = None, + value: str | None = None, + disabled: bool | None = None, + readonly: bool | None = None, + required: bool | None = None, + placeholder: str | None = None, + autofocus: bool | None = None, **attributes: AttributeType, ) -> None: ... @@ -244,14 +244,14 @@ def __init__( self, *options: RenderOptions, type: Literal["radio"] = "radio", - id: Optional[str] = None, - name: Optional[str] = None, - value: Optional[str] = None, - checked: Optional[bool] = None, - disabled: Optional[bool] = None, - readonly: Optional[bool] = None, - required: Optional[bool] = None, - autofocus: Optional[bool] = None, + id: str | None = None, + name: str | None = None, + value: str | None = None, + checked: bool | None = None, + disabled: bool | None = None, + readonly: bool | None = None, + required: bool | None = None, + autofocus: bool | None = None, **attributes: AttributeType, ) -> None: ... @@ -261,16 +261,16 @@ def __init__( self, *options: RenderOptions, type: Literal["range"] = "range", - id: Optional[str] = None, - name: Optional[str] = None, - value: Optional[str] = None, - disabled: Optional[bool] = None, - readonly: Optional[bool] = None, - min: Optional[str] = None, - max: Optional[str] = None, - step: Optional[str] = None, - placeholder: Optional[str] = None, - autofocus: Optional[bool] = None, + id: str | None = None, + name: str | None = None, + value: str | None = None, + disabled: bool | None = None, + readonly: bool | None = None, + min: str | None = None, + max: str | None = None, + step: str | None = None, + placeholder: str | None = None, + autofocus: bool | None = None, **attributes: AttributeType, ) -> None: ... @@ -279,15 +279,15 @@ def __init__( def __init__( self, *options: RenderOptions, - type: Optional[InputTypes] = None, - id: Optional[str] = None, - name: Optional[str] = None, - value: Optional[str] = None, - placeholder: Optional[str] = None, - disabled: Optional[bool] = None, - readonly: Optional[bool] = None, - required: Optional[bool] = None, - autofocus: Optional[bool] = None, + type: InputTypes | None = None, + id: str | None = None, + name: str | None = None, + value: str | None = None, + placeholder: str | None = None, + disabled: bool | None = None, + readonly: bool | None = None, + required: bool | None = None, + autofocus: bool | None = None, **attributes: AttributeType, ) -> None: ... @@ -296,25 +296,25 @@ def __init__( def __init__( self, *options: RenderOptions, - type: Optional[str] = None, - id: Optional[str] = None, - name: Optional[str] = None, - value: Optional[str] = None, - placeholder: Optional[str] = None, - disabled: Optional[bool] = None, - readonly: Optional[bool] = None, - required: Optional[bool] = None, - autofocus: Optional[bool] = None, + type: str | None = None, + id: str | None = None, + name: str | None = None, + value: str | None = None, + placeholder: str | None = None, + disabled: bool | None = None, + readonly: bool | None = None, + required: bool | None = None, + autofocus: bool | None = None, **attributes: AttributeType, ) -> None: ... def __init__( self, *options: RenderOptions, - type: Optional[str] = None, - id: Optional[str] = None, - name: Optional[str] = None, - value: Optional[str] = None, + type: str | None = None, + id: str | None = None, + name: str | None = None, + value: str | None = None, **attributes: AttributeType, ) -> None: """ @@ -398,11 +398,11 @@ def __call__( self, *options: RenderOptions, type: Literal["submit"] = "submit", - id: Optional[str] = None, - name: Optional[str] = None, - value: Optional[str] = None, - disabled: Optional[bool] = None, - autofocus: Optional[bool] = None, + id: str | None = None, + name: str | None = None, + value: str | None = None, + disabled: bool | None = None, + autofocus: bool | None = None, **attributes: AttributeType, ) -> None: ... @@ -412,15 +412,15 @@ def __call__( self, *options: RenderOptions, type: Literal["text"] = "text", - id: Optional[str] = None, - name: Optional[str] = None, - value: Optional[str] = None, - disabled: Optional[bool] = None, - readonly: Optional[bool] = None, - required: Optional[bool] = None, - placeholder: Optional[str] = None, - spellcheck: Optional[Literal["true", "false", ""]] = None, - autofocus: Optional[bool] = None, + id: str | None = None, + name: str | None = None, + value: str | None = None, + disabled: bool | None = None, + readonly: bool | None = None, + required: bool | None = None, + placeholder: str | None = None, + spellcheck: Literal["true", "false", ""] | None = None, + autofocus: bool | None = None, **attributes: AttributeType, ) -> None: ... @@ -430,12 +430,12 @@ def __call__( self, *options: RenderOptions, type: Literal["button"] = "button", - id: Optional[str] = None, - name: Optional[str] = None, - value: Optional[str] = None, - disabled: Optional[bool] = None, - readonly: Optional[bool] = None, - autofocus: Optional[bool] = None, + id: str | None = None, + name: str | None = None, + value: str | None = None, + disabled: bool | None = None, + readonly: bool | None = None, + autofocus: bool | None = None, **attributes: AttributeType, ) -> None: ... @@ -445,13 +445,13 @@ def __call__( self, *options: RenderOptions, type: Literal["checkbox"] = "checkbox", - id: Optional[str] = None, - name: Optional[str] = None, - value: Optional[str] = None, - checked: Optional[bool] = None, - disabled: Optional[bool] = None, - readonly: Optional[bool] = None, - autofocus: Optional[bool] = None, + id: str | None = None, + name: str | None = None, + value: str | None = None, + checked: bool | None = None, + disabled: bool | None = None, + readonly: bool | None = None, + autofocus: bool | None = None, **attributes: AttributeType, ) -> None: ... @@ -461,14 +461,14 @@ def __call__( self, *options: RenderOptions, type: Literal["email"] = "email", - id: Optional[str] = None, - name: Optional[str] = None, - value: Optional[str] = None, - disabled: Optional[bool] = None, - readonly: Optional[bool] = None, - required: Optional[bool] = None, - placeholder: Optional[str] = None, - autofocus: Optional[bool] = None, + id: str | None = None, + name: str | None = None, + value: str | None = None, + disabled: bool | None = None, + readonly: bool | None = None, + required: bool | None = None, + placeholder: str | None = None, + autofocus: bool | None = None, **attributes: AttributeType, ) -> None: ... @@ -478,15 +478,15 @@ def __call__( self, *options: RenderOptions, type: Literal["file"] = "file", - id: Optional[str] = None, - name: Optional[str] = None, - value: Optional[str] = None, - required: Optional[bool] = None, - accept: Optional[str] = None, - multiple: Optional[bool] = None, - disabled: Optional[bool] = None, - readonly: Optional[bool] = None, - autofocus: Optional[bool] = None, + id: str | None = None, + name: str | None = None, + value: str | None = None, + required: bool | None = None, + accept: str | None = None, + multiple: bool | None = None, + disabled: bool | None = None, + readonly: bool | None = None, + autofocus: bool | None = None, **attributes: AttributeType, ) -> None: ... @@ -496,16 +496,16 @@ def __call__( self, *options: RenderOptions, type: Literal["number"] = "number", - id: Optional[str] = None, - name: Optional[str] = None, - value: Optional[str] = None, - required: Optional[bool] = None, - disabled: Optional[bool] = None, - readonly: Optional[bool] = None, - min: Optional[str] = None, - max: Optional[str] = None, - placeholder: Optional[str] = None, - autofocus: Optional[bool] = None, + id: str | None = None, + name: str | None = None, + value: str | None = None, + required: bool | None = None, + disabled: bool | None = None, + readonly: bool | None = None, + min: str | None = None, + max: str | None = None, + placeholder: str | None = None, + autofocus: bool | None = None, **attributes: AttributeType, ) -> None: ... @@ -515,14 +515,14 @@ def __call__( self, *options: RenderOptions, type: Literal["password"] = "password", - id: Optional[str] = None, - name: Optional[str] = None, - value: Optional[str] = None, - disabled: Optional[bool] = None, - readonly: Optional[bool] = None, - required: Optional[bool] = None, - placeholder: Optional[str] = None, - autofocus: Optional[bool] = None, + id: str | None = None, + name: str | None = None, + value: str | None = None, + disabled: bool | None = None, + readonly: bool | None = None, + required: bool | None = None, + placeholder: str | None = None, + autofocus: bool | None = None, **attributes: AttributeType, ) -> None: ... @@ -532,14 +532,14 @@ def __call__( self, *options: RenderOptions, type: Literal["radio"] = "radio", - id: Optional[str] = None, - name: Optional[str] = None, - value: Optional[str] = None, - checked: Optional[bool] = None, - disabled: Optional[bool] = None, - readonly: Optional[bool] = None, - required: Optional[bool] = None, - autofocus: Optional[bool] = None, + id: str | None = None, + name: str | None = None, + value: str | None = None, + checked: bool | None = None, + disabled: bool | None = None, + readonly: bool | None = None, + required: bool | None = None, + autofocus: bool | None = None, **attributes: AttributeType, ) -> None: ... @@ -549,17 +549,17 @@ def __call__( self, *options: RenderOptions, type: Literal["range"] = "range", - id: Optional[str] = None, - name: Optional[str] = None, - value: Optional[str] = None, - required: Optional[bool] = None, - min: Optional[str] = None, - max: Optional[str] = None, - step: Optional[str] = None, - placeholder: Optional[str] = None, - disabled: Optional[bool] = None, - readonly: Optional[bool] = None, - autofocus: Optional[bool] = None, + id: str | None = None, + name: str | None = None, + value: str | None = None, + required: bool | None = None, + min: str | None = None, + max: str | None = None, + step: str | None = None, + placeholder: str | None = None, + disabled: bool | None = None, + readonly: bool | None = None, + autofocus: bool | None = None, **attributes: AttributeType, ) -> None: ... @@ -568,15 +568,15 @@ def __call__( def __call__( self, *options: RenderOptions, - type: Optional[InputTypes] = None, - id: Optional[str] = None, - name: Optional[str] = None, - value: Optional[str] = None, - placeholder: Optional[str] = None, - disabled: Optional[bool] = None, - readonly: Optional[bool] = None, - required: Optional[bool] = None, - autofocus: Optional[bool] = None, + type: InputTypes | None = None, + id: str | None = None, + name: str | None = None, + value: str | None = None, + placeholder: str | None = None, + disabled: bool | None = None, + readonly: bool | None = None, + required: bool | None = None, + autofocus: bool | None = None, **attributes: AttributeType, ) -> None: ... @@ -585,25 +585,25 @@ def __call__( def __call__( self, *options: RenderOptions, - type: Optional[str] = None, - id: Optional[str] = None, - name: Optional[str] = None, - value: Optional[str] = None, - placeholder: Optional[str] = None, - disabled: Optional[bool] = None, - readonly: Optional[bool] = None, - required: Optional[bool] = None, - autofocus: Optional[bool] = None, + type: str | None = None, + id: str | None = None, + name: str | None = None, + value: str | None = None, + placeholder: str | None = None, + disabled: bool | None = None, + readonly: bool | None = None, + required: bool | None = None, + autofocus: bool | None = None, **attributes: AttributeType, ) -> None: ... def __call__( # type: ignore self, *options: RenderOptions, - type: Optional[str] = None, - id: Optional[str] = None, - name: Optional[str] = None, - value: Optional[str] = None, + type: str | None = None, + id: str | None = None, + name: str | None = None, + value: str | None = None, **attributes: AttributeType, ): """ diff --git a/pyhtml/__types.py b/pyhtml/__types.py index ca01ba0..55f0338 100644 --- a/pyhtml/__types.py +++ b/pyhtml/__types.py @@ -12,7 +12,7 @@ from .__tag_base import Tag -AttributeType = Union[str, bool, None] +AttributeType = str | bool | None """ Objects that are valid values for tag attributes diff --git a/pyhtml/__util.py b/pyhtml/__util.py index c2a02d9..5974d5a 100644 --- a/pyhtml/__util.py +++ b/pyhtml/__util.py @@ -176,7 +176,7 @@ def flatten_children( result: list[ChildElementType] = [] options = RenderOptions() for item in the_list: - if isinstance(item, (list, Generator)): + if isinstance(item, list | Generator): result.extend(item) elif isinstance(item, str): result.append(item) diff --git a/pyproject.toml b/pyproject.toml index fb2dbad..8b70f2e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,17 +1,12 @@ -[tool.poetry] +[project] name = "pyhtml-enhanced" version = "2.2.0" description = "A library for building HTML documents with a simple and learnable syntax" -authors = ["Maddy Guthridge "] -license = "MIT" readme = "README.md" -packages = [{ include = "pyhtml" }] - -repository = "https://github.com/COMP1010UNSW/pyhtml-enhanced" -documentation = "https://comp1010unsw.github.io/pyhtml-enhanced/" +license = "MIT" +authors = [{ name = "Maddy Guthridge", email = "maddy.guthridge@unsw.edu.au" }] keywords = ['html', 'template', 'pyhtml', 'markup', 'documentation'] - classifiers = [ "Programming Language :: Python :: 3", "Intended Audience :: Developers", @@ -23,11 +18,39 @@ classifiers = [ "Typing :: Typed", ] -include = ["py.typed"] +requires-python = ">=3.10" -[tool.poetry.urls] +[project.urls] +homepage = "https://comp1010unsw.github.io/pyhtml-enhanced/" +repository = "https://github.com/COMP1010UNSW/pyhtml-enhanced" +documentation = "https://comp1010unsw.github.io/pyhtml-enhanced/" "Bug Tracker" = "https://github.com/COMP1010UNSW/pyhtml-enhanced/issues" +[tool.poetry] +include = ["py.typed"] +packages = [{ include = "pyhtml" }] + +[tool.poetry.group.dev.dependencies] +pytest = ">=7.4.2,<9.0.0" +mypy = "^1.5.1" +autopep8 = "^2.0.4" +coverage = "^7.3.1" +requests = "^2.31.0" +types-requests = "^2.31.0.2" +pyyaml = "^6.0.1" +types-pyyaml = "^6.0.12.11" +flask = "^3.0.0" +pytest-mypy-plugins = "^3.0.0" +ruff = "^0.9.4" + + +[tool.poetry.group.docs.dependencies] +mkdocs = "^1.6.1" +mkdocs-material = "^9.5.34" +mkdocstrings = { version = ">=0.26,<0.28", extras = ["python"] } +mkdocs-awesome-pages-plugin = "^2.9.3" +mkdocs-section-index = "^0.3.9" + [tool.mypy] check_untyped_defs = true files = ["pyhtml", "tests", "meta"] @@ -78,30 +101,6 @@ exclude_also = [ 'raise NotImplementedError', ] -[tool.poetry.dependencies] -python = "^3.10" - -[tool.poetry.group.dev.dependencies] -pytest = ">=7.4.2,<9.0.0" -mypy = "^1.5.1" -autopep8 = "^2.0.4" -coverage = "^7.3.1" -requests = "^2.31.0" -types-requests = "^2.31.0.2" -pyyaml = "^6.0.1" -types-pyyaml = "^6.0.12.11" -flask = "^3.0.0" -pytest-mypy-plugins = "^3.0.0" -ruff = "^0.9.4" - - -[tool.poetry.group.docs.dependencies] -mkdocs = "^1.6.1" -mkdocs-material = "^9.5.34" -mkdocstrings = { version = ">=0.26,<0.28", extras = ["python"] } -mkdocs-awesome-pages-plugin = "^2.9.3" -mkdocs-section-index = "^0.3.9" - [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" diff --git a/tests/code_gen_test.py b/tests/code_gen_test.py index 43bcdef..3b70119 100644 --- a/tests/code_gen_test.py +++ b/tests/code_gen_test.py @@ -21,7 +21,7 @@ # That are a kind of Tag and issubclass(getattr(pyhtml, i), Tag) # And aren't a PyHTML feature (since comments require named args) - and not issubclass(getattr(pyhtml, i), (Comment, DangerousRawHtml)) + and not issubclass(getattr(pyhtml, i), Comment | DangerousRawHtml) # And isn't since it has pre-content and not issubclass(getattr(pyhtml, i), html) )