Skip to content

Commit

Permalink
Use staticmethod where self not used
Browse files Browse the repository at this point in the history
  • Loading branch information
domdfcoding committed Nov 17, 2023
1 parent c5fa988 commit 3d1c6b2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
15 changes: 10 additions & 5 deletions formate/reformat_generics.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,15 @@ def visit(self, node: ast.AST) -> typing.List[typing.Tuple[ast.Subscript, Generi
super().visit(node)
return self.unions

def visit_FunctionDef(self, node: ast.FunctionDef) -> None:
@staticmethod
def visit_FunctionDef(node: ast.FunctionDef) -> None:
return None

def visit_ClassDef(self, node: ast.ClassDef) -> None:
self.unions.extend(ClassVisitor().visit(node))

def visit_AsyncFunctionDef(self, node: ast.AsyncFunctionDef) -> None:
@staticmethod
def visit_AsyncFunctionDef(node: ast.AsyncFunctionDef) -> None:
return None


Expand Down Expand Up @@ -221,16 +223,19 @@ def visit_List(self, node: ast.List) -> None:
elements.extend(UnionVisitor().visit(child))
self.structure.append(List(elements))

def visit_Load(self, node: ast.Load) -> None:
@staticmethod
def visit_Load(node: ast.Load) -> None:
return None

def visit_FunctionDef(self, node: ast.FunctionDef) -> None:
@staticmethod
def visit_FunctionDef(node: ast.FunctionDef) -> None:
return None

def visit_ClassDef(self, node: ast.ClassDef) -> None:
self.generic_visit(node)

def visit_AsyncFunctionDef(self, node: ast.AsyncFunctionDef) -> None:
@staticmethod
def visit_AsyncFunctionDef(node: ast.AsyncFunctionDef) -> None:
return None

if sys.version_info[:2] < (3, 8): # pragma: no cover (py38+)
Expand Down
6 changes: 4 additions & 2 deletions formate/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,13 @@ class SyntaxTracebackHandler(TracebackHandler):
Subclass of :class:`consolekit.tracebacks.TracebackHandler` to additionally handle :exc:`SyntaxError`.
"""

def handle_SyntaxError(self, e: SyntaxError) -> "NoReturn": # noqa: D102
@staticmethod
def handle_SyntaxError(e: SyntaxError) -> "NoReturn": # noqa: D102
click.echo(terminal_colours.Fore.RED(f"Fatal: {e.__class__.__name__}: {e}"), err=True)
sys.exit(126)

def handle_HookNotFoundError(self, e: HookNotFoundError) -> "NoReturn": # noqa: D102
@staticmethod
def handle_HookNotFoundError(e: HookNotFoundError) -> "NoReturn": # noqa: D102
click.echo(terminal_colours.Fore.RED(f"Fatal: Hook not found: {e}"), err=True)
sys.exit(126)

Expand Down

0 comments on commit 3d1c6b2

Please sign in to comment.