htmy 0.3.1__py3-none-any.whl → 0.3.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
htmy/__init__.py CHANGED
@@ -28,6 +28,7 @@ from .typing import ContextProvider as ContextProvider
28
28
  from .typing import ContextValue as ContextValue
29
29
  from .typing import FunctionComponent as FunctionComponent
30
30
  from .typing import HTMYComponentType as HTMYComponentType
31
+ from .typing import MutableContext as MutableContext
31
32
  from .typing import Properties as Properties
32
33
  from .typing import PropertyValue as PropertyValue
33
34
  from .typing import SyncComponent as SyncComponent
htmy/core.py CHANGED
@@ -5,7 +5,7 @@ import asyncio
5
5
  import enum
6
6
  from collections.abc import Callable, Container
7
7
  from pathlib import Path
8
- from typing import Any, ClassVar, Generic, Self, TypedDict, cast, overload
8
+ from typing import TYPE_CHECKING, Any, ClassVar, Generic, TypedDict, cast, overload
9
9
  from xml.sax.saxutils import escape as xml_escape
10
10
 
11
11
  from .io import open_file
@@ -24,6 +24,11 @@ from .typing import (
24
24
  )
25
25
  from .utils import join_components
26
26
 
27
+ if TYPE_CHECKING:
28
+ from typing_extensions import Self
29
+ else:
30
+ Self = Any
31
+
27
32
  # -- Utility components
28
33
 
29
34
 
@@ -238,7 +243,7 @@ class ContextAware:
238
243
  if isinstance(result, cls):
239
244
  return result
240
245
 
241
- raise TypeError("Incorrectly context data type.")
246
+ raise TypeError(f"Invalid context data type for {cls.__name__}.")
242
247
 
243
248
 
244
249
  # -- Function components
htmy/md/typing.py CHANGED
@@ -1,8 +1,13 @@
1
1
  from collections.abc import Callable
2
- from typing import Any, NotRequired, TypeAlias, TypedDict
2
+ from typing import TYPE_CHECKING, Any, TypeAlias, TypedDict
3
3
 
4
4
  from htmy.typing import Component
5
5
 
6
+ if TYPE_CHECKING:
7
+ from typing_extensions import NotRequired
8
+ else:
9
+ from typing import Optional as NotRequired
10
+
6
11
  MarkdownMetadataDict: TypeAlias = dict[str, Any]
7
12
 
8
13
 
htmy/typing.py CHANGED
@@ -1,4 +1,4 @@
1
- from collections.abc import Callable, Coroutine, Mapping
1
+ from collections.abc import Callable, Coroutine, Mapping, MutableMapping
2
2
  from typing import Any, Protocol, TypeAlias, TypeGuard, TypeVar, runtime_checkable
3
3
 
4
4
  T = TypeVar("T")
@@ -23,6 +23,14 @@ ContextValue: TypeAlias = Any
23
23
  Context: TypeAlias = Mapping[ContextKey, ContextValue]
24
24
  """Context mapping."""
25
25
 
26
+ MutableContext: TypeAlias = MutableMapping[ContextKey, ContextValue]
27
+ """
28
+ Mutable context mapping.
29
+
30
+ It can be helpful when the created context should be marked as mutable for static type analysis
31
+ (usually the created context is a plain `dict`).
32
+ """
33
+
26
34
  # -- Components
27
35
 
28
36
 
@@ -1,13 +1,14 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: htmy
3
- Version: 0.3.1
3
+ Version: 0.3.3
4
4
  Summary: Async, pure-Python rendering engine.
5
5
  License: MIT
6
6
  Author: Peter Volf
7
7
  Author-email: do.volfp@gmail.com
8
- Requires-Python: >=3.11,<4.0
8
+ Requires-Python: >=3.10,<4.0
9
9
  Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.10
11
12
  Classifier: Programming Language :: Python :: 3.11
12
13
  Classifier: Programming Language :: Python :: 3.12
13
14
  Classifier: Programming Language :: Python :: 3.13
@@ -1,17 +1,17 @@
1
- htmy/__init__.py,sha256=_hffMH5lgK2E8cV62Fr90dF2fjfdjM5WMPgWMe9EP4M,1782
2
- htmy/core.py,sha256=9BvzVMc3ZL94It6Yw4qxodbxLvw_PolJO1uzzxW4Rbo,18562
1
+ htmy/__init__.py,sha256=My_Dmh9JNQpQekTO6CEbdbV7Ux7MD9Pz-L2M3KMZjGQ,1835
2
+ htmy/core.py,sha256=6_mFrJ1GdMQv3lrIgUWa0-41NhSKGtgwrXrxYr7BHQY,18666
3
3
  htmy/etree.py,sha256=zZkKY82t5fX85unS9oHuG6KEBsJY_iz6E7SJto8lSVQ,3097
4
4
  htmy/html.py,sha256=pxmE-KU5OgwNp6MyxOfdS0Ohpzu2RNYCeGGFlHLDGUM,20940
5
5
  htmy/i18n.py,sha256=brNazQjObBFfbnViZCpcnxa0qgxQbJfX7xJAH-MqTW8,5124
6
6
  htmy/io.py,sha256=iebJOZp7L0kZ9SWdqMatKtW5VGRIkEd-eD0_vTAldH8,41
7
7
  htmy/md/__init__.py,sha256=lxBJnYplkDuxYuiese6My9KYp1DeGdzo70iUdYTvMnE,334
8
8
  htmy/md/core.py,sha256=-EKucDFKMUtGgs9k_q9134oXY2GXtdKX1KOJXG4YmKc,3342
9
- htmy/md/typing.py,sha256=LbsoAJ8OnZod9UbFiNVvWAEyFDqGRKhGmRpLWqbi8VY,642
9
+ htmy/md/typing.py,sha256=LF-AEvo7FCW2KumyR5l55rsXizV2E4AHVLKFf6lApgM,762
10
10
  htmy/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  htmy/renderer.py,sha256=vIY-_IFonctEHgl6kOL3586Peve2Lz7Ly8jpf9WOlqQ,3706
12
- htmy/typing.py,sha256=QdqbObdnrVvHjIpVlEH4ylZtvZCuOYU9XygF3oI1IQ8,2672
12
+ htmy/typing.py,sha256=iUZQjMU-DHMV1Mv-ugW26eSPlrFO-KVhWfkLod7dig4,2937
13
13
  htmy/utils.py,sha256=7_CyA39l2m6jzDqparPKkKgRB2wiGuBZXbiPgiZOXKA,1093
14
- htmy-0.3.1.dist-info/LICENSE,sha256=rFtoGU_3c_rlacXgOZapTHfMErN-JFPT5Bq_col4bqI,1067
15
- htmy-0.3.1.dist-info/METADATA,sha256=hNSmkwmwBGr0xfVSrOsp6BPfNZ-kCX6m0gGN5I7WqSo,16210
16
- htmy-0.3.1.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
17
- htmy-0.3.1.dist-info/RECORD,,
14
+ htmy-0.3.3.dist-info/LICENSE,sha256=rFtoGU_3c_rlacXgOZapTHfMErN-JFPT5Bq_col4bqI,1067
15
+ htmy-0.3.3.dist-info/METADATA,sha256=MPbERjyHqKdhtcWZyM2rUeHHwTL3uzfY-O5zUB1IjBY,16261
16
+ htmy-0.3.3.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
17
+ htmy-0.3.3.dist-info/RECORD,,
File without changes
File without changes