Skip to content

Fix AST deprecation warnings#1242

Merged
larsoner merged 1 commit intosphinx-gallery:masterfrom
QuLogic:fix-warnings
Dec 15, 2023
Merged

Fix AST deprecation warnings#1242
larsoner merged 1 commit intosphinx-gallery:masterfrom
QuLogic:fix-warnings

Conversation

@QuLogic
Copy link
Copy Markdown
Contributor

@QuLogic QuLogic commented Dec 15, 2023

This fixes the following warnings:

.../sphinx_gallery/py_source_parser.py:101: DeprecationWarning: ast.Str is
  deprecated and will be removed in Python 3.14; use ast.Constant
  instead
    and isinstance(node.body[0].value, ast.Str)

.../sphinx_gallery/py_source_parser.py:113: DeprecationWarning:
  Attribute s is deprecated and will be removed in Python 3.14; use
  value instead
    if len(node.body[0].value.s) and node.body[0].value.s[0] == "\n":

ast.Str was deprecated in 3.8 (and returned an ast.Constant anyway), which is the minimum requirement here. I can't find s or value, so I'm not sure when they were deprecated exactly.

This fixes the following warnings:
```
.../sphinx_gallery/py_source_parser.py:101: DeprecationWarning: ast.Str is
  deprecated and will be removed in Python 3.14; use ast.Constant
  instead
    and isinstance(node.body[0].value, ast.Str)

.../sphinx_gallery/py_source_parser.py:113: DeprecationWarning:
  Attribute s is deprecated and will be removed in Python 3.14; use
  value instead
    if len(node.body[0].value.s) and node.body[0].value.s[0] == "\n":
```

`ast.Str` was deprecated in 3.8 (and returned an `ast.Constant` anyway),
which is the minimum requirement here. I can't find `s` or `value`, so
I'm not sure when they were deprecated exactly.
@larsoner larsoner merged commit a34b72c into sphinx-gallery:master Dec 15, 2023
@larsoner
Copy link
Copy Markdown
Contributor

Thanks @QuLogic !

@QuLogic QuLogic deleted the fix-warnings branch December 15, 2023 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants