[Python] The Type Point in geojson_pydantic is not hashable

Discussão em 'Python' iniciado por Stack, Maio 30, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using Python 3.11 and I am struggling a lot to understand this.

    When I try to access to the Swagger documentation of my service, in localhost, I have this error:

    generate_definitions definitions_remapping = self._build_definitions_remapping()

    File \"/app/.venv/lib/python3.11/site-packages/pydantic/json_schema.py\", line 2129, in _build_definitions_remapping\n return _DefinitionsRemapping.from_prioritized_choices(

    File \"/app/.venv/lib/python3.11/site-packages/pydantic/json_schema.py\", line 177, in from_prioritized_choices\n schemas_for_alternatives[defs_ref] = _deduplicate_schemas(schemas_for_alternatives[defs_ref])

    File \"/app/.venv/lib/python3.11/site-packages/pydantic/json_schema.py\", line 2235, in _deduplicate_schemas\n return list({_make_json_hashable(schema): schema for schema in schemas}.values())

    File \"/app/.venv/lib/python3.11/site-packages/pydantic/json_schema.py\", line 2235, in <dictcomp>\n return list({_make_json_hashable(schema): schema for schema in schemas}.values())

    File \"/app/.venv/lib/python3.11/site-packages/pydantic/_internal/_model_construction.py\", line 429, in hash_func\n return hash(getter(self.__dict__))

    TypeError: unhashable type: 'Point'"


    so this TypeError: unhashable type: 'Point

    is the cause when generating Swagger docs.

    This is the screenshot when I try to read that docs page:

    [​IMG]

    so, the "Point" class comes from geojson_pydantic.

    I have to say that I had the same error in another class of my code, and I solved that error by writing:

    class Config:
    frozen = True


    so:

    class MyClass(BaseModel):
    class Config:
    frozen = True


    I can't understand how to identify the exact class or model that is not "hashable" and that is causing the swagger documentation to not to loading.

    the version of geojson_pydantic I am using is 1.2.0

    Any clue ?

    Continue reading...

Compartilhe esta Página