generated from yanyongyu/python-poetry-template
-
-
Notifications
You must be signed in to change notification settings - Fork 37
Closed
Labels
Description
githubkitversion: 0.11.13pydanticversion: 2.9.2
Reproduction Code:
import asyncio
import githubkit
import githubkit.versions.latest.models as m
from icecream import ic
async def main() -> None:
gh: githubkit.GitHub = githubkit.GitHub(githubkit.ActionAuthStrategy())
resp = await gh.rest.repos.async_get_release_by_tag(
"liblaf", "hello-githubkit", "test"
)
release: m.Release = resp.parsed_data
resp = await gh.rest.repos.async_upload_release_asset(
"liblaf", "hello-githubkit", release.id, name="test.txt", data=b"Hello, world!"
)
ic(resp.parsed_data)
if __name__ == "__main__":
asyncio.run(main())Error:
Traceback (most recent call last):
File "**/.venv/lib/python3.12/site-packages/pydantic/type_adapter.py", line 270, in _init_core_attrs
self._core_schema = _getattr_no_parents(self._type, '__pydantic_core_schema__')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "**/.venv/lib/python3.12/site-packages/pydantic/type_adapter.py", line 112, in _getattr_no_parents
raise AttributeError(attribute)
AttributeError: __pydantic_core_schema__
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "**/hello.py", line 21, in <module>
asyncio.run(main())
File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "**/hello.py", line 14, in main
resp = await gh.rest.repos.async_upload_release_asset(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "**/.venv/lib/python3.12/site-packages/githubkit/versions/v2022_11_28/rest/repos.py", line 13894, in async_upload_release_asset
content = type_validate_python(FileTypes, content)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "**/.venv/lib/python3.12/site-packages/githubkit/compat.py", line 48, in type_validate_python
return TypeAdapter(type_).validate_python(data)
^^^^^^^^^^^^^^^^^^
File "**/.venv/lib/python3.12/site-packages/pydantic/type_adapter.py", line 257, in __init__
self._init_core_attrs(rebuild_mocks=False)
File "**/.venv/lib/python3.12/site-packages/pydantic/type_adapter.py", line 135, in wrapped
return func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "**/.venv/lib/python3.12/site-packages/pydantic/type_adapter.py", line 277, in _init_core_attrs
self._core_schema = _get_schema(self._type, config_wrapper, parent_depth=self._parent_depth)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "**/.venv/lib/python3.12/site-packages/pydantic/type_adapter.py", line 95, in _get_schema
schema = gen.generate_schema(type_)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "**/.venv/lib/python3.12/site-packages/pydantic/_internal/_generate_schema.py", line 655, in generate_schema
schema = self._generate_schema_inner(obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "**/.venv/lib/python3.12/site-packages/pydantic/_internal/_generate_schema.py", line 929, in _generate_schema_inner
return self.match_type(obj)
^^^^^^^^^^^^^^^^^^^^
File "**/.venv/lib/python3.12/site-packages/pydantic/_internal/_generate_schema.py", line 1029, in match_type
return self._match_generic_type(obj, origin)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "**/.venv/lib/python3.12/site-packages/pydantic/_internal/_generate_schema.py", line 1058, in _match_generic_type
return self._union_schema(obj)
^^^^^^^^^^^^^^^^^^^^^^^
File "**/.venv/lib/python3.12/site-packages/pydantic/_internal/_generate_schema.py", line 1378, in _union_schema
choices.append(self.generate_schema(arg))
^^^^^^^^^^^^^^^^^^^^^^^^^
File "**/.venv/lib/python3.12/site-packages/pydantic/_internal/_generate_schema.py", line 655, in generate_schema
schema = self._generate_schema_inner(obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "**/.venv/lib/python3.12/site-packages/pydantic/_internal/_generate_schema.py", line 929, in _generate_schema_inner
return self.match_type(obj)
^^^^^^^^^^^^^^^^^^^^
File "**/.venv/lib/python3.12/site-packages/pydantic/_internal/_generate_schema.py", line 1029, in match_type
return self._match_generic_type(obj, origin)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "**/.venv/lib/python3.12/site-packages/pydantic/_internal/_generate_schema.py", line 1087, in _match_generic_type
return self._unknown_type_schema(obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "**/.venv/lib/python3.12/site-packages/pydantic/_internal/_generate_schema.py", line 558, in _unknown_type_schema
raise PydanticSchemaGenerationError(
pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for typing.IO[bytes]. Set `arbitrary_types_allowed=True` in the model_config to ignore this error or implement `__get_pydantic_core_schema__` on your type to fully support it.
If you got this error by calling handler(<some type>) within `__get_pydantic_core_schema__` then you likely need to call `handler.generate_schema(<some type>)` since we do not call `__get_pydantic_core_schema__` on `<some type>` otherwise to avoid infinite recursion.
For further information visit https://errors.pydantic.dev/2.9/u/schema-for-unknown-type