dbrattli / OSlash

Functors, Applicatives, And Monads in Python
MIT License
708 stars 50 forks source link

3.12.2 python problem with Functor subclass check #35

Open banderlog opened 2 months ago

banderlog commented 2 months ago

Hi, the next error appears on python3.12.2:

 File "/venv/lib/python3.12/site-packages/oslash/_init_.py", line 11, in <module>
    from .state import State
  File "/venv/lib/python3.12/site-packages/oslash/state.py", line 78, in <module>
    assert issubclass(State, Functor)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/typing.py", line 1841, in _subclasscheck_
    cls._non_callable_proto_members_
AttributeError: type object 'Functor' has no attribute '_non_callable_proto_members_'

with 3.11 everything is fine

oslash-0.6.3 (latest)

banderlog commented 2 months ago

UPD: it is the problem of combination of python and typing-extensions

python-3.12 with typing-extensions>4.9.0 fails
python-3.10 and python-3.11 works fine with typing-extensions>=4.9.0

banderlog commented 2 months ago

https://github.com/python/typing_extensions/issues/372#issuecomment-2067787722

Thanks. This happens because you're mixing typing.Protocol with typing_extensions.runtime_checkable. If you either import both symbols from typing or both symbols from typing_extensions, the error goes away.

simonzg commented 2 months ago

I know I might be asking for too much, but do you have any timeline in mind to publish a fix soon? I'm experiencing this exact error and would like to get it fixed soon. Thanks in advance. @banderlog

banderlog commented 2 months ago

@simonzg https://github.com/dbrattli/OSlash/pull/36

or hardcode specific version typing-extensions==4.9.0 in requirements/toml file

also, typing-extensions now have 4.11 version, in which it might be fixed already