Skip to content

Commit

Permalink
Update Ruff version
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerYep committed Mar 29, 2024
1 parent 8db13cf commit ad13357
Show file tree
Hide file tree
Showing 16 changed files with 68 additions and 39 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.1.14
rev: v0.3.4
hooks:
- id: ruff
args: [--fix]
Expand Down
30 changes: 14 additions & 16 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
target-version = "py312"
select = ["ALL"]
ignore = [
"ANN101", # Missing type annotation for `self` in method
"ANN102", # Missing type annotation for `cls` in classmethod
lint.select = ["ALL"]
lint.ignore = [
"ANN101", # Missing type annotation for `self` in method
"ANN102", # Missing type annotation for `cls` in classmethod
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed
"C901", # function is too complex (12 > 10)
"COM812", # Trailing comma missing
Expand All @@ -15,27 +15,25 @@ ignore = [
"FBT003", # Boolean positional value in function call
"FIX002", # Line contains TODO
"ISC001", # Isort
"PLR0911", # Too many return statements (11 > 6)
"PLR0911", # Too many return statements (11 > 6)
"PLR2004", # Magic value used in comparison, consider replacing 2 with a constant variable
"PLR0912", # Too many branches
"PLR0912", # Too many branches
"PLR0913", # Too many arguments to function call
"PLR0915", # Too many statements
"S101", # Use of `assert` detected
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
"T201", # print() found
"T203", # pprint() found
"TCH001", # Move application import into a type-checking block
"TCH003", # Move standard library import into a type-checking block
"TD002", # Missing author in TODO; try: `# TODO(<author_name>): ...`
"TD003", # Missing issue link on the line following this TODO
"TD005", # Missing issue description after `TODO`
"TRY003", # Avoid specifying long messages outside the exception class
"TD002", # Missing author in TODO; try: `# TODO(<author_name>): ...`
"TD003", # Missing issue link on the line following this TODO
"TD005", # Missing issue description after `TODO`
"TRY003", # Avoid specifying long messages outside the exception class

# WolfBot-specific ignores
"ARG001", # Unused function argument
"ARG004", # Unused static method argument
"PT004", # Fixture `override_random` does not return anything, add leading underscore
"ARG001", # Unused function argument
"ARG004", # Unused static method argument
"PT004", # Fixture `override_random` does not return anything, add leading underscore
]

[flake8-pytest-style]
[lint.flake8-pytest-style]
fixture-parentheses = false
8 changes: 5 additions & 3 deletions wolfbot/algorithms/expectimax.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from __future__ import annotations

import random
from typing import Any
from typing import TYPE_CHECKING, Any

from wolfbot import const
from wolfbot.solvers import SolverState
from wolfbot.statements import Statement

if TYPE_CHECKING:
from wolfbot.solvers import SolverState
from wolfbot.statements import Statement


def expectimax(
Expand Down
5 changes: 4 additions & 1 deletion wolfbot/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
import sys
from collections import Counter
from pathlib import Path
from types import ModuleType
from typing import TYPE_CHECKING

from wolfbot.enums import Role, Solver
from wolfbot.log import logger

if TYPE_CHECKING:
from types import ModuleType


def init_program(is_tests: bool) -> argparse.Namespace:
"""Command Line Arguments"""
Expand Down
6 changes: 4 additions & 2 deletions wolfbot/enums.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from __future__ import annotations

import functools
from collections.abc import Callable
from enum import Enum, IntEnum, auto, unique
from typing import Any, TypeVar, cast, override
from typing import TYPE_CHECKING, Any, TypeVar, cast, override

if TYPE_CHECKING:
from collections.abc import Callable

T = TypeVar("T")
CACHED_FUNCTIONS = set()
Expand Down
8 changes: 6 additions & 2 deletions wolfbot/game_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

import logging
import random
from collections.abc import Sequence
from typing import TYPE_CHECKING

from wolfbot import const
from wolfbot.enums import Role
from wolfbot.log import logger

if TYPE_CHECKING:
from collections.abc import Sequence

from wolfbot.enums import Role


def print_roles(
game_roles: Sequence[Role], tag: str, log_level: int = logging.DEBUG
Expand Down
1 change: 1 addition & 0 deletions wolfbot/learning/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
generate.py
To run: python -m wolfbot.learning.generate
"""

import json
import logging
import time
Expand Down
1 change: 1 addition & 0 deletions wolfbot/learning/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
train.py
To run: python -m wolfbot.learning.train
"""

import json

# import time
Expand Down
6 changes: 4 additions & 2 deletions wolfbot/roles/werewolf/minion.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import random
from typing import Any, Self, override
from typing import TYPE_CHECKING, Any, Self, override

from wolfbot import const
from wolfbot.enums import Role, lru_cache
Expand All @@ -15,7 +15,9 @@
get_wolf_statements_random,
)
from wolfbot.solvers import switching_solver as solver
from wolfbot.statements import KnowledgeBase, Statement

if TYPE_CHECKING:
from wolfbot.statements import KnowledgeBase, Statement


class Minion(Player):
Expand Down
6 changes: 4 additions & 2 deletions wolfbot/roles/werewolf/tanner.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import random
from typing import Self, override
from typing import TYPE_CHECKING, Self, override

from wolfbot import const
from wolfbot.enums import Role, lru_cache
Expand All @@ -12,7 +12,9 @@
get_wolf_statements_random,
)
from wolfbot.solvers import switching_solver as solver
from wolfbot.statements import KnowledgeBase, Statement

if TYPE_CHECKING:
from wolfbot.statements import KnowledgeBase, Statement


class Tanner(Player):
Expand Down
6 changes: 4 additions & 2 deletions wolfbot/roles/werewolf/wolf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import random
from typing import Any, Self, override
from typing import TYPE_CHECKING, Any, Self, override

from wolfbot import const
from wolfbot.enums import Role, lru_cache
Expand All @@ -17,7 +17,9 @@
get_wolf_statements_random,
)
from wolfbot.solvers import switching_solver as solver
from wolfbot.statements import KnowledgeBase, Statement

if TYPE_CHECKING:
from wolfbot.statements import KnowledgeBase, Statement


class Wolf(Player):
Expand Down
6 changes: 5 additions & 1 deletion wolfbot/solvers/cached.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from __future__ import annotations

from typing import TYPE_CHECKING

from wolfbot.solvers.state import SolverState
from wolfbot.statements import Statement

if TYPE_CHECKING:
from wolfbot.statements import Statement


def cached_solver(statements: tuple[Statement, ...]) -> int:
Expand Down
5 changes: 4 additions & 1 deletion wolfbot/solvers/relaxed.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from __future__ import annotations

import heapq
from typing import TYPE_CHECKING

from wolfbot import const
from wolfbot.solvers.state import SolverState
from wolfbot.statements import Statement

if TYPE_CHECKING:
from wolfbot.statements import Statement


def relaxed_solver(
Expand Down
8 changes: 5 additions & 3 deletions wolfbot/solvers/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import shutil
from dataclasses import dataclass, field
from functools import total_ordering
from typing import override
from typing import TYPE_CHECKING, override

from wolfbot import const
from wolfbot.enums import Role
from wolfbot.log import formatter
from wolfbot.statements import Statement, Switch

if TYPE_CHECKING:
from wolfbot.enums import Role
from wolfbot.statements import Statement, Switch


@total_ordering
Expand Down
6 changes: 5 additions & 1 deletion wolfbot/solvers/switching.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
from __future__ import annotations

from typing import TYPE_CHECKING

from wolfbot.solvers.state import SolverState
from wolfbot.statements import Statement

if TYPE_CHECKING:
from wolfbot.statements import Statement


def switching_solver(
Expand Down
3 changes: 1 addition & 2 deletions wolfbot/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
class SupportsLessThan(Protocol):
"""Enforces the type has __lt__ implemented."""

def __lt__(self, __other: Any) -> bool:
...
def __lt__(self, __other: Any) -> bool: ...


def weighted_coin_flip(prob: float) -> bool:
Expand Down

0 comments on commit ad13357

Please sign in to comment.