plugantic 0.2.0__tar.gz → 0.2.2__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plugantic
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Simplified extendable composition with pydantic
5
5
  Author-email: Martin Kunze <martin@martinkunze.com>
6
6
  Project-URL: Homepage, https://github.com/martinkunze/plugantic
@@ -316,7 +316,7 @@ uv build
316
316
  > 💡 This section is primarily relevant for the maintainers of this package (me), as it requires permission to push a package to the `plugantic` repository on PyPI.
317
317
 
318
318
  ```bash
319
- uv run publish --token <token>
319
+ uv publish --token <token>
320
320
  ```
321
321
 
322
322
  </details>
@@ -300,7 +300,7 @@ uv build
300
300
  > 💡 This section is primarily relevant for the maintainers of this package (me), as it requires permission to push a package to the `plugantic` repository on PyPI.
301
301
 
302
302
  ```bash
303
- uv run publish --token <token>
303
+ uv publish --token <token>
304
304
  ```
305
305
 
306
306
  </details>
@@ -1,2 +1,2 @@
1
1
  # Single source of truth for information needed at runtime and build-time (i.e. version)
2
- version = "0.2.0"
2
+ version = "0.2.2"
@@ -1,4 +1,4 @@
1
- from typing_extensions import ClassVar, Type, Self, Literal, Any, TypeVar, Set, Self, get_type_hints, get_origin, get_args
1
+ from typing_extensions import ClassVar, Type, Self, Literal, Any, TypeVar, Set, Self, get_type_hints, get_origin, get_args, TYPE_CHECKING
2
2
  from pydantic import BaseModel, GetCoreSchemaHandler, Field, ConfigDict, model_validator
3
3
  from pydantic.fields import FieldInfo
4
4
  from pydantic_core.core_schema import tagged_union_schema, union_schema
@@ -47,14 +47,15 @@ class PluginModel(BaseModel, metaclass=PluganticModelMeta):
47
47
 
48
48
  model_config: ClassVar[PluganticConfigDict] = PluganticConfigDict()
49
49
 
50
- def __init__(self, *args, **kwargs):
51
- declared_type = self._get_declared_type()
52
- if declared_type:
53
- kwargs = {
54
- self.__plugantic_varname_type__: declared_type,
55
- **kwargs
56
- }
57
- super().__init__(*args, **kwargs)
50
+ if not TYPE_CHECKING:
51
+ def __init__(self, *args, **kwargs):
52
+ declared_type = self._get_declared_type() # inject the default discriminator value if not provided
53
+ if declared_type:
54
+ kwargs = {
55
+ self.__plugantic_varname_type__: declared_type,
56
+ **kwargs
57
+ }
58
+ super().__init__(*args, **kwargs)
58
59
 
59
60
  def __init_subclass__(cls, *,
60
61
  varname_type: str|None=None,
@@ -138,7 +139,7 @@ class PluginModel(BaseModel, metaclass=PluganticModelMeta):
138
139
  annotation = None
139
140
  try:
140
141
  annotation = get_type_hints(cls).get(name, None)
141
- except NameError:
142
+ except (NameError, TypeError):
142
143
  pass
143
144
  if not annotation:
144
145
  field = cls.model_fields.get(name, None)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plugantic
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Simplified extendable composition with pydantic
5
5
  Author-email: Martin Kunze <martin@martinkunze.com>
6
6
  Project-URL: Homepage, https://github.com/martinkunze/plugantic
@@ -316,7 +316,7 @@ uv build
316
316
  > 💡 This section is primarily relevant for the maintainers of this package (me), as it requires permission to push a package to the `plugantic` repository on PyPI.
317
317
 
318
318
  ```bash
319
- uv run publish --token <token>
319
+ uv publish --token <token>
320
320
  ```
321
321
 
322
322
  </details>
File without changes
File without changes
File without changes