-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
issue#6305 Replace deprecated ast.NameConstant usage and add tests #6306
base: master
Are you sure you want to change the base?
Conversation
@@ -2,6 +2,7 @@ | |||
import warnings | |||
from functools import partial | |||
from unittest import mock | |||
import ast |
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.
It shouldn't be used in tests directly.
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.
Hiya! Good call out -- I amended my commit to use magic mock. Let me know what you think. Cheers.
@@ -12,6 +12,13 @@ | |||
def _indentation_error(*args, **kwargs): | |||
raise IndentationError() | |||
|
|||
def create_ast_return(value=None): | |||
return ( | |||
unittest.mock.MagicMock(name='ast.Return', value=None) |
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.
Hmm my point is that I expect this test to test real code that produces specific ast nodes when parsed.
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.
(hpefully that makes sense)
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.
Yes, that makes sense. I will push a new change tomorrow. Thank you for the feedback!
Replaced ast.NameConstant with ast.Constant in response to issue#6305 Replace deprecated ast.NameConstant usage and add tests scrapy#6306.
Problem
Within
misc.py
there is a usage ofast.NameConstant
.ast.NameConstant
will be deprecated beginning with Python 3.14.x so we want to remove it.Solution
ast.NameConstant
withast.Constant
withinmisc.py
ast.Constant
with a value, or with aNone
valueValidation
Fixes #6305