Closed DimitriPapadopoulos closed 1 year ago
This piece of code fails with pydantic 2.0a1: https://github.com/bids-standard/stats-models/blob/da7aa019df9689a142cbe2142f22dba486ade949/bsmschema/bsmschema/models.py#L79
Easily reproduced with:
from typing import Literal, Union
from pydantic import StrictStr
VariableList = Union[Literal[1], StrictStr]
The error is:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.10/typing.py", line 312, in inner
return func(*args, **kwds)
File "/usr/lib/python3.10/typing.py", line 403, in __getitem__
return self._getitem(self, parameters)
File "/usr/lib/python3.10/typing.py", line 516, in Union
parameters = _remove_dups_flatten(parameters)
File "/usr/lib/python3.10/typing.py", line 281, in _remove_dups_flatten
return tuple(_deduplicate(params))
File "/usr/lib/python3.10/typing.py", line 255, in _deduplicate
all_params = set(params)
File "/usr/lib/python3.10/typing.py", line 1651, in __hash__
return hash((self.__origin__, self.__metadata__))
TypeError: unhashable type: 'Strict'
Please consider https://github.com/DimitriPapadopoulos/stats-models/pull/1 addition to this PR ;)
By the way, we would need a formal release of bsmschema
to fix CI:
Collecting bsmschema
Downloading bsmschema-0.0.3-py3-none-any.whl (8.8 kB)
Collecting pydantic
Downloading pydantic-2.0a1-py3-none-any.whl (172 kB)
Yup. Doing a little prep work in #78.
Apart from these minor changes, the real intent is to pull recent dependencies such as pydantic 2.0a1 released yesterday – which might break CI, here or in packages that depend on
bsmschema
(https://github.com/bids-standard/pybids/pull/972).Might need to (temporarily) pin pydantic to versions pre-2.0a1 here: https://github.com/bids-standard/stats-models/blob/da7aa019df9689a142cbe2142f22dba486ade949/bsmschema/setup.cfg#L20-L21