Skip to content

Commit

Permalink
Upgrade to Ruff v0.9.6
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerYep committed Feb 11, 2025
1 parent c8c9315 commit bca65fa
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ci:
skip: [mypy, pytest]
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.4
rev: v0.9.6
hooks:
- id: ruff
args: [--fix]
Expand Down
3 changes: 2 additions & 1 deletion stanfordkarel/didyoumean.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
import difflib
import itertools
import re
from typing import TYPE_CHECKING, Any, Callable, Iterator
from typing import TYPE_CHECKING, Any

if TYPE_CHECKING:
from collections.abc import Callable, Iterator
from types import FrameType, TracebackType

# To be used in `get_suggestions_for_exception`.
Expand Down
7 changes: 5 additions & 2 deletions stanfordkarel/karel_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@
from tkinter.filedialog import askopenfilename
from tkinter.messagebox import showwarning
from types import FrameType, ModuleType
from typing import Any, Callable, cast
from typing import TYPE_CHECKING, Any, cast

from .didyoumean import add_did_you_mean
from .karel_canvas import DEFAULT_ICON, LIGHT_GREY, PAD_X, PAD_Y, KarelCanvas
from .karel_program import KarelException, KarelProgram

if TYPE_CHECKING:
from collections.abc import Callable


class StudentModule(ModuleType):
move: Any
Expand Down Expand Up @@ -130,7 +133,7 @@ def main(self) -> None:
try:
self.mods[0].main()
except Exception as e:
if isinstance(e, (KarelException, NameError, RuntimeError)):
if isinstance(e, KarelException | NameError | RuntimeError):
self.print_error_traceback(e)
raise

Expand Down
9 changes: 6 additions & 3 deletions stanfordkarel/karel_ascii.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@
from __future__ import annotations

from enum import Enum, unique
from typing import Any, Dict, Iterator, Tuple
from typing import TYPE_CHECKING, Any

from .karel_world import Direction, KarelWorld

if TYPE_CHECKING:
from collections.abc import Iterator

CHAR_WIDTH = 5
HORIZONTAL, VERTICAL = "─", "│"
SPACING = 10
BEEPER_COORDS = Dict[Tuple[int, int], int]
BEEPER_COORDS = dict[tuple[int, int], int]


class Tile:
Expand Down Expand Up @@ -182,7 +185,7 @@ def compare_output(first: Any, second: Any) -> str:

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

def symmetric_difference(
a: BEEPER_COORDS, b: BEEPER_COORDS
Expand Down
3 changes: 2 additions & 1 deletion stanfordkarel/style_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@

import ast
import inspect
from collections.abc import Callable
from pathlib import Path
from typing import Any, Callable
from typing import Any

import stanfordkarel

Expand Down
5 changes: 4 additions & 1 deletion stanfordkarel/world_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@
from pathlib import Path
from tkinter import messagebox, simpledialog
from tkinter.filedialog import askopenfilename, asksaveasfilename
from typing import Any, Callable
from typing import TYPE_CHECKING, Any

from .karel_canvas import DEFAULT_ICON, LIGHT_GREY, PAD_X, PAD_Y, KarelCanvas
from .karel_program import KarelProgram
from .karel_world import COLOR_MAP, INFINITY, Direction

if TYPE_CHECKING:
from collections.abc import Callable

MIN_DIMENSIONS = 1
MAX_DIMENSIONS = 50
DEFAULT_COLOR = "Red"
Expand Down

0 comments on commit bca65fa

Please sign in to comment.