-
-
Notifications
You must be signed in to change notification settings - Fork 406
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
Adjust imports for Python 3.11 #1140
Conversation
sre_parse and sre_constants are deprecated in 3.11, see python/cpython#91308
Mostly due to old Pandas versions: pandas-dev/pandas#41199 pandas-dev/pandas#32056 pandas-dev/pandas#34848 In one instance, also due to Lark using sre_* modules: lark-parser/lark#1140 Those filters could also be set to `ignore` to not show the warnings at all. This sets them to `default`, restoring the previous behavior of showing the warnings but not failing the test run. Perhaps it might make sense to use older Numpy versions for testing the older Pandas versions too?
lark/utils.py
Outdated
@@ -113,8 +113,13 @@ def deserialize(cls, data, namespace, memo): | |||
except ImportError: | |||
regex = None | |||
|
|||
import sre_parse | |||
import sre_constants | |||
try: # Python 3.11 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend using sys.version_info >= (3, 11)
or similar instead of try
on import
, it serves as documentation to the user, it enables the workaround to be dropped when that version of Python is dropped, and it can be used by static analysis tools like mypy and pyupgrade.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You make a good point, thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjusted accordingly. Also has its downsides, though (it will break now with Python 3.11 before alpha 7, and there isn't a very straightforward way to check for that).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, though older alpha / beta / rcs are not worth supporting after a new one comes out. Especially alphas once a beta is out. They are essentially just development snapshots.
Build 0.8.0 doesn’t support alpha 6 either.
Thanks for contributing! |
Any timeline on a release? As far as I can tell this is the last thing stopping me from testing with |
sre_parse and sre_constants are deprecated in 3.11, see python/cpython#91308
This fixes a
DeprecationWarning
when runningpython3 -Wall -c "import lark"
with Python 3.11.0a7.I couldn't run the tests on Python 3.11 due to PiotrDabkowski/Js2Py#282, but it looks like at least lark works without deprecation warnings with this change.