Skip to content

TypeError: unhashable type: 'list' with pydantic version <2.5.2 #58

Closed
@mattibo

Description

@mattibo

when i run this code i get an TypeError after i upgraded to pydantic version 2.5:

from githubkit import GitHub

with GitHub() as github:
    resp = github.rest.repos.get(owner="yanyongyu", repo="githubkit")
    repo = resp.parsed_data

following error is raised:

Traceback (most recent call last):
  File "githubkit\test.py", line 5, in <module>
    repo = resp.parsed_data
           ^^^^^^^^^^^^^^^^
  File "githubkit\githubkit\response.py", line 50, in parsed_data
    return TypeAdapter(self._data_model).validate_json(self.content)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "githubkit\venv\Lib\site-packages\pydantic\type_adapter.py", line 256, in validate_json
    return self.validator.validate_json(__data, strict=strict, context=context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: unhashable type: 'list'

maybe this has something todo with the new json parsing library pydantic hast introduced with version 2.5: https://docs.pydantic.dev/2.5/concepts/json/#json-parsing

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions