Skip to content

Commit

Permalink
black formatting: comments + skip-magic-trailing-comma
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerYep committed May 9, 2021
1 parent c63635d commit aed8c25
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repos:

- id: black
name: black
entry: black
entry: black -C
language: python
types: [python]

Expand Down
4 changes: 2 additions & 2 deletions stanfordkarel/karel_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def create_slider(self) -> None:
self.scale.pack()

def create_canvas(self) -> None:
""" This method creates the canvas on which Karel and the world are drawn. """
"""This method creates the canvas on which Karel and the world are drawn."""
self.canvas = KarelCanvas(
self.canvas_width,
self.canvas_height,
Expand Down Expand Up @@ -229,7 +229,7 @@ def create_buttons(self) -> None:
)

def create_status_label(self) -> None:
""" This function creates the status label at the bottom of the window. """
"""This function creates the status label at the bottom of the window."""
self.status_label = tk.Label(
self.master, text="Welcome to Karel!", bg=LIGHT_GREY
)
Expand Down
6 changes: 3 additions & 3 deletions stanfordkarel/karel_ascii.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def tile_pair_has_wall(self, r: int, c: int, direction: Direction) -> bool:
raise ValueError("Direction is invalid.")

def get_next_line(self, r: int, c: int, next_block_start: str) -> tuple[str, str]:
""" Given a tile, figures out the lower line of the ASCII art. """
"""Given a tile, figures out the lower line of the ASCII art."""

if self.tile_pair_has_wall(r, c, Direction.SOUTH):
if (
Expand Down Expand Up @@ -177,10 +177,10 @@ class Color(Enum):


def compare_output(first: Any, second: Any) -> str:
""" Compares Karel Output and gets the results. """
"""Compares Karel Output and gets the results."""

def create_two_column_string(col1: list[str], col2: list[str]) -> Iterator[str]:
""" col1 and col2 are Lists. """
"""col1 and col2 are Lists."""
return map(lambda x: f"{x[0]}{' ' * SPACING}{x[1]}", zip(col1, col2))

def symmetric_difference(
Expand Down
4 changes: 2 additions & 2 deletions stanfordkarel/karel_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __init__(self, world_file: str) -> None:
self.num_beepers = self.world.karel_start_beeper_count

def __repr__(self) -> str:
""" Creates a Karel World in ASCII Art! """
"""Creates a Karel World in ASCII Art!"""
return str(AsciiKarelWorld(self.world, self.street, self.avenue))

def __eq__(self, other: object) -> bool:
Expand Down Expand Up @@ -407,7 +407,7 @@ def corner_color_is(self, color: str) -> bool:


class KarelException(Exception):
""" The following classes define Karel-specific exceptions. """
"""The following classes define Karel-specific exceptions."""

def __init__(
self, avenue: int, street: int, direction: Direction, message: str
Expand Down
8 changes: 4 additions & 4 deletions stanfordkarel/karel_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,12 +323,12 @@ def in_bounds(self, avenue: int, street: int) -> bool:
return 0 < avenue <= self.num_avenues and 0 < street <= self.num_streets

def reset_world(self) -> None:
""" Reset initial state of beepers in the world """
"""Reset initial state of beepers in the world"""
self.beepers = copy.deepcopy(self.init_beepers)
self.corner_colors = collections.defaultdict(lambda: "")

def reload_world(self, filename: str | None = None) -> None:
""" Reloads world using constructor. """
"""Reloads world using constructor."""
# TODO fix this
self.__init__(filename) # type: ignore

Expand Down Expand Up @@ -375,7 +375,7 @@ class Direction(Enum):
NORTH = "north"

def __lt__(self, other: object) -> bool:
""" Required to sort Directions. """
"""Required to sort Directions."""
if isinstance(other, Direction):
# pylint: disable=comparison-with-callable
return self.value < other.value
Expand All @@ -386,7 +386,7 @@ def __repr__(self) -> str:


class Wall(NamedTuple):
""" Note that the World Editor only uses West & South to denote wall directions. """
"""Note that the World Editor only uses West & South to denote wall directions."""

avenue: int
street: int
Expand Down
6 changes: 3 additions & 3 deletions stanfordkarel/style_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


def style_test(func: Callable[..., bool]) -> Callable[..., bool]:
""" Decorator for printing out the results of a style test. """
"""Decorator for printing out the results of a style test."""

def success_func(*args: Any, **kwargs: Any) -> bool:
result = func(*args, **kwargs)
Expand All @@ -32,7 +32,7 @@ def success_func(*args: Any, **kwargs: Any) -> bool:


class StyleChecker:
""" Style Checker for Karel. """
"""Style Checker for Karel."""

def __init__(self, code_file: Path) -> None:
self.student_code = StudentCode(code_file)
Expand Down Expand Up @@ -86,7 +86,7 @@ def check_function_defs(self, min_name_length: int = 5) -> bool:

@style_test
def check_naming(self, min_name_length: int = 5) -> bool:
""". """
"""."""
self.print_status_message("Checking function and variable names...")
stanfordkarel_names = dir(stanfordkarel)
root = ast.parse(str(self.student_code))
Expand Down

0 comments on commit aed8c25

Please sign in to comment.