pydata / patsy

Describing statistical models in Python using symbolic formulas
Other
955 stars 104 forks source link

Importing `patsy.eval` fails on Python 3.11 #186

Closed musicinmybrain closed 2 years ago

musicinmybrain commented 2 years ago

Because the annotations feature was postponed indefinitely, __future__.annotations.getMandatoryRelease() returns None in Python 3.11, which means a planned feature got dropped.

As a result, importing patsy.eval fails with a traceback like:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/ben/src/forks/patsy/patsy/__init__.py", line 77, in <module>
    import patsy.highlevel
  File "/home/ben/src/forks/patsy/patsy/highlevel.py", line 19, in <module>
    from patsy.design_info import DesignMatrix, DesignInfo
  File "/home/ben/src/forks/patsy/patsy/design_info.py", line 38, in <module>
    from patsy.desc import ModelDesc, Term
  File "/home/ben/src/forks/patsy/patsy/desc.py", line 14, in <module>
    from patsy.eval import EvalEnvironment, EvalFactor
  File "/home/ben/src/forks/patsy/patsy/eval.py", line 36, in <module>
    _ALL_FUTURE_FLAGS = _all_future_flags()
                        ^^^^^^^^^^^^^^^^^^^
  File "/home/ben/src/forks/patsy/patsy/eval.py", line 32, in _all_future_flags
    if feature.getMandatoryRelease() > sys.version_info:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: '>' not supported between instances of 'NoneType' and 'sys.version_info'

PR to follow.