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

Adjust imports for Python 3.11 #1140

Merged
merged 2 commits into from
May 23, 2022
Merged

Conversation

The-Compiler
Copy link
Contributor

sre_parse and sre_constants are deprecated in 3.11, see python/cpython#91308

This fixes a DeprecationWarning when running python3 -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.

sre_parse and sre_constants are deprecated in 3.11, see python/cpython#91308
The-Compiler added a commit to The-Compiler/hypothesis that referenced this pull request Apr 26, 2022
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
Copy link
Contributor

@henryiii henryiii May 23, 2022

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.

Copy link
Member

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

Copy link
Contributor Author

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).

Copy link
Contributor

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.

@erezsh erezsh merged commit d6ad13a into lark-parser:master May 23, 2022
@erezsh
Copy link
Member

erezsh commented May 23, 2022

Thanks for contributing!

@Zac-HD
Copy link
Contributor

Zac-HD commented Sep 5, 2022

Any timeline on a release? As far as I can tell this is the last thing stopping me from testing with -Werror on Python 3.11.

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 this pull request may close these issues.

4 participants