-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
Added Django 4.2+ fixer for “Set” assert
methods
#253
Conversation
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.
Thansk for the PR, yes I'll delay merging it until after Django 4.2 is in RC
@fixer.register(ast.Attribute) | ||
def visit_Attribute( | ||
state: State, | ||
node: ast.Attribute, | ||
parents: list[ast.AST], | ||
) -> Iterable[tuple[Offset, TokenFunc]]: | ||
if ( | ||
(name := node.attr) in NAMES | ||
and isinstance(node.value, ast.Name) | ||
and node.value.id == "self" | ||
): | ||
yield ast_start_offset(node), partial( | ||
find_and_replace_name, name=name, new=NAMES[name] | ||
) |
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.
can we instead check for ast.Call
nodes that have an ast.Attribute
as their func
? This would be slightly more precise, which is good for avoiding false positives.
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.
@adamchainz I changed my code according to your suggestion, see 0bc330e. Do you think it is okay now?
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.
Yeah looks good! Now we just need to wait for the Django 4.2 RC1.
We'll also need to add 4.2 as an allowed target version, if you want to add that in this PR:
django-upgrade/src/django_upgrade/main.py
Lines 26 to 44 in 4dba611
parser.add_argument( | |
"--target-version", | |
default="2.2", | |
choices=[ | |
"1.7", | |
"1.8", | |
"1.9", | |
"1.10", | |
"1.11", | |
"2.0", | |
"2.1", | |
"2.2", | |
"3.0", | |
"3.1", | |
"3.2", | |
"4.0", | |
"4.1", | |
], | |
) |
Done in 3ba65c4. |
Great, now we play the waiting game. |
3ba65c4
to
3ef8bd7
Compare
I said "RC" but Django 4.2 alpha 1 is out, and that's a good time to merge and release I think. People can start their test branches and run django-upgrade to clear this deprecation warning. |
assertFormsetError
and assertQuerysetEqual
.assert
methods
Fixes #252.