[flake8-datetime] Ignore .replace() calls while looking for .astimezone - #16050
Conversation
|
|
The second commit is just a rename. All substantial changes are isolated within the first. |
AlexWaygood
left a comment
There was a problem hiding this comment.
Thank you, this overall looks great. Nicely done!
Thank you for adding comments to the code; it made it easier to understand what was going on. It still took me some time to figure out what was going on here, though. I almost wonder if it's worth adding a comment that links to the Ruff playground showing what the AST we're dealing with here looks like, and explaining that we start at the innermost node in the AST and have to work our way upwards https://play.ruff.rs/89b67ffb-c32a-437e-aa8c-8dcfc8b7068a
|
OK, I added some documentation for you. |
Summary
Resolves #15998.
Previously, this would be considered an error by
DTZ005, asparent_expr_is_astimezone()would only traverse up one level:The function will now check for all expressions in the current stack, ignoring all such intermediate
.replace()calls while looking for.astimezone.Test Plan
cargo nextest runandcargo insta test.