TGViewer
Находки в опенсорсе: Python Находки в опенсорсе: Python @opensource_findings_python · 1.06K subscribers
Post #231 556
🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Test and declare officail `NamedTuple` support (#774)


Here's the code:

>>> from typing import NamedTuple
>>> class A(NamedTuple):
... x: int
... y: int
...
>>> import pydantic
>>> pydantic.TypeAdapter(A).validate_python({'x': 1, 'y': 2})
A(x=1, y=2)
>>> pydantic.TypeAdapter(A).validate_python({'x': 1, 'y': 'a'})
Traceback (most recent call last):
File "<python-input-11>", line 1, in <module>
pydantic.TypeAdapter(A).validate_python({'x': 1, 'y': 'a'})
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
File "/Users/sobolev/Desktop/django-modern-rest/.venv/lib/python3.13/site-packages/pydantic/type_adapter.py", line 441, in validate_python
return self.validator.validate_python(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
object,
^^^^^^^
...<6 lines>...
by_name=by_name,
^^^^^^^^^^^^^^^^
)
^
pydantic_core._pydantic_core.ValidationError: 1 validation error for call[A]
y
Input should be a valid integer, unable to parse string as an integer [type=int_parsing, input_value='a', input_type=str]
For further information visit https://errors.pydantic.dev/2.12/v/int_parsing

As we can see, NamedTuple models work well with pydantic. So, here's what we need to do:

1. Add a test case to test_plugins/test_pydantic that it works with NamedTuple
2. Add a doc example here https://django-modern-rest.readthedocs.io/en/latest/pages/getting-started.html#showcase
3. Add a changelog entry, that it is now officially supported

We welcome new contributors :)


#enhancement #good_first_issue #help_wanted #django_modern_rest
sent via relator
  • 🔥 1
More from @opensource_findings_python
  1. Sep 24, 2026🚀 New issue to wemake-services/django-modern-rest by @sobolevn 📝 Flaky `test_empty_valid…
  2. Sep 24, 2026🚀 New issue to wemake-services/django-modern-rest by @sobolevn 📝 `CookieJWT[A]syncAuth`…
  3. Sep 23, 2026🚀 New issue to ag2ai/faststream by @IvanKirpichnikov 📝 Feature: Implementation of the `A…
  4. Sep 22, 2026🚀 New issue to faststream-community/zMQTT by @borisalekseev 📝 Mark flaky Artemis test xf…
  5. Sep 17, 2026Помните про https://github.com/ozeranskii/httptap? Я писал о нем давно еще - > тут. Наклеп…
  6. Sep 15, 2026🚀 New issue to wemake-services/django-modern-rest by @sobolevn 📝 `test_custom_union_form…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →