Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing patsy.eval fails on Python 3.11 #186

Closed
musicinmybrain opened this issue Aug 2, 2022 · 0 comments · Fixed by #187
Closed

Importing patsy.eval fails on Python 3.11 #186

musicinmybrain opened this issue Aug 2, 2022 · 0 comments · Fixed by #187

Comments

@musicinmybrain
Copy link
Contributor

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.

musicinmybrain added a commit to musicinmybrain/patsy that referenced this issue Aug 2, 2022
Fixes pydata#186 by handling future features where the mandatory release
version is None, indicating the feature was dropped. These are now
included in patsy.eval._ALL_FUTURE_FLAGS rather than causing a
TypeError.

The first appearance of such a feature is in Python 3.11, in which
__future__.annotations.getMandatoryRelease() returns None.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant