chore(Linter): reformatted code with black (#211)

* chore(Linter): reformatted code with black

* Create black.yaml
This commit is contained in:
Mark Aron Szulyovszky
2022-02-17 19:22:17 +01:00
committed by GitHub
parent f3fee4a4e1
commit 8dd2d88740
101 changed files with 2595 additions and 2319 deletions
+30 -33
View File
@@ -12,23 +12,23 @@ class ReplaceFunctionCommand(VisitorBasedCodemodCommand):
# Add a description so that future codemodders can see what this does.
DESCRIPTION: str = "Replaces the body of a function with pass."
def __init__(self, context: CodemodContext) -> None:
# Initialize the base class with context, and save our args. Remember, the
# "dest" for each argument we added above must match a parameter name in
# this init.
super().__init__(context)
def leave_FunctionDef(self, original_node: cst.FunctionDef, updated_node: cst.FunctionDef) -> cst.FunctionDef:
def leave_FunctionDef(
self, original_node: cst.FunctionDef, updated_node: cst.FunctionDef
) -> cst.FunctionDef:
functions_docstring = updated_node.get_docstring()
docstring_should_be = '"""No docstring here yet."""'
if functions_docstring is not None:
docstring_should_be = '"""\n{}\n\n"""'.format(functions_docstring)
replace_function = cst.FunctionDef(
name=updated_node.name,
params=updated_node.params,#cst.Parameters(),
name=updated_node.name,
params=updated_node.params, # cst.Parameters(),
body=cst.IndentedBlock(
body=[
cst.SimpleStatementLine(
@@ -44,50 +44,47 @@ class ReplaceFunctionCommand(VisitorBasedCodemodCommand):
],
leading_lines=[],
trailing_whitespace=cst.TrailingWhitespace(
whitespace=cst.SimpleWhitespace(
value='',
whitespace=cst.SimpleWhitespace(
value="",
),
comment=None,
newline=cst.Newline(
value=None,
),
),
),
),
cst.SimpleStatementLine(
body=[
cst.Pass(),
],
),
]
)
body=[
cst.Pass(),
],
),
]
),
)
return replace_function
def leave_ClassDef(self, original_node: cst.ClassDef, updated_node: cst.ClassDef) -> cst.ClassDef:
def leave_ClassDef(
self, original_node: cst.ClassDef, updated_node: cst.ClassDef
) -> cst.ClassDef:
new_body = []
for body_item in updated_node.body.body:
if type(body_item) is cst.FunctionDef:
new_body.append(self.leave_FunctionDef(body_item, body_item))
return updated_node.with_changes(
body=cst.IndentedBlock(new_body)
)
def leave_Module(self, original_node: cst.Module, updated_node: cst.Module) -> cst.Module:
new_module_body=[]
return updated_node.with_changes(body=cst.IndentedBlock(new_body))
def leave_Module(
self, original_node: cst.Module, updated_node: cst.Module
) -> cst.Module:
new_module_body = []
for node in original_node.body:
if type(node) is cst.FunctionDef:
new_module_body.append(self.leave_FunctionDef(node,node))
new_module_body.append(self.leave_FunctionDef(node, node))
if type(node) is cst.ClassDef:
new_module_body.append(self.leave_ClassDef(node,node))
new_module_body.append(self.leave_ClassDef(node, node))
replace_function = cst.Module(body=new_module_body)
replace_function = cst.Module(
body= new_module_body
)
return replace_function