Fix a number of formatter errors from the cpython repository (#5089)
## Summary This fixes a number of problems in the formatter that showed up with various files in the [cpython](https://github.com/python/cpython) repository. These problems surfaced as unstable formatting and invalid code. This is not the entirety of problems discovered through cpython, but a big enough chunk to separate it. Individual fixes are generally individual commits. They were discovered with #5055, which i update as i work through the output ## Test Plan I added regression tests with links to cpython for each entry, except for the two stubs that also got comment stubs since they'll be implemented properly later.
This commit is contained in:
@@ -4212,6 +4212,22 @@ impl AnyNodeRef<'_> {
|
||||
| AnyNodeRef::Decorator(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn is_node_with_body(self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
AnyNodeRef::StmtIf(_)
|
||||
| AnyNodeRef::StmtFor(_)
|
||||
| AnyNodeRef::StmtAsyncFor(_)
|
||||
| AnyNodeRef::StmtWhile(_)
|
||||
| AnyNodeRef::StmtWith(_)
|
||||
| AnyNodeRef::StmtAsyncWith(_)
|
||||
| AnyNodeRef::StmtMatch(_)
|
||||
| AnyNodeRef::StmtFunctionDef(_)
|
||||
| AnyNodeRef::StmtAsyncFunctionDef(_)
|
||||
| AnyNodeRef::StmtClassDef(_)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a ModModule> for AnyNodeRef<'a> {
|
||||
|
||||
Reference in New Issue
Block a user