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

Reflect AST changes in Python 3.8. #616

Merged
merged 1 commit into from Sep 30, 2018

Conversation

serhiy-storchaka
Copy link
Contributor

@serhiy-storchaka serhiy-storchaka commented Sep 29, 2018

Steps

  • Add a ChangeLog entry describing what your PR does
  • Write a good description on what the PR does

Description

There will be several changes in AST in Python 3.8.

  • ast.Num, ast.Str, ast.Bytes, ast.Ellipsis and ast.NameConstant are replaced with ast.Constant.
    (https://bugs.python.org/issue32892)

    ast.Constant can be used since Python 3.6, it is just that ast.parse() didn't produce it.

    This PR adds a handler for ast.Constant in TreeRebuilder.

  • Simplified AST for subscriptions. ast.Index is replaced with its value, ast.ExtSlice is replaced with ast.Tuple.
    (https://bugs.python.org/issue34822)

    This change is not merged yet.

    Since the code like a[(::1, 1:)] is invalid syntax, tuples should be handled specially in as_string() when used as indices in subscription. As side effect, a comma with a space instead of a just comma is now used for separating slices in the as_string() output.

Type of Changes

Type
🐛 Bug fix

Closes #617.

* Num, Str, Bytes, Ellipsis and NameConstant are replaced with Constant.
  (https://bugs.python.org/issue32892)

* Index is replaced with its value, ExtSlice is replaced with Tuple.
  (https://bugs.python.org/issue34822)
@PCManticore
Copy link
Contributor

Thank you so much @serhiy-storchaka ! This is super useful.

@PCManticore PCManticore merged commit 3746acc into pylint-dev:master Sep 30, 2018
@serhiy-storchaka serhiy-storchaka deleted the ast-py38 branch October 4, 2018 07:39
hadisfr added a commit to hadisfr/clara that referenced this pull request Jul 14, 2020
due to deprecating `ast.Num`, `ast.Str`, `ast.Bytes`, `ast.Ellipsis` and `ast.NameConstant` in favour of `ast.Constant` in python3.8
ref: pylint-dev/astroid#616
ref: https://bugs.python.org/issue32892#msg342486
iradicek pushed a commit to iradicek/clara that referenced this pull request Nov 11, 2020
* add more files to .gitignore

* add clusters folder to .gitignore

* add more description into "NotSupported: Unimplemented visitor" exception message

* fix an issue with python3.8+

due to deprecating `ast.Num`, `ast.Str`, `ast.Bytes`, `ast.Ellipsis` and `ast.NameConstant` in favour of `ast.Constant` in python3.8
ref: pylint-dev/astroid#616
ref: https://bugs.python.org/issue32892#msg342486

* make .gitignore minimal

ref #19 (review)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants